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/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/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/IndentedTextWriterExample/CPP/form1.cpp b/snippets/cpp/VS_Snippets_CLR/IndentedTextWriterExample/CPP/form1.cpp deleted file mode 100644 index 4c29bcd1705..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/IndentedTextWriterExample/CPP/form1.cpp +++ /dev/null @@ -1,120 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; -using namespace System::ComponentModel; -using namespace System::IO; -using namespace System::Windows::Forms; -public ref class Form1: public System::Windows::Forms::Form -{ -private: - System::Windows::Forms::TextBox^ textBox1; - - // - String^ CreateMultilevelIndentString() - { - - // - // Creates a TextWriter to use as the base output writer. - System::IO::StringWriter^ baseTextWriter = gcnew System::IO::StringWriter; - - // Create an IndentedTextWriter and set the tab string to use - // as the indentation string for each indentation level. - System::CodeDom::Compiler::IndentedTextWriter^ indentWriter = gcnew IndentedTextWriter( baseTextWriter," " ); - - // - // - // Sets the indentation level. - indentWriter->Indent = 0; - - // - // Output test strings at stepped indentations through a recursive loop method. - WriteLevel( indentWriter, 0, 5 ); - - // Return the resulting string from the base StringWriter. - return baseTextWriter->ToString(); - } - - - // - void WriteLevel( IndentedTextWriter^ indentWriter, int level, int totalLevels ) - { - - // Output a test string with a new-line character at the end. - indentWriter->WriteLine( "This is a test phrase. Current indentation level: {0}", level ); - - // If not yet at the highest recursion level, call this output method for the next level of indentation. - if ( level < totalLevels ) - { - - // Increase the indentation count for the next level of indented output. - indentWriter->Indent++; - - // Call the WriteLevel method to write test output for the next level of indentation. - WriteLevel( indentWriter, level + 1, totalLevels ); - - // Restores the indentation count for this level after the recursive branch method has returned. - indentWriter->Indent--; - } - else - // - // Outputs a string using the WriteLineNoTabs method. - indentWriter->WriteLineNoTabs( "This is a test phrase written with the IndentTextWriter.WriteLineNoTabs method." ); - // - // Outputs a test string with a new-line character at the end. - indentWriter->WriteLine( "This is a test phrase. Current indentation level: {0}", level ); - } - - - // - // - void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ ) - { - textBox1->Text = CreateMultilevelIndentString(); - } - - -public: - Form1() - { - System::Windows::Forms::Button^ button1 = gcnew System::Windows::Forms::Button; - this->textBox1 = gcnew System::Windows::Forms::TextBox; - this->SuspendLayout(); - this->textBox1->Anchor = (System::Windows::Forms::AnchorStyles)(System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left | System::Windows::Forms::AnchorStyles::Right); - this->textBox1->Location = System::Drawing::Point( 8, 40 ); - this->textBox1->Multiline = true; - this->textBox1->Name = "textBox1"; - this->textBox1->Size = System::Drawing::Size( 391, 242 ); - this->textBox1->TabIndex = 0; - this->textBox1->Text = ""; - button1->Location = System::Drawing::Point( 11, 8 ); - button1->Name = "button1"; - button1->Size = System::Drawing::Size( 229, 23 ); - button1->TabIndex = 1; - button1->Text = "Generate string using IndentedTextWriter"; - button1->Click += gcnew System::EventHandler( this, &Form1::button1_Click ); - this->AutoScaleBaseSize = System::Drawing::Size( 5, 13 ); - this->ClientSize = System::Drawing::Size( 407, 287 ); - this->Controls->Add( button1 ); - this->Controls->Add( this->textBox1 ); - this->Name = "Form1"; - this->Text = "IndentedTextWriter example"; - this->ResumeLayout( false ); - } - -}; - - -[STAThread] -int main() -{ - Application::Run( gcnew Form1 ); -} - -// 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/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/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/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/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/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/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_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.codedom.codeattributeargument/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codeattributeargument/cpp/source.cpp deleted file mode 100644 index 2b795397fac..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codeattributeargument/cpp/source.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; - -int main() -{ - // Declare a new type called Class1. - CodeTypeDeclaration^ class1 = gcnew CodeTypeDeclaration("Class1"); - - // Use attributes to mark the class as serializable and obsolete. - CodeAttributeDeclaration^ codeAttrDecl = - gcnew CodeAttributeDeclaration("System.Serializable"); - class1->CustomAttributes->Add(codeAttrDecl); - - CodeAttributeArgument^ codeAttr = - gcnew CodeAttributeArgument( gcnew CodePrimitiveExpression("This class is obsolete.")); - codeAttrDecl = gcnew CodeAttributeDeclaration("System.Obsolete", codeAttr); - class1->CustomAttributes->Add(codeAttrDecl); - - // Create a C# code provider - CodeDomProvider^ provider = CodeDomProvider::CreateProvider("CSharp"); - - // Generate code and send the output to the console - provider->GenerateCodeFromType(class1, Console::Out, gcnew CodeGeneratorOptions()); -} - -// The CPP code generator produces the following source code for the preceeding example code: -// -//[System.Serializable()] -//[System.Obsolete("This class is obsolete.")] -//public class Class1 { -//} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codeattributedeclaration/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codeattributedeclaration/cpp/source.cpp deleted file mode 100644 index 5523f2c37c7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codeattributedeclaration/cpp/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; - -int main() -{ - // Declare a new type called Class1. - CodeTypeDeclaration^ class1 = gcnew CodeTypeDeclaration("Class1"); - - // Declare a new code attribute - CodeAttributeDeclaration^ codeAttrDecl = gcnew CodeAttributeDeclaration( - "System.CLSCompliantAttribute", - gcnew CodeAttributeArgument(gcnew CodePrimitiveExpression(false))); - class1->CustomAttributes->Add(codeAttrDecl); - - // Create a C# code provider - CodeDomProvider^ provider = CodeDomProvider::CreateProvider("CSharp"); - - // Generate code and send the output to the console - provider->GenerateCodeFromType(class1, Console::Out, gcnew CodeGeneratorOptions()); -} - -// The CPP code generator produces the following source code for the preceeding example code: -// -//[System.CLSCompliantAttribute(false)] -//public class Class1 { -//} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codemethodreferenceexpression/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codemethodreferenceexpression/cpp/source.cpp deleted file mode 100644 index 4db196685db..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codemethodreferenceexpression/cpp/source.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; - -int main() -{ - // Declare a new type called Class1. - CodeTypeDeclaration^ class1 = gcnew CodeTypeDeclaration("Class1"); - - // Declares a type constructor that calls a method. - CodeConstructor^ constructor1 = gcnew CodeConstructor(); - constructor1->Attributes = MemberAttributes::Public; - class1->Members->Add(constructor1); - - // Creates a method reference for dict.Init. - CodeMethodReferenceExpression^ methodRef1 = - gcnew CodeMethodReferenceExpression( - gcnew CodeVariableReferenceExpression("dict"), - "Init", - gcnew array { - gcnew CodeTypeReference("System.Decimal"), - gcnew CodeTypeReference("System.Int32")}); - - // Invokes the dict.Init method from the constructor. - CodeMethodInvokeExpression^ invoke1 = - gcnew CodeMethodInvokeExpression(methodRef1, gcnew array {}); - constructor1->Statements->Add(invoke1); - - // Create a C# code provider - CodeDomProvider^ provider = CodeDomProvider::CreateProvider("CSharp"); - - // Generate code and send the output to the console - provider->GenerateCodeFromType(class1, Console::Out, gcnew CodeGeneratorOptions()); -} - -// The CPP code generator produces the following source code for the preceeding example code: -// -//public class Class1 { -// -// public Class1() { -// dict.Init(); -// } -// } -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.codedom.compiler.generatedcodeattribute/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.codedom.compiler.generatedcodeattribute/cpp/source.cpp deleted file mode 100644 index dcd7661e4aa..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.codedom.compiler.generatedcodeattribute/cpp/source.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; - -int main() -{ - // Declare a new type called Class1. - CodeTypeDeclaration^ class1 = gcnew CodeTypeDeclaration("Class1"); - - // Declare a new generated code attribute - GeneratedCodeAttribute^ generatedCodeAttribute = - gcnew GeneratedCodeAttribute("SampleCodeGenerator", "2.0.0.0"); - - // Use the generated code attribute members in the attribute declaration - CodeAttributeDeclaration^ codeAttrDecl = - gcnew CodeAttributeDeclaration(generatedCodeAttribute->GetType()->Name, - gcnew CodeAttributeArgument( - gcnew CodePrimitiveExpression(generatedCodeAttribute->Tool)), - gcnew CodeAttributeArgument( - gcnew CodePrimitiveExpression(generatedCodeAttribute->Version))); - class1->CustomAttributes->Add(codeAttrDecl); - - // Create a C# code provider - CodeDomProvider^ provider = CodeDomProvider::CreateProvider("CSharp"); - - // Generate code and send the output to the console - provider->GenerateCodeFromType(class1, Console::Out, gcnew CodeGeneratorOptions()); -} - -// The CPP code generator produces the following source code for the preceeding example code: -// -// [GeneratedCodeAttribute("SampleCodeGenerator", "2.0.0.0")] -// public class Class1 { -// } -// \ No newline at end of file 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/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.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"::: ]]>