diff --git a/snippets/cpp/VS_Snippets_CLR/ActivatorX/cpp/ActivatorX.cpp b/snippets/cpp/VS_Snippets_CLR/ActivatorX/cpp/ActivatorX.cpp deleted file mode 100644 index 23f9d8bfc08..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ActivatorX/cpp/ActivatorX.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Text; - -public ref class SomeType -{ -public: - void DoSomething(int x) - { - Console::WriteLine("100 / {0} = {1}", x, 100 / x); - } -}; - -void main() -{ - // - // Create an instance of the StringBuilder type using - // Activator.CreateInstance. - Object^ o = Activator::CreateInstance(StringBuilder::typeid); - - // Append a string into the StringBuilder object and display the - // StringBuilder. - StringBuilder^ sb = (StringBuilder^) o; - sb->Append("Hello, there."); - Console::WriteLine(sb); - // - - // - // Create an instance of the SomeType class that is defined in this - // assembly. - System::Runtime::Remoting::ObjectHandle^ oh = - Activator::CreateInstanceFrom(Assembly::GetEntryAssembly()->CodeBase, - SomeType::typeid->FullName); - - // Call an instance method defined by the SomeType type using this object. - SomeType^ st = (SomeType^) oh->Unwrap(); - - st->DoSomething(5); - // -}; - -/* This code produces the following output: - -Hello, there. -100 / 5 = 20 - */ -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/ActivatorX/cpp/source2.cpp b/snippets/cpp/VS_Snippets_CLR/ActivatorX/cpp/source2.cpp deleted file mode 100644 index d02d7ca37f0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ActivatorX/cpp/source2.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// -using namespace System; - -ref class DynamicInstanceList -{ -private: - static String^ instanceSpec = "System.EventArgs;System.Random;" + - "System.Exception;System.Object;System.Version"; - -public: - static void Main() - { - array^ instances = instanceSpec->Split(';'); - Array^ instlist = Array::CreateInstance(Object::typeid, instances->Length); - Object^ item; - - for (int i = 0; i < instances->Length; i++) - { - // create the object from the specification string - Console::WriteLine("Creating instance of: {0}", instances[i]); - item = Activator::CreateInstance(Type::GetType(instances[i])); - instlist->SetValue(item, i); - } - Console::WriteLine("\nObjects and their default values:\n"); - for each (Object^ o in instlist) - { - Console::WriteLine("Type: {0}\nValue: {1}\nHashCode: {2}\n", - o->GetType()->FullName, o->ToString(), o->GetHashCode()); - } - } -}; - -int main() -{ - DynamicInstanceList::Main(); -} - -// This program will display output similar to the following: -// -// Creating instance of: System.EventArgs -// Creating instance of: System.Random -// Creating instance of: System.Exception -// Creating instance of: System.Object -// Creating instance of: System.Version -// -// Objects and their default values: -// -// Type: System.EventArgs -// Value: System.EventArgs -// HashCode: 46104728 -// -// Type: System.Random -// Value: System.Random -// HashCode: 12289376 -// -// Type: System.Exception -// Value: System.Exception: Exception of type 'System.Exception' was thrown. -// HashCode: 55530882 -// -// Type: System.Object -// Value: System.Object -// HashCode: 30015890 -// -// Type: System.Version -// Value: 0.0 -// HashCode: 1048575 -// diff --git a/snippets/cpp/VS_Snippets_CLR/AnimalAttributes/CPP/customattribute.cpp b/snippets/cpp/VS_Snippets_CLR/AnimalAttributes/CPP/customattribute.cpp deleted file mode 100644 index 46b9455a618..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/AnimalAttributes/CPP/customattribute.cpp +++ /dev/null @@ -1,98 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -// An enumeration of animals. Start at 1 (0 = uninitialized). -public enum class Animal -{ - // Pets. - Dog = 1, - Cat, Bird -}; - -// A custom attribute to allow a target to have a pet. -public ref class AnimalTypeAttribute: public Attribute -{ -public: - - // The constructor is called when the attribute is set. - AnimalTypeAttribute( Animal pet ) - { - thePet = pet; - } - - -protected: - - // Keep a variable internally ... - Animal thePet; - -public: - - property Animal Pet - { - // .. and show a copy to the outside world. - Animal get() - { - return thePet; - } - - void set( Animal value ) - { - thePet = value; - } - } -}; - -// A test class where each method has its own pet. -ref class AnimalTypeTestClass -{ -public: - - [AnimalType(Animal::Dog)] - void DogMethod(){} - - - [AnimalType(Animal::Cat)] - void CatMethod(){} - - [AnimalType(Animal::Bird)] - void BirdMethod(){} - -}; - -int main() -{ - AnimalTypeTestClass^ testClass = gcnew AnimalTypeTestClass; - Type^ type = testClass->GetType(); - - // Iterate through all the methods of the class. - System::Collections::IEnumerator^ myEnum = - type->GetMethods()->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - MethodInfo^ mInfo = safe_cast(myEnum->Current); - - // Iterate through all the Attributes for each method. - System::Collections::IEnumerator^ myEnum1 = - Attribute::GetCustomAttributes( mInfo )->GetEnumerator(); - while ( myEnum1->MoveNext() ) - { - Attribute^ attr = safe_cast(myEnum1->Current); - - // Check for the AnimalType attribute. - if ( attr->GetType() == AnimalTypeAttribute::typeid ) - Console::WriteLine( "Method {0} has a pet {1} attribute.", - mInfo->Name, (dynamic_cast(attr))->Pet ); - } - } -} - -/* - * Output: - * Method DogMethod has a pet Dog attribute. - * Method CatMethod has a pet Cat attribute. - * Method BirdMethod has a pet Bird attribute. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/ArgumentException/cpp/ArgumentException.cpp b/snippets/cpp/VS_Snippets_CLR/ArgumentException/cpp/ArgumentException.cpp deleted file mode 100644 index 34a424f0c5f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ArgumentException/cpp/ArgumentException.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// Types:System.ArgumentException -// -using namespace System; - -// -int DivideByTwo(int num) -{ - // If num is an odd number, throw an ArgumentException. - if ((num & 1) == 1) - { - throw gcnew ArgumentException("Number must be even", "num"); - } - // num is even, return half of its value. - return num / 2; -} -// - -int main() -{ - // ArgumentException is not thrown because 10 is an even number. - Console::WriteLine("10 divided by 2 is {0}", DivideByTwo(10)); - try - { - // ArgumentException is thrown because 7 is not an even number. - Console::WriteLine("7 divided by 2 is {0}", DivideByTwo(7)); - } - catch (ArgumentException^) - { - // Show the user that 7 cannot be divided by 2. - Console::WriteLine("7 is not divided by 2 integrally."); - } -} - -// This code produces the following output. -// -// 10 divided by 2 is 5 -// 7 is not divided by 2 integrally. -// diff --git a/snippets/cpp/VS_Snippets_CLR/ArgumentException/cpp/argumentexception2.cpp b/snippets/cpp/VS_Snippets_CLR/ArgumentException/cpp/argumentexception2.cpp deleted file mode 100644 index 63ffdbb6142..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ArgumentException/cpp/argumentexception2.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// -using namespace System; - -static int DivideByTwo(int num) -{ - // If num is an odd number, throw an ArgumentException. - if ((num & 1) == 1) - throw gcnew ArgumentException(String::Format("{0} is not an even number", num), - "num"); - - // num is even, return half of its value. - return num / 2; -} - -void main() -{ - // Define some integers for a division operation. - array^ values = { 10, 7 }; - for each (int value in values) { - try { - Console::WriteLine("{0} divided by 2 is {1}", value, DivideByTwo(value)); - } - catch (ArgumentException^ e) { - Console::WriteLine("{0}: {1}", e->GetType()->Name, e->Message); - } - Console::WriteLine(); - } -} -// This example displays the following output: -// 10 divided by 2 is 5 -// -// ArgumentException: 7 is not an even number -// Parameter name: num -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/ArrayList/CPP/ArrayListSample.cpp b/snippets/cpp/VS_Snippets_CLR/ArrayList/CPP/ArrayListSample.cpp deleted file mode 100644 index dfe97aa75c8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ArrayList/CPP/ArrayListSample.cpp +++ /dev/null @@ -1,78 +0,0 @@ - -// -using namespace System; -using namespace System::Text; -using namespace System::Collections; - -// -ref class ReverseStringComparer: public IComparer -{ -public: - virtual int Compare( Object^ x, Object^ y ) - { - String^ s1 = dynamic_cast(x); - String^ s2 = dynamic_cast(y); - - //negate the return value to get the reverse order - return -String::Compare( s1, s2 ); - } - -}; -// - -// -void PrintValues( String^ title, IEnumerable^ myList ) -{ - Console::Write( "{0,10}: ", title ); - StringBuilder^ sb = gcnew StringBuilder; - { - IEnumerator^ en = myList->GetEnumerator(); - String^ s; - while ( en->MoveNext() ) - { - s = en->Current->ToString(); - sb->AppendFormat( "{0}, ", s ); - } - } - sb->Remove( sb->Length - 2, 2 ); - Console::WriteLine( sb ); -} -// - -void main() -{ - // - // Creates and initializes a new ArrayList. - ArrayList^ myAL = gcnew ArrayList; - myAL->Add( "Eric" ); - myAL->Add( "Mark" ); - myAL->Add( "Lance" ); - myAL->Add( "Rob" ); - myAL->Add( "Kris" ); - myAL->Add( "Brad" ); - myAL->Add( "Kit" ); - myAL->Add( "Bradley" ); - myAL->Add( "Keith" ); - myAL->Add( "Susan" ); - - // Displays the properties and values of the ArrayList. - Console::WriteLine( "Count: {0}", myAL->Count.ToString() ); - // - - PrintValues( "Unsorted", myAL ); - - // - myAL->Sort(); - PrintValues( "Sorted", myAL ); - // - - // - myAL->Sort( gcnew ReverseStringComparer ); - PrintValues( "Reverse", myAL ); - // - - // - array^names = dynamic_cast^>(myAL->ToArray( String::typeid )); - // -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/ArrayTypeMisMatch_Constructor1/CPP/arraytypemismatch_constructor1.cpp b/snippets/cpp/VS_Snippets_CLR/ArrayTypeMisMatch_Constructor1/CPP/arraytypemismatch_constructor1.cpp deleted file mode 100644 index 3bd578173ee..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ArrayTypeMisMatch_Constructor1/CPP/arraytypemismatch_constructor1.cpp +++ /dev/null @@ -1,56 +0,0 @@ - -// System::ArrayTypeMismatchException::ArrayTypeMismatchException -/* - * The following example demonstrates the 'ArrayTypeMismatchException()' constructor of class - * ArrayTypeMismatchException class. It creates a function which takes two arrays as arguments. - * It checks whether the two arrays are of same type or not. If two arrays are not of same type - * then a new 'ArrayTypeMismatchException' object is created and thrown. That exception is caught - * in the calling method. - */ -// -using namespace System; -public ref class ArrayTypeMisMatchConst -{ -public: - void CopyArray( Array^ myArray, Array^ myArray1 ) - { - String^ typeArray1 = myArray->GetType()->ToString(); - String^ typeArray2 = myArray1->GetType()->ToString(); - - // Check whether the two arrays are of same type or not. - if ( typeArray1 == typeArray2 ) - { - - // Copy the values from one array to another. - myArray->SetValue( String::Concat( "Name: ", myArray1->GetValue( 0 )->ToString() ), 0 ); - myArray->SetValue( String::Concat( "Name: ", myArray1->GetValue( 1 )->ToString() ), 1 ); - } - else - { - - // Throw an exception of type 'ArrayTypeMismatchException'. - throw gcnew ArrayTypeMismatchException; - } - } - -}; - -int main() -{ - try - { - array^myStringArray = gcnew array(2); - myStringArray->SetValue( "Jones", 0 ); - myStringArray->SetValue( "John", 1 ); - array^myIntArray = gcnew array(2); - ArrayTypeMisMatchConst^ myArrayType = gcnew ArrayTypeMisMatchConst; - myArrayType->CopyArray( myStringArray, myIntArray ); - } - catch ( ArrayTypeMismatchException^ e ) - { - Console::WriteLine( "The Exception is : {0}", e ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/ArrayTypeMisMatch_Constructor2/CPP/arraytypemismatch_constructor2.cpp b/snippets/cpp/VS_Snippets_CLR/ArrayTypeMisMatch_Constructor2/CPP/arraytypemismatch_constructor2.cpp deleted file mode 100644 index d83f12c18e3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ArrayTypeMisMatch_Constructor2/CPP/arraytypemismatch_constructor2.cpp +++ /dev/null @@ -1,57 +0,0 @@ - -// System::ArrayTypeMismatchException::ArrayTypeMismatchException -/* - The following example demonstrates the 'ArrayTypeMismatchException(String*)' - constructor of class ArrayTypeMismatchException class. A function has been - created which takes two arrays as arguments. It checks whether the two arrays - are of same type or not. If two arrays are of not same type then a new - 'ArrayTypeMismatchException' object is created and thrown. That exception is - caught in the calling method. - */ -// -using namespace System; -public ref class ArrayTypeMisMatchConst -{ -public: - void CopyArray( Array^ myArray, Array^ myArray1 ) - { - String^ typeArray1 = myArray->GetType()->ToString(); - String^ typeArray2 = myArray1->GetType()->ToString(); - - // Check whether the two arrays are of same type or not. - if ( typeArray1 == typeArray2 ) - { - - // Copies the values from one array to another. - myArray->SetValue( String::Concat( "Name: ", myArray1->GetValue( 0 )->ToString() ), 0 ); - myArray->SetValue( String::Concat( "Name: ", myArray1->GetValue( 1 )->ToString() ), 1 ); - } - else - { - - // Throw an exception of type 'ArrayTypeMismatchException' with a message String* as parameter. - throw gcnew ArrayTypeMismatchException( "The Source and destination arrays are not of same type." ); - } - } - -}; - -int main() -{ - try - { - array^myStringArray = gcnew array(2); - myStringArray->SetValue( "Jones", 0 ); - myStringArray->SetValue( "John", 1 ); - array^myIntArray = gcnew array(2); - ArrayTypeMisMatchConst^ myArrayType = gcnew ArrayTypeMisMatchConst; - myArrayType->CopyArray( myStringArray, myIntArray ); - } - catch ( ArrayTypeMismatchException^ e ) - { - Console::WriteLine( "The Exception Message is : {0}", e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/ArrayTypeMisMatch_Constructor3/CPP/arraytypemismatch_constructor3.cpp b/snippets/cpp/VS_Snippets_CLR/ArrayTypeMisMatch_Constructor3/CPP/arraytypemismatch_constructor3.cpp deleted file mode 100644 index 83d9a347667..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ArrayTypeMisMatch_Constructor3/CPP/arraytypemismatch_constructor3.cpp +++ /dev/null @@ -1,56 +0,0 @@ - -// System::ArrayTypeMismatchException::ArrayTypeMismatchException -/* - The following example demonstrates the 'ArrayTypeMismatchException(String*, innerException)' - constructor of class ArrayTypeMismatchException class. It creates a - function which takes two arrays as arguments. It copies elements of - one array to another array. If two arrays are of not same type then - an exception has been thrown. In the 'Catch' block a new 'WebException' - object is created and thrown to the caller. That exception is caught - in the calling method and the error message is displayed to the console. - */ -// -using namespace System; -public ref class ArrayTypeMisMatchConst -{ -public: - void CopyArray( Array^ myArray, Array^ myArray1 ) - { - try - { - - // Copies the value of one array into another array. - myArray->SetValue( myArray1->GetValue( 0 ), 0 ); - myArray->SetValue( myArray1->GetValue( 1 ), 1 ); - } - catch ( Exception^ e ) - { - - // Throw an exception of with a message and innerexception. - throw gcnew ArrayTypeMismatchException( "The Source and destination arrays are of not same type.",e ); - } - - } - -}; - -int main() -{ - try - { - array^myStringArray = gcnew array(2); - myStringArray->SetValue( "Jones", 0 ); - myStringArray->SetValue( "John", 1 ); - array^myIntArray = gcnew array(2); - ArrayTypeMisMatchConst^ myArrayType = gcnew ArrayTypeMisMatchConst; - myArrayType->CopyArray( myStringArray, myIntArray ); - } - catch ( ArrayTypeMismatchException^ e ) - { - Console::WriteLine( "The Exception Message is : {0}", e->Message ); - Console::WriteLine( "The Inner exception is : {0}", e->InnerException ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Array_ConvertAll/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Array_ConvertAll/cpp/source.cpp deleted file mode 100644 index 6ea5b937007..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Array_ConvertAll/cpp/source.cpp +++ /dev/null @@ -1,55 +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() -{ - // Create an array of PointF objects. - array^ apf = { - PointF(27.8F, 32.62F), - PointF(99.3F, 147.273F), - PointF(7.5F, 1412.2F) }; - - - // Display each element in the PointF array. - Console::WriteLine(); - for each(PointF p in apf) - { - Console::WriteLine(p); - } - - // Convert each PointF element to a Point object. - array^ ap = - Array::ConvertAll(apf, - gcnew Converter(PointFToPoint) - ); - - // Display each element in the Point array. - Console::WriteLine(); - for each(Point p in ap) - { - 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/Array_FindEtAl/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Array_FindEtAl/cpp/source.cpp deleted file mode 100644 index 61bb710737e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Array_FindEtAl/cpp/source.cpp +++ /dev/null @@ -1,169 +0,0 @@ -// -using namespace System; - -public ref class DinoDiscoverySet -{ -public: - static void Main() - { - array^ dinosaurs = - { - "Compsognathus", "Amargasaurus", "Oviraptor", - "Velociraptor", "Deinonychus", "Dilophosaurus", - "Gallimimus", "Triceratops" - }; - - DinoDiscoverySet^ GoMesozoic = gcnew DinoDiscoverySet(dinosaurs); - - GoMesozoic->DiscoverAll(); - GoMesozoic->DiscoverByEnding("saurus"); - } - - DinoDiscoverySet(array^ items) - { - dinosaurs = items; - } - - void DiscoverAll() - { - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs) - { - Console::WriteLine(dinosaur); - } - } - - void DiscoverByEnding(String^ Ending) - { - Predicate^ dinoType; - - if (Ending->ToLower() == "raptor") - { - dinoType = - gcnew Predicate(&DinoDiscoverySet::EndsWithRaptor); - } - else if (Ending->ToLower() == "tops") - { - dinoType = - gcnew Predicate(&DinoDiscoverySet::EndsWithTops); - } - else if (Ending->ToLower() == "saurus") - { - dinoType = - gcnew Predicate(&DinoDiscoverySet::EndsWithSaurus); - } - else - { - dinoType = - gcnew Predicate(&DinoDiscoverySet::EndsWithSaurus); - } - - Console::WriteLine( - "\nArray::Exists(dinosaurs, \"{0}\"): {1}", - Ending, - Array::Exists(dinosaurs, dinoType)); - - Console::WriteLine( - "\nArray::TrueForAll(dinosaurs, \"{0}\"): {1}", - Ending, - Array::TrueForAll(dinosaurs, dinoType)); - - Console::WriteLine( - "\nArray::Find(dinosaurs, \"{0}\"): {1}", - Ending, - Array::Find(dinosaurs, dinoType)); - - Console::WriteLine( - "\nArray::FindLast(dinosaurs, \"{0}\"): {1}", - Ending, - Array::FindLast(dinosaurs, dinoType)); - - Console::WriteLine( - "\nArray::FindAll(dinosaurs, \"{0}\"):", Ending); - - array^ subArray = - Array::FindAll(dinosaurs, dinoType); - - for each(String^ dinosaur in subArray) - { - Console::WriteLine(dinosaur); - } - } - -private: - array^ dinosaurs; - - // Search predicate returns true if a string ends in "saurus". - static bool EndsWithSaurus(String^ s) - { - if ((s->Length > 5) && - (s->Substring(s->Length - 6)->ToLower() == "saurus")) - { - return true; - } - else - { - return false; - } - } - - // Search predicate returns true if a string ends in "raptor". - static bool EndsWithRaptor(String^ s) - { - if ((s->Length > 5) && - (s->Substring(s->Length - 6)->ToLower() == "raptor")) - { - return true; - } - else - { - return false; - } - } - - // Search predicate returns true if a string ends in "tops". - static bool EndsWithTops(String^ s) - { - if ((s->Length > 3) && - (s->Substring(s->Length - 4)->ToLower() == "tops")) - { - return true; - } - else - { - return false; - } - } -}; - -int main() -{ - DinoDiscoverySet::Main(); -} - -/* This code example produces the following output: - -Compsognathus -Amargasaurus -Oviraptor -Velociraptor -Deinonychus -Dilophosaurus -Gallimimus -Triceratops - -Array.Exists(dinosaurs, "saurus"): True - -Array.TrueForAll(dinosaurs, "saurus"): False - -Array.Find(dinosaurs, "saurus"): Amargasaurus - -Array.FindLast(dinosaurs, "saurus"): Dilophosaurus - -Array.FindAll(dinosaurs, "saurus"): -Amargasaurus -Dilophosaurus -*/ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/Array_FindIndex/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Array_FindIndex/cpp/source.cpp deleted file mode 100644 index da0510c1de8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Array_FindIndex/cpp/source.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// -using namespace System; - -// Search predicate returns true if a string ends in "saurus". -bool EndsWithSaurus(String^ s) -{ - if ((s->Length > 5) && - (s->Substring(s->Length - 6)->ToLower() == "saurus")) - { - return true; - } - else - { - return false; - } -}; - -void main() -{ - array^ dinosaurs = { "Compsognathus", - "Amargasaurus", "Oviraptor", "Velociraptor", - "Deinonychus", "Dilophosaurus", "Gallimimus", - "Triceratops" }; - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs ) - { - Console::WriteLine(dinosaur); - } - - Console::WriteLine("\nArray::FindIndex(dinosaurs, EndsWithSaurus): {0}", - Array::FindIndex(dinosaurs, gcnew Predicate(EndsWithSaurus))); - - Console::WriteLine("\nArray::FindIndex(dinosaurs, 2, EndsWithSaurus): {0}", - Array::FindIndex(dinosaurs, 2, gcnew Predicate(EndsWithSaurus))); - - Console::WriteLine("\nArray::FindIndex(dinosaurs, 2, 3, EndsWithSaurus): {0}", - Array::FindIndex(dinosaurs, 2, 3, gcnew Predicate(EndsWithSaurus))); -} - -/* This code example produces the following output: - -Compsognathus -Amargasaurus -Oviraptor -Velociraptor -Deinonychus -Dilophosaurus -Gallimimus -Triceratops - -Array::FindIndex(dinosaurs, EndsWithSaurus): 1 - -Array::FindIndex(dinosaurs, 2, EndsWithSaurus): 5 - -Array::FindIndex(dinosaurs, 2, 3, EndsWithSaurus): -1 - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/Array_FindLastIndex/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Array_FindLastIndex/cpp/source.cpp deleted file mode 100644 index 2ce93684dce..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Array_FindLastIndex/cpp/source.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// -using namespace System; - -// Search predicate returns true if a string ends in "saurus". -bool EndsWithSaurus(String^ s) -{ - if ((s->Length > 5) && - (s->Substring(s->Length - 6)->ToLower() == "saurus")) - { - return true; - } - else - { - return false; - } -}; - -void main() -{ - array^ dinosaurs = { "Compsognathus", - "Amargasaurus", "Oviraptor", "Velociraptor", - "Deinonychus", "Dilophosaurus", "Gallimimus", - "Triceratops" }; - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs ) - { - Console::WriteLine(dinosaur); - } - - Console::WriteLine("\nArray::FindLastIndex(dinosaurs, EndsWithSaurus): {0}", - Array::FindLastIndex(dinosaurs, gcnew Predicate(EndsWithSaurus))); - - Console::WriteLine("\nArray::FindLastIndex(dinosaurs, 4, EndsWithSaurus): {0}", - Array::FindLastIndex(dinosaurs, 4, gcnew Predicate(EndsWithSaurus))); - - Console::WriteLine("\nArray::FindLastIndex(dinosaurs, 4, 3, EndsWithSaurus): {0}", - Array::FindLastIndex(dinosaurs, 4, 3, gcnew Predicate(EndsWithSaurus))); -} - -/* This code example produces the following output: - -Compsognathus -Amargasaurus -Oviraptor -Velociraptor -Deinonychus -Dilophosaurus -Gallimimus -Triceratops - -Array::FindLastIndex(dinosaurs, EndsWithSaurus): 5 - -Array::FindLastIndex(dinosaurs, 4, EndsWithSaurus): 1 - -Array::FindLastIndex(dinosaurs, 4, 3, EndsWithSaurus): -1 - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/Array_IndexOf/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Array_IndexOf/cpp/source.cpp deleted file mode 100644 index 946551d8cde..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Array_IndexOf/cpp/source.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// -using namespace System; - -void main() -{ - array^ dinosaurs = { "Tyrannosaurus", - "Amargasaurus", - "Mamenchisaurus", - "Brachiosaurus", - "Deinonychus", - "Tyrannosaurus", - "Compsognathus" }; - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs ) - { - Console::WriteLine(dinosaur); - } - - Console::WriteLine("\nArray.IndexOf(dinosaurs, \"Tyrannosaurus\"): {0}", - Array::IndexOf(dinosaurs, "Tyrannosaurus")); - - Console::WriteLine("\nArray.IndexOf(dinosaurs, \"Tyrannosaurus\", 3): {0}", - Array::IndexOf(dinosaurs, "Tyrannosaurus", 3)); - - Console::WriteLine("\nArray.IndexOf(dinosaurs, \"Tyrannosaurus\", 2, 2): {0}", - Array::IndexOf(dinosaurs, "Tyrannosaurus", 2, 2)); -} - -/* This code example produces the following output: - -Tyrannosaurus -Amargasaurus -Mamenchisaurus -Brachiosaurus -Deinonychus -Tyrannosaurus -Compsognathus - -Array.IndexOf(dinosaurs, "Tyrannosaurus"): 0 - -Array.IndexOf(dinosaurs, "Tyrannosaurus", 3): 5 - -Array.IndexOf(dinosaurs, "Tyrannosaurus", 2, 2): -1 - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/Array_LastIndexOf/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Array_LastIndexOf/cpp/source.cpp deleted file mode 100644 index 2f297639c6a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Array_LastIndexOf/cpp/source.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// -using namespace System; - -void main() -{ - array^ dinosaurs = { "Tyrannosaurus", - "Amargasaurus", - "Mamenchisaurus", - "Brachiosaurus", - "Deinonychus", - "Tyrannosaurus", - "Compsognathus" }; - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs ) - { - Console::WriteLine(dinosaur); - } - - Console::WriteLine( - "\nArray.LastIndexOf(dinosaurs, \"Tyrannosaurus\"): {0}", - Array::LastIndexOf(dinosaurs, "Tyrannosaurus")); - - Console::WriteLine( - "\nArray.LastIndexOf(dinosaurs, \"Tyrannosaurus\", 3): {0}", - Array::LastIndexOf(dinosaurs, "Tyrannosaurus", 3)); - - Console::WriteLine( - "\nArray.LastIndexOf(dinosaurs, \"Tyrannosaurus\", 4, 4): {0}", - Array::LastIndexOf(dinosaurs, "Tyrannosaurus", 4, 4)); -} - -/* This code example produces the following output: - -Tyrannosaurus -Amargasaurus -Mamenchisaurus -Brachiosaurus -Deinonychus -Tyrannosaurus -Compsognathus - -Array.LastIndexOf(dinosaurs, "Tyrannosaurus"): 5 - -Array.LastIndexOf(dinosaurs, "Tyrannosaurus", 3): 0 - -Array.LastIndexOf(dinosaurs, "Tyrannosaurus", 4, 4): -1 - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/Array_Sort2IntIntIComparer/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Array_Sort2IntIntIComparer/cpp/source.cpp deleted file mode 100644 index 0eece7d8c34..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Array_Sort2IntIntIComparer/cpp/source.cpp +++ /dev/null @@ -1,124 +0,0 @@ -// -using namespace System; -using namespace System::Collections::Generic; - -public ref class ReverseComparer: IComparer -{ -public: - virtual int Compare(String^ x, String^ y) - { - // Compare y and x in reverse order. - return y->CompareTo(x); - } -}; - -void main() -{ - array^ dinosaurs = { - "Seismosaurus", - "Chasmosaurus", - "Coelophysis", - "Mamenchisaurus", - "Caudipteryx", - "Cetiosaurus" }; - - array^ dinosaurSizes = { 40, 5, 3, 22, 1, 18 }; - - Console::WriteLine(); - for (int i = 0; i < dinosaurs->Length; i++) - { - Console::WriteLine("{0}: up to {1} meters long.", - dinosaurs[i], dinosaurSizes[i]); - } - - Console::WriteLine("\nSort(dinosaurs, dinosaurSizes)"); - Array::Sort(dinosaurs, dinosaurSizes); - - Console::WriteLine(); - for (int i = 0; i < dinosaurs->Length; i++) - { - Console::WriteLine("{0}: up to {1} meters long.", - dinosaurs[i], dinosaurSizes[i]); - } - - ReverseComparer^ rc = gcnew ReverseComparer(); - - Console::WriteLine("\nSort(dinosaurs, dinosaurSizes, rc)"); - Array::Sort(dinosaurs, dinosaurSizes, rc); - - Console::WriteLine(); - for (int i = 0; i < dinosaurs->Length; i++) - { - Console::WriteLine("{0}: up to {1} meters long.", - dinosaurs[i], dinosaurSizes[i]); - } - - Console::WriteLine("\nSort(dinosaurs, dinosaurSizes, 3, 3)"); - Array::Sort(dinosaurs, dinosaurSizes, 3, 3); - - Console::WriteLine(); - for (int i = 0; i < dinosaurs->Length; i++) - { - Console::WriteLine("{0}: up to {1} meters long.", - dinosaurs[i], dinosaurSizes[i]); - } - - Console::WriteLine("\nSort(dinosaurs, dinosaurSizes, 3, 3, rc)"); - Array::Sort(dinosaurs, dinosaurSizes, 3, 3, rc); - - Console::WriteLine(); - for (int i = 0; i < dinosaurs->Length; i++) - { - Console::WriteLine("{0}: up to {1} meters long.", - dinosaurs[i], dinosaurSizes[i]); - } -} - -/* This code example produces the following output: - -Seismosaurus: up to 40 meters long. -Chasmosaurus: up to 5 meters long. -Coelophysis: up to 3 meters long. -Mamenchisaurus: up to 22 meters long. -Caudipteryx: up to 1 meters long. -Cetiosaurus: up to 18 meters long. - -Sort(dinosaurs, dinosaurSizes) - -Caudipteryx: up to 1 meters long. -Cetiosaurus: up to 18 meters long. -Chasmosaurus: up to 5 meters long. -Coelophysis: up to 3 meters long. -Mamenchisaurus: up to 22 meters long. -Seismosaurus: up to 40 meters long. - -Sort(dinosaurs, dinosaurSizes, rc) - -Seismosaurus: up to 40 meters long. -Mamenchisaurus: up to 22 meters long. -Coelophysis: up to 3 meters long. -Chasmosaurus: up to 5 meters long. -Cetiosaurus: up to 18 meters long. -Caudipteryx: up to 1 meters long. - -Sort(dinosaurs, dinosaurSizes, 3, 3) - -Seismosaurus: up to 40 meters long. -Mamenchisaurus: up to 22 meters long. -Coelophysis: up to 3 meters long. -Caudipteryx: up to 1 meters long. -Cetiosaurus: up to 18 meters long. -Chasmosaurus: up to 5 meters long. - -Sort(dinosaurs, dinosaurSizes, 3, 3, rc) - -Seismosaurus: up to 40 meters long. -Mamenchisaurus: up to 22 meters long. -Coelophysis: up to 3 meters long. -Chasmosaurus: up to 5 meters long. -Cetiosaurus: up to 18 meters long. -Caudipteryx: up to 1 meters long. - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/Array_SortComparison/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Array_SortComparison/cpp/source.cpp deleted file mode 100644 index 8570582fcc3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Array_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(array^ arr) -{ - Console::WriteLine(); - for each(String^ s in arr) - { - if (s == nullptr) - Console::WriteLine("(null)"); - else - Console::WriteLine("\"{0}\"", s); - } -}; - -void main() -{ - array^ dinosaurs = { - "Pachycephalosaurus", - "Amargasaurus", - "", - nullptr, - "Mamenchisaurus", - "Deinonychus" }; - Display(dinosaurs); - - Console::WriteLine("\nSort with generic Comparison delegate:"); - Array::Sort(dinosaurs, - 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/Array_SortIntIntIComparer/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Array_SortIntIntIComparer/cpp/source.cpp deleted file mode 100644 index d51b2194310..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Array_SortIntIntIComparer/cpp/source.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// -using namespace System; -using namespace System::Collections::Generic; - -public ref class ReverseComparer: IComparer -{ -public: - virtual int Compare(String^ x, String^ y) - { - // Compare y and x in reverse order. - return y->CompareTo(x); - } -}; - -void main() -{ - array^ dinosaurs = {"Pachycephalosaurus", - "Amargasaurus", - "Mamenchisaurus", - "Tarbosaurus", - "Tyrannosaurus", - "Albertasaurus"}; - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs) - { - Console::WriteLine(dinosaur); - } - - Console::WriteLine("\nSort(dinosaurs, 3, 3)"); - Array::Sort(dinosaurs, 3, 3); - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs) - { - Console::WriteLine(dinosaur); - } - - ReverseComparer^ rc = gcnew ReverseComparer(); - - Console::WriteLine("\nSort(dinosaurs, 3, 3, rc)"); - Array::Sort(dinosaurs, 3, 3, rc); - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs) - { - Console::WriteLine(dinosaur); - } -} - -/* This code example produces the following output: - -Pachycephalosaurus -Amargasaurus -Mamenchisaurus -Tarbosaurus -Tyrannosaurus -Albertasaurus - -Sort(dinosaurs, 3, 3) - -Pachycephalosaurus -Amargasaurus -Mamenchisaurus -Albertasaurus -Tarbosaurus -Tyrannosaurus - -Sort(dinosaurs, 3, 3, rc) - -Pachycephalosaurus -Amargasaurus -Mamenchisaurus -Tyrannosaurus -Tarbosaurus -Albertasaurus - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/Array_SortSearch/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Array_SortSearch/cpp/source.cpp deleted file mode 100644 index 1d9c96cc967..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Array_SortSearch/cpp/source.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// -using namespace System; -using namespace System::Collections::Generic; - -generic void ShowWhere(array^ arr, int index) -{ - if (index<0) - { - // If the index is negative, it represents the bitwise - // complement of the next larger element in the array. - // - index = ~index; - - Console::Write("Not found. Sorts between: "); - - if (index == 0) - Console::Write("beginning of array and "); - else - Console::Write("{0} and ", arr[index-1]); - - if (index == arr->Length) - Console::WriteLine("end of array."); - else - Console::WriteLine("{0}.", arr[index]); - } - else - { - Console::WriteLine("Found at index {0}.", index); - } -}; - -void main() -{ - array^ dinosaurs = {"Pachycephalosaurus", - "Amargasaurus", - "Tyrannosaurus", - "Mamenchisaurus", - "Deinonychus", - "Edmontosaurus"}; - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs) - { - Console::WriteLine(dinosaur); - } - - Console::WriteLine("\nSort"); - Array::Sort(dinosaurs); - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs) - { - Console::WriteLine(dinosaur); - } - - Console::WriteLine("\nBinarySearch for 'Coelophysis':"); - int index = Array::BinarySearch(dinosaurs, "Coelophysis"); - ShowWhere(dinosaurs, index); - - Console::WriteLine("\nBinarySearch for 'Tyrannosaurus':"); - index = Array::BinarySearch(dinosaurs, "Tyrannosaurus"); - ShowWhere(dinosaurs, index); -} - -/* This code example produces the following output: - -Pachycephalosaurus -Amargasaurus -Tyrannosaurus -Mamenchisaurus -Deinonychus -Edmontosaurus - -Sort - -Amargasaurus -Deinonychus -Edmontosaurus -Mamenchisaurus -Pachycephalosaurus -Tyrannosaurus - -BinarySearch for 'Coelophysis': -Not found. Sorts between: Amargasaurus and Deinonychus. - -BinarySearch for 'Tyrannosaurus': -Found at index 5. - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/Array_SortSearchComparer/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Array_SortSearchComparer/cpp/source.cpp deleted file mode 100644 index d19063bd802..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Array_SortSearchComparer/cpp/source.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// -using namespace System; -using namespace System::Collections::Generic; - -public ref class ReverseComparer: IComparer -{ -public: - virtual int Compare(String^ x, String^ y) - { - // Compare y and x in reverse order. - return y->CompareTo(x); - } -}; - -generic void ShowWhere(array^ arr, int index) -{ - if (index<0) - { - // If the index is negative, it represents the bitwise - // complement of the next larger element in the array. - // - index = ~index; - - Console::Write("Not found. Sorts between: "); - - if (index == 0) - Console::Write("beginning of array and "); - else - Console::Write("{0} and ", arr[index-1]); - - if (index == arr->Length) - Console::WriteLine("end of array."); - else - Console::WriteLine("{0}.", arr[index]); - } - else - { - Console::WriteLine("Found at index {0}.", index); - } -}; - -void main() -{ - array^ dinosaurs = {"Pachycephalosaurus", - "Amargasaurus", - "Tyrannosaurus", - "Mamenchisaurus", - "Deinonychus", - "Edmontosaurus"}; - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs) - { - Console::WriteLine(dinosaur); - } - - ReverseComparer^ rc = gcnew ReverseComparer(); - - Console::WriteLine("\nSort"); - Array::Sort(dinosaurs, rc); - - Console::WriteLine(); - for each(String^ dinosaur in dinosaurs) - { - Console::WriteLine(dinosaur); - } - - Console::WriteLine("\nBinarySearch for 'Coelophysis':"); - int index = Array::BinarySearch(dinosaurs, "Coelophysis", rc); - ShowWhere(dinosaurs, index); - - Console::WriteLine("\nBinarySearch for 'Tyrannosaurus':"); - index = Array::BinarySearch(dinosaurs, "Tyrannosaurus", rc); - ShowWhere(dinosaurs, index); -} - -/* This code example produces the following output: - -Pachycephalosaurus -Amargasaurus -Tyrannosaurus -Mamenchisaurus -Deinonychus -Edmontosaurus - -Sort - -Tyrannosaurus -Pachycephalosaurus -Mamenchisaurus -Edmontosaurus -Deinonychus -Amargasaurus - -BinarySearch for 'Coelophysis': -Not found. Sorts between: Deinonychus and Amargasaurus. - -BinarySearch for 'Tyrannosaurus': -Found at index 0. - */ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/AttrTargs/CPP/attrtargs.cpp b/snippets/cpp/VS_Snippets_CLR/AttrTargs/CPP/attrtargs.cpp deleted file mode 100644 index 41f69f4f144..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/AttrTargs/CPP/attrtargs.cpp +++ /dev/null @@ -1,73 +0,0 @@ - -// -using namespace System; - -namespace AttTargsCS -{ - - // This attribute is only valid on a class. - - [AttributeUsage(AttributeTargets::Class)] - public ref class ClassTargetAttribute: public Attribute{}; - - - // This attribute is only valid on a method. - - [AttributeUsage(AttributeTargets::Method)] - public ref class MethodTargetAttribute: public Attribute{}; - - - // This attribute is only valid on a constructor. - - [AttributeUsage(AttributeTargets::Constructor)] - public ref class ConstructorTargetAttribute: public Attribute{}; - - - // This attribute is only valid on a field. - - [AttributeUsage(AttributeTargets::Field)] - public ref class FieldTargetAttribute: public Attribute{}; - - - // This attribute is valid on a class or a method. - - [AttributeUsage(AttributeTargets::Class|AttributeTargets::Method)] - public ref class ClassMethodTargetAttribute: public Attribute{}; - - - // This attribute is valid on any target. - - [AttributeUsage(AttributeTargets::All)] - public ref class AllTargetsAttribute: public Attribute{}; - - - [ClassTarget] - [ClassMethodTarget] - [AllTargets] - public ref class TestClassAttribute - { - private: - - [ConstructorTarget] - [AllTargets] - TestClassAttribute(){} - - - public: - - [MethodTarget] - [ClassMethodTarget] - [AllTargets] - void Method1(){} - - - [FieldTarget] - [AllTargets] - int myInt; - static void Main(){} - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeArgumentReferenceExpressionExample/CPP/codeargumentreferenceexpressionexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeArgumentReferenceExpressionExample/CPP/codeargumentreferenceexpressionexample.cpp deleted file mode 100644 index cafb9d2dab4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeArgumentReferenceExpressionExample/CPP/codeargumentreferenceexpressionexample.cpp +++ /dev/null @@ -1,43 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSamples -{ - public ref class CodeArgumentReferenceExpressionExample - { - public: - CodeArgumentReferenceExpressionExample() - { - - // - // Declare a method that accepts a string parameter named text. - CodeMemberMethod^ cmm = gcnew CodeMemberMethod; - cmm->Parameters->Add( gcnew CodeParameterDeclarationExpression( "String","text" ) ); - cmm->Name = "WriteString"; - cmm->ReturnType = gcnew CodeTypeReference( "System::Void" ); - array^ce = {gcnew CodeArgumentReferenceExpression( "test1" )}; - - // Create a method invoke statement to output the string passed to the method. - CodeMethodInvokeExpression^ cmie = gcnew CodeMethodInvokeExpression( gcnew CodeTypeReferenceExpression( "Console" ),"WriteLine",ce ); - - // Add the method invoke expression to the method's statements collection. - cmm->Statements->Add( cmie ); - - // A C++ code generator produces the following source code for the preceeding example code: - // private: - // void WriteString(String text) { - // Console::WriteLine(text); - // } - // - } - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeArrayCreateExpressionSnippet/CPP/codearraycreateexpressionsnippet.cpp b/snippets/cpp/VS_Snippets_CLR/CodeArrayCreateExpressionSnippet/CPP/codearraycreateexpressionsnippet.cpp deleted file mode 100644 index ba586aa0cf3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeArrayCreateExpressionSnippet/CPP/codearraycreateexpressionsnippet.cpp +++ /dev/null @@ -1,289 +0,0 @@ -// -#using -#using -#using -#using -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; -using namespace System::Drawing; -using namespace System::Collections; -using namespace System::ComponentModel; -using namespace System::Windows::Forms; -using namespace System::Data; -using namespace System::IO; -using namespace Microsoft::CSharp; -using namespace Microsoft::VisualBasic; -using namespace Microsoft::JScript; - -/// -/// Provides a wrapper for CodeDOM samples. -/// -public ref class Form1: public System::Windows::Forms::Form -{ -private: - System::CodeDom::CodeCompileUnit^ cu; - System::Windows::Forms::TextBox^ textBox1; - System::Windows::Forms::Button^ button1; - System::Windows::Forms::Button^ button2; - System::Windows::Forms::GroupBox^ groupBox1; - System::Windows::Forms::RadioButton^ radioButton1; - System::Windows::Forms::RadioButton^ radioButton2; - System::Windows::Forms::RadioButton^ radioButton3; - int language; - System::ComponentModel::Container^ components; - -public: - Form1() - { - language = 1; // 1 = Csharp 2 = VB 3 = JScript - components = nullptr; - InitializeComponent(); - cu = CreateGraph(); - } - - // -public: - CodeCompileUnit^ CreateGraph() - { - // Create a compile unit to contain a CodeDOM graph - CodeCompileUnit^ cu = gcnew CodeCompileUnit; - - // Create a namespace named "TestSpace" - CodeNamespace^ cn = gcnew CodeNamespace( "TestSpace" ); - - // Create a new type named "TestClass" - CodeTypeDeclaration^ cd = gcnew CodeTypeDeclaration( "TestClass" ); - - // Create a new entry point method - CodeEntryPointMethod^ cm = gcnew CodeEntryPointMethod; - - // - // Create an initialization expression for a new array of type Int32 with 10 indices - CodeArrayCreateExpression^ ca1 = gcnew CodeArrayCreateExpression( "System.Int32",10 ); - - // Declare an array of type Int32, using the CodeArrayCreateExpression ca1 as the initialization expression - CodeVariableDeclarationStatement^ cv1 = gcnew CodeVariableDeclarationStatement( "System.Int32[]","x",ca1 ); - - // A C# code generator produces the following source code for the preceeding example code: - // int[] x = new int[10]; - // - - // Add the variable declaration and initialization statement to the entry point method - cm->Statements->Add( cv1 ); - - // Add the entry point method to the "TestClass" type - cd->Members->Add( cm ); - - // Add the "TestClass" type to the namespace - cn->Types->Add( cd ); - - // Add the "TestSpace" namespace to the compile unit - cu->Namespaces->Add( cn ); - return cu; - } - // - -private: - void OutputGraph() - { - // Create string writer to output to textbox - StringWriter^ sw = gcnew StringWriter; - - // Create appropriate CodeProvider - System::CodeDom::Compiler::CodeDomProvider^ cp; - switch ( language ) - { - case 2: - // VB - cp = CodeDomProvider::CreateProvider("VisualBasic"); - break; - - case 3: - // JScript - cp = CodeDomProvider::CreateProvider("JScript"); - break; - - default: - // CSharp - cp = CodeDomProvider::CreateProvider("CSharp"); - break; - } - - // Create a code generator that will output to the string writer - ICodeGenerator^ cg = cp->CreateGenerator( sw ); - - // Generate code from the compile unit and outputs it to the string writer - cg->GenerateCodeFromCompileUnit( cu, sw, gcnew CodeGeneratorOptions ); - - // Output the contents of the string writer to the textbox - this->textBox1->Text = sw->ToString(); - } - -public: - ~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() - { - this->textBox1 = gcnew System::Windows::Forms::TextBox; - this->button1 = gcnew System::Windows::Forms::Button; - this->button2 = gcnew System::Windows::Forms::Button; - this->groupBox1 = gcnew System::Windows::Forms::GroupBox; - this->radioButton1 = gcnew System::Windows::Forms::RadioButton; - this->radioButton2 = gcnew System::Windows::Forms::RadioButton; - this->radioButton3 = gcnew System::Windows::Forms::RadioButton; - this->groupBox1->SuspendLayout(); - this->SuspendLayout(); - - // - // textBox1 - // - this->textBox1->Location = System::Drawing::Point( 16, 112 ); - this->textBox1->Multiline = true; - this->textBox1->Name = "textBox1"; - this->textBox1->ScrollBars = System::Windows::Forms::ScrollBars::Both; - this->textBox1->Size = System::Drawing::Size( 664, 248 ); - this->textBox1->TabIndex = 0; - this->textBox1->Text = ""; - this->textBox1->WordWrap = false; - - // - // button1 - // - this->button1->BackColor = System::Drawing::Color::Aquamarine; - this->button1->Location = System::Drawing::Point( 16, 16 ); - this->button1->Name = "button1"; - this->button1->TabIndex = 1; - this->button1->Text = "Generate"; - this->button1->Click += gcnew System::EventHandler( this, &Form1::button1_Click ); - - // - // button2 - // - this->button2->BackColor = System::Drawing::Color::MediumTurquoise; - this->button2->Location = System::Drawing::Point( 112, 16 ); - this->button2->Name = "button2"; - this->button2->TabIndex = 2; - this->button2->Text = "Show Code"; - this->button2->Click += gcnew System::EventHandler( this, &Form1::button2_Click ); - - // - // groupBox1 - // - array^temp0 = {this->radioButton3,this->radioButton2,this->radioButton1}; - this->groupBox1->Controls->AddRange( temp0 ); - this->groupBox1->Location = System::Drawing::Point( 16, 48 ); - this->groupBox1->Name = "groupBox1"; - this->groupBox1->Size = System::Drawing::Size( 384, 56 ); - this->groupBox1->TabIndex = 3; - this->groupBox1->TabStop = false; - this->groupBox1->Text = "Language selection"; - - // - // radioButton1 - // - this->radioButton1->Checked = true; - this->radioButton1->Location = System::Drawing::Point( 16, 24 ); - this->radioButton1->Name = "radioButton1"; - this->radioButton1->TabIndex = 0; - this->radioButton1->TabStop = true; - this->radioButton1->Text = "CSharp"; - this->radioButton1->Click += gcnew System::EventHandler( this, &Form1::radioButton1_CheckedChanged ); - - // - // radioButton2 - // - this->radioButton2->Location = System::Drawing::Point( 144, 24 ); - this->radioButton2->Name = "radioButton2"; - this->radioButton2->TabIndex = 1; - this->radioButton2->Text = "Visual Basic"; - this->radioButton2->Click += gcnew System::EventHandler( this, &Form1::radioButton2_CheckedChanged ); - - // - // radioButton3 - // - this->radioButton3->Location = System::Drawing::Point( 272, 24 ); - this->radioButton3->Name = "radioButton3"; - this->radioButton3->TabIndex = 2; - this->radioButton3->Text = "JScript"; - this->radioButton3->Click += gcnew System::EventHandler( this, &Form1::radioButton3_CheckedChanged ); - - // - // Form1 - // - this->AutoScaleBaseSize = System::Drawing::Size( 5, 13 ); - this->ClientSize = System::Drawing::Size( 714, 367 ); - array^temp1 = {this->groupBox1,this->button2,this->button1,this->textBox1}; - this->Controls->AddRange( temp1 ); - this->Name = "Form1"; - this->Text = "CodeDOM Samples Framework"; - this->groupBox1->ResumeLayout( false ); - this->ResumeLayout( false ); - } - - void ShowCode() - { - this->textBox1->Text = ""; - } - - // Show code button - void button2_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ ) - { - ShowCode(); - } - - // Generate and show code button - void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ ) - { - OutputGraph(); - } - - // Csharp language selection button - void radioButton1_CheckedChanged( Object^ /*sender*/, System::EventArgs^ /*e*/ ) - { - radioButton1->Checked = true; - radioButton2->Checked = false; - radioButton3->Checked = false; - language = 1; - } - - // Visual Basic language selection button - void radioButton2_CheckedChanged( Object^ /*sender*/, System::EventArgs^ /*e*/ ) - { - radioButton1->Checked = false; - radioButton2->Checked = true; - radioButton3->Checked = false; - language = 2; - } - - // JScript language selection button - void radioButton3_CheckedChanged( Object^ /*sender*/, System::EventArgs^ /*e*/ ) - { - radioButton1->Checked = false; - radioButton2->Checked = false; - radioButton3->Checked = true; - language = 3; - } - -}; - -[STAThread] -int main() -{ - Application::Run( gcnew Form1 ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeArrayIndexerExpressionSnippet/CPP/codearrayindexerexpressionsnippet.cpp b/snippets/cpp/VS_Snippets_CLR/CodeArrayIndexerExpressionSnippet/CPP/codearrayindexerexpressionsnippet.cpp deleted file mode 100644 index e565079d0a3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeArrayIndexerExpressionSnippet/CPP/codearrayindexerexpressionsnippet.cpp +++ /dev/null @@ -1,301 +0,0 @@ -// -#using -#using -#using -#using -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; -using namespace System::Drawing; -using namespace System::Collections; -using namespace System::ComponentModel; -using namespace System::Windows::Forms; -using namespace System::Data; -using namespace System::IO; -using namespace Microsoft::CSharp; -using namespace Microsoft::VisualBasic; -using namespace Microsoft::JScript; - -/// -/// Provides a wrapper for CodeDOM samples. -/// -public ref class Form1: public System::Windows::Forms::Form -{ -private: - System::CodeDom::CodeCompileUnit^ cu; - System::Windows::Forms::TextBox^ textBox1; - System::Windows::Forms::Button^ button1; - System::Windows::Forms::Button^ button2; - System::Windows::Forms::GroupBox^ groupBox1; - System::Windows::Forms::RadioButton^ radioButton1; - System::Windows::Forms::RadioButton^ radioButton2; - System::Windows::Forms::RadioButton^ radioButton3; - int language; - System::ComponentModel::Container^ components; - -public: - Form1() - { - language = 1; // 1 = Csharp 2 = VB 3 = JScript - components = nullptr; - InitializeComponent(); - cu = CreateGraph(); - } - - // -public: - CodeCompileUnit^ CreateGraph() - { - // Create a compile unit to contain a CodeDOM graph - CodeCompileUnit^ cu = gcnew CodeCompileUnit; - - // Create a namespace named "TestSpace" - CodeNamespace^ cn = gcnew CodeNamespace( "TestSpace" ); - - // Create a new type named "TestClass" - CodeTypeDeclaration^ cd = gcnew CodeTypeDeclaration( "TestClass" ); - - // Create an entry point method - CodeEntryPointMethod^ cm = gcnew CodeEntryPointMethod; - - // Create the initialization expression for an array of type Int32 with 10 indices - CodeArrayCreateExpression^ ca1 = gcnew CodeArrayCreateExpression( "System.Int32",10 ); - - // Declare an array of type Int32, using the CodeArrayCreateExpression ca1 as the initialization expression - CodeVariableDeclarationStatement^ cv1 = gcnew CodeVariableDeclarationStatement( "System.Int32[]","x",ca1 ); - - // Add the array declaration and initialization statement to the entry point method class member - cm->Statements->Add( cv1 ); - // - - // Create an array indexer expression that references index 5 of array "x" - array^temp = {gcnew CodePrimitiveExpression( 5 )}; - CodeArrayIndexerExpression^ ci1 = gcnew CodeArrayIndexerExpression( gcnew CodeVariableReferenceExpression( "x" ),temp ); - - // A C# code generator produces the following source code for the preceeding example code: - // x[5] - // - // Declare a variable of type Int32 and adds it to the entry point method - CodeVariableDeclarationStatement^ cv2 = gcnew CodeVariableDeclarationStatement( "System.Int32","y" ); - cm->Statements->Add( cv2 ); - - // Assign the value of the array indexer ci1 to variable "y" - CodeAssignStatement^ as1 = gcnew CodeAssignStatement( gcnew CodeVariableReferenceExpression( "y" ),ci1 ); - - // Add the assignment statement to the entry point method - cm->Statements->Add( as1 ); - - // Add the entry point method to the "TestClass" type - cd->Members->Add( cm ); - - // Add the "TestClass" type to the namespace - cn->Types->Add( cd ); - - // Add the "TestSpace" namespace to the compile unit - cu->Namespaces->Add( cn ); - return cu; - } - // - -private: - void OutputGraph() - { - // Create string writer to output to textbox - StringWriter^ sw = gcnew StringWriter; - - // Create appropriate CodeProvider - System::CodeDom::Compiler::CodeDomProvider^ cp; - switch ( language ) - { - case 2: - // VB - cp = CodeDomProvider::CreateProvider("VisualBasic"); - break; - - case 3: - // JScript - cp = CodeDomProvider::CreateProvider("JScript"); - break; - - default: - // CSharp - cp = CodeDomProvider::CreateProvider("CSharp"); - break; - } - - // Create a code generator that will output to the string writer - ICodeGenerator^ cg = cp->CreateGenerator( sw ); - - // Generate code from the compile unit and outputs it to the string writer - cg->GenerateCodeFromCompileUnit( cu, sw, gcnew CodeGeneratorOptions ); - - // Output the contents of the string writer to the textbox - this->textBox1->Text = sw->ToString(); - } - -public: - ~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() - { - this->textBox1 = gcnew System::Windows::Forms::TextBox; - this->button1 = gcnew System::Windows::Forms::Button; - this->button2 = gcnew System::Windows::Forms::Button; - this->groupBox1 = gcnew System::Windows::Forms::GroupBox; - this->radioButton1 = gcnew System::Windows::Forms::RadioButton; - this->radioButton2 = gcnew System::Windows::Forms::RadioButton; - this->radioButton3 = gcnew System::Windows::Forms::RadioButton; - this->groupBox1->SuspendLayout(); - this->SuspendLayout(); - - // - // textBox1 - // - this->textBox1->Location = System::Drawing::Point( 16, 112 ); - this->textBox1->Multiline = true; - this->textBox1->Name = "textBox1"; - this->textBox1->ScrollBars = System::Windows::Forms::ScrollBars::Both; - this->textBox1->Size = System::Drawing::Size( 664, 248 ); - this->textBox1->TabIndex = 0; - this->textBox1->Text = ""; - this->textBox1->WordWrap = false; - - // - // button1 - // - this->button1->BackColor = System::Drawing::Color::Aquamarine; - this->button1->Location = System::Drawing::Point( 16, 16 ); - this->button1->Name = "button1"; - this->button1->TabIndex = 1; - this->button1->Text = "Generate"; - this->button1->Click += gcnew System::EventHandler( this, &Form1::button1_Click ); - - // - // button2 - // - this->button2->BackColor = System::Drawing::Color::MediumTurquoise; - this->button2->Location = System::Drawing::Point( 112, 16 ); - this->button2->Name = "button2"; - this->button2->TabIndex = 2; - this->button2->Text = "Show Code"; - this->button2->Click += gcnew System::EventHandler( this, &Form1::button2_Click ); - - // - // groupBox1 - // - array^temp2 = {this->radioButton3,this->radioButton2,this->radioButton1}; - this->groupBox1->Controls->AddRange( temp2 ); - this->groupBox1->Location = System::Drawing::Point( 16, 48 ); - this->groupBox1->Name = "groupBox1"; - this->groupBox1->Size = System::Drawing::Size( 384, 56 ); - this->groupBox1->TabIndex = 3; - this->groupBox1->TabStop = false; - this->groupBox1->Text = "Language selection"; - - // - // radioButton1 - // - this->radioButton1->Checked = true; - this->radioButton1->Location = System::Drawing::Point( 16, 24 ); - this->radioButton1->Name = "radioButton1"; - this->radioButton1->TabIndex = 0; - this->radioButton1->TabStop = true; - this->radioButton1->Text = "CSharp"; - this->radioButton1->Click += gcnew System::EventHandler( this, &Form1::radioButton1_CheckedChanged ); - - // - // radioButton2 - // - this->radioButton2->Location = System::Drawing::Point( 144, 24 ); - this->radioButton2->Name = "radioButton2"; - this->radioButton2->TabIndex = 1; - this->radioButton2->Text = "Visual Basic"; - this->radioButton2->Click += gcnew System::EventHandler( this, &Form1::radioButton2_CheckedChanged ); - - // - // radioButton3 - // - this->radioButton3->Location = System::Drawing::Point( 272, 24 ); - this->radioButton3->Name = "radioButton3"; - this->radioButton3->TabIndex = 2; - this->radioButton3->Text = "JScript"; - this->radioButton3->Click += gcnew System::EventHandler( this, &Form1::radioButton3_CheckedChanged ); - - // - // Form1 - // - this->AutoScaleBaseSize = System::Drawing::Size( 5, 13 ); - this->ClientSize = System::Drawing::Size( 714, 367 ); - array^temp3 = {this->groupBox1,this->button2,this->button1,this->textBox1}; - this->Controls->AddRange( temp3 ); - this->Name = "Form1"; - this->Text = "CodeDOM Samples Framework"; - this->groupBox1->ResumeLayout( false ); - this->ResumeLayout( false ); - } - - void ShowCode() - { - this->textBox1->Text = ""; - } - - // Show code button - void button2_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ ) - { - ShowCode(); - } - - // Generate and show code button - void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ ) - { - OutputGraph(); - } - - // Csharp language selection button - void radioButton1_CheckedChanged( Object^ /*sender*/, System::EventArgs^ /*e*/ ) - { - radioButton1->Checked = true; - radioButton2->Checked = false; - radioButton3->Checked = false; - language = 1; - } - - // Visual Basic language selection button - void radioButton2_CheckedChanged( Object^ /*sender*/, System::EventArgs^ /*e*/ ) - { - radioButton1->Checked = false; - radioButton2->Checked = true; - radioButton3->Checked = false; - language = 2; - } - - // JScript language selection button - void radioButton3_CheckedChanged( Object^ /*sender*/, System::EventArgs^ /*e*/ ) - { - radioButton1->Checked = false; - radioButton2->Checked = false; - radioButton3->Checked = true; - language = 3; - } -}; - -[STAThread] -int main() -{ - Application::Run( gcnew Form1 ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeAssignStatement/CPP/codeassignstatementsnippet.cpp b/snippets/cpp/VS_Snippets_CLR/CodeAssignStatement/CPP/codeassignstatementsnippet.cpp deleted file mode 100644 index a94dc0b0c36..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeAssignStatement/CPP/codeassignstatementsnippet.cpp +++ /dev/null @@ -1,289 +0,0 @@ -// -#using -#using -#using -#using -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; -using namespace System::Drawing; -using namespace System::Collections; -using namespace System::ComponentModel; -using namespace System::Windows::Forms; -using namespace System::Data; -using namespace System::IO; -using namespace Microsoft::CSharp; -using namespace Microsoft::VisualBasic; -using namespace Microsoft::JScript; - -/// -/// Provides a wrapper for CodeDOM samples. -/// -public ref class Form1: public System::Windows::Forms::Form -{ -private: - System::CodeDom::CodeCompileUnit^ cu; - System::Windows::Forms::TextBox^ textBox1; - System::Windows::Forms::Button^ button1; - System::Windows::Forms::Button^ button2; - System::Windows::Forms::GroupBox^ groupBox1; - System::Windows::Forms::RadioButton^ radioButton1; - System::Windows::Forms::RadioButton^ radioButton2; - System::Windows::Forms::RadioButton^ radioButton3; - int language; - System::ComponentModel::Container^ components; - -public: - Form1() - { - language = 1; // 1 = Csharp 2 = VB 3 = JScript - components = nullptr; - InitializeComponent(); - cu = CreateGraph(); - } - - // - CodeCompileUnit^ CreateGraph() - { - // Create a compile unit to contain a CodeDOM graph - CodeCompileUnit^ cu = gcnew CodeCompileUnit; - - // Create a namespace named "TestSpace" - CodeNamespace^ cn = gcnew CodeNamespace( "TestSpace" ); - - // Create a new type named "TestClass" - CodeTypeDeclaration^ cd = gcnew CodeTypeDeclaration( "TestClass" ); - - // Create a new entry point method - CodeEntryPointMethod^ cm = gcnew CodeEntryPointMethod; - - // Declare a variable of type Int32 named "i" - CodeVariableDeclarationStatement^ cv1 = gcnew CodeVariableDeclarationStatement( "System.Int32","i" ); - - // Add the variable declaration statement to the entry point method - cm->Statements->Add( cv1 ); - - // - // Assigns the value of the 10 to the integer variable "i". - CodeAssignStatement^ as1 = gcnew CodeAssignStatement( gcnew CodeVariableReferenceExpression( "i" ),gcnew CodePrimitiveExpression( 10 ) ); - - // A C# code generator produces the following source code for the preceeding example code: - // i=10; - // - // Add the assignment statement to the entry point method - cm->Statements->Add( as1 ); - - // Add the entry point method to the "TestClass" type - cd->Members->Add( cm ); - - // Add the "TestClass" type to the namespace - cn->Types->Add( cd ); - - // Add the "TestSpace" namespace to the compile unit - cu->Namespaces->Add( cn ); - return cu; - } - // - -private: - void OutputGraph() - { - // Create string writer to output to textbox - StringWriter^ sw = gcnew StringWriter; - - // Create appropriate CodeProvider - System::CodeDom::Compiler::CodeDomProvider^ cp; - switch ( language ) - { - case 2: - // VB - cp = CodeDomProvider::CreateProvider("VisualBasic"); - break; - - case 3: - // JScript - cp = CodeDomProvider::CreateProvider("JScript"); - break; - - default: - // CSharp - cp = CodeDomProvider::CreateProvider("CSharp"); - break; - } - - // Create a code generator that will output to the string writer - ICodeGenerator^ cg = cp->CreateGenerator( sw ); - - // Generate code from the compile unit and outputs it to the string writer - cg->GenerateCodeFromCompileUnit( cu, sw, gcnew CodeGeneratorOptions ); - - // Output the contents of the string writer to the textbox - this->textBox1->Text = sw->ToString(); - } - -public: - ~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() - { - this->textBox1 = gcnew System::Windows::Forms::TextBox; - this->button1 = gcnew System::Windows::Forms::Button; - this->button2 = gcnew System::Windows::Forms::Button; - this->groupBox1 = gcnew System::Windows::Forms::GroupBox; - this->radioButton1 = gcnew System::Windows::Forms::RadioButton; - this->radioButton2 = gcnew System::Windows::Forms::RadioButton; - this->radioButton3 = gcnew System::Windows::Forms::RadioButton; - this->groupBox1->SuspendLayout(); - this->SuspendLayout(); - - // - // textBox1 - // - this->textBox1->Location = System::Drawing::Point( 16, 112 ); - this->textBox1->Multiline = true; - this->textBox1->Name = "textBox1"; - this->textBox1->ScrollBars = System::Windows::Forms::ScrollBars::Both; - this->textBox1->Size = System::Drawing::Size( 664, 248 ); - this->textBox1->TabIndex = 0; - this->textBox1->Text = ""; - this->textBox1->WordWrap = false; - - // - // button1 - // - this->button1->BackColor = System::Drawing::Color::Aquamarine; - this->button1->Location = System::Drawing::Point( 16, 16 ); - this->button1->Name = "button1"; - this->button1->TabIndex = 1; - this->button1->Text = "Generate"; - this->button1->Click += gcnew System::EventHandler( this, &Form1::button1_Click ); - - // - // button2 - // - this->button2->BackColor = System::Drawing::Color::MediumTurquoise; - this->button2->Location = System::Drawing::Point( 112, 16 ); - this->button2->Name = "button2"; - this->button2->TabIndex = 2; - this->button2->Text = "Show Code"; - this->button2->Click += gcnew System::EventHandler( this, &Form1::button2_Click ); - - // - // groupBox1 - // - array^temp0 = {this->radioButton3,this->radioButton2,this->radioButton1}; - this->groupBox1->Controls->AddRange( temp0 ); - this->groupBox1->Location = System::Drawing::Point( 16, 48 ); - this->groupBox1->Name = "groupBox1"; - this->groupBox1->Size = System::Drawing::Size( 384, 56 ); - this->groupBox1->TabIndex = 3; - this->groupBox1->TabStop = false; - this->groupBox1->Text = "Language selection"; - - // - // radioButton1 - // - this->radioButton1->Checked = true; - this->radioButton1->Location = System::Drawing::Point( 16, 24 ); - this->radioButton1->Name = "radioButton1"; - this->radioButton1->TabIndex = 0; - this->radioButton1->TabStop = true; - this->radioButton1->Text = "CSharp"; - this->radioButton1->Click += gcnew System::EventHandler( this, &Form1::radioButton1_CheckedChanged ); - - // - // radioButton2 - // - this->radioButton2->Location = System::Drawing::Point( 144, 24 ); - this->radioButton2->Name = "radioButton2"; - this->radioButton2->TabIndex = 1; - this->radioButton2->Text = "Visual Basic"; - this->radioButton2->Click += gcnew System::EventHandler( this, &Form1::radioButton2_CheckedChanged ); - - // - // radioButton3 - // - this->radioButton3->Location = System::Drawing::Point( 272, 24 ); - this->radioButton3->Name = "radioButton3"; - this->radioButton3->TabIndex = 2; - this->radioButton3->Text = "JScript"; - this->radioButton3->Click += gcnew System::EventHandler( this, &Form1::radioButton3_CheckedChanged ); - - // - // Form1 - // - this->AutoScaleBaseSize = System::Drawing::Size( 5, 13 ); - this->ClientSize = System::Drawing::Size( 714, 367 ); - array^temp1 = {this->groupBox1,this->button2,this->button1,this->textBox1}; - this->Controls->AddRange( temp1 ); - this->Name = "Form1"; - this->Text = "CodeDOM Samples Framework"; - this->groupBox1->ResumeLayout( false ); - this->ResumeLayout( false ); - } - - void ShowCode() - { - this->textBox1->Text = ""; - } - - // Show code button - void button2_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ ) - { - ShowCode(); - } - - // Generate and show code button - void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ ) - { - OutputGraph(); - } - - // Csharp language selection button - void radioButton1_CheckedChanged( Object^ /*sender*/, System::EventArgs^ /*e*/ ) - { - radioButton1->Checked = true; - radioButton2->Checked = false; - radioButton3->Checked = false; - language = 1; - } - - // Visual Basic language selection button - void radioButton2_CheckedChanged( Object^ /*sender*/, System::EventArgs^ /*e*/ ) - { - radioButton1->Checked = false; - radioButton2->Checked = true; - radioButton3->Checked = false; - language = 2; - } - - // JScript language selection button - void radioButton3_CheckedChanged( Object^ /*sender*/, System::EventArgs^ /*e*/ ) - { - radioButton1->Checked = false; - radioButton2->Checked = false; - radioButton3->Checked = true; - language = 3; - } -}; - -[STAThread] -int main() -{ - Application::Run( gcnew Form1 ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeAttachEventStatementExample/CPP/codeattacheventstatementexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeAttachEventStatementExample/CPP/codeattacheventstatementexample.cpp deleted file mode 100644 index bf0e69c601b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeAttachEventStatementExample/CPP/codeattacheventstatementexample.cpp +++ /dev/null @@ -1,81 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSamples -{ - public ref class CodeAttachEventStatementExample - { - public: - CodeAttachEventStatementExample() - { - - // - // Declares a type to contain the delegate and constructor method. - CodeTypeDeclaration^ type1 = gcnew CodeTypeDeclaration( "AttachEventTest" ); - - // Declares an event that needs no custom event arguments class. - CodeMemberEvent^ event1 = gcnew CodeMemberEvent; - event1->Name = "TestEvent"; - event1->Type = gcnew CodeTypeReference( "System.EventHandler" ); - - // Adds the event to the type members. - type1->Members->Add( event1 ); - - // Declares a method that matches the System.EventHandler method signature. - CodeMemberMethod^ method1 = gcnew CodeMemberMethod; - method1->Name = "TestMethod"; - method1->Parameters->Add( gcnew CodeParameterDeclarationExpression( "System.Object","sender" ) ); - method1->Parameters->Add( gcnew CodeParameterDeclarationExpression( "System.EventArgs","e" ) ); - - // Adds the method to the type members. - type1->Members->Add( method1 ); - - // Defines a constructor that attaches a TestDelegate delegate pointing to - // the TestMethod method to the TestEvent event. - CodeConstructor^ constructor1 = gcnew CodeConstructor; - constructor1->Attributes = MemberAttributes::Public; - - // - // Defines a delegate creation expression that creates an EventHandler delegate pointing to a method named TestMethod. - CodeDelegateCreateExpression^ createDelegate1 = gcnew CodeDelegateCreateExpression( gcnew CodeTypeReference( "System.EventHandler" ),gcnew CodeThisReferenceExpression,"TestMethod" ); - - // Attaches an EventHandler delegate pointing to TestMethod to the TestEvent event. - CodeAttachEventStatement^ attachStatement1 = gcnew CodeAttachEventStatement( gcnew CodeThisReferenceExpression,"TestEvent",createDelegate1 ); - - // A C# code generator produces the following source code for the preceeding example code: - // this.TestEvent += new System.EventHandler(this.TestMethod); - // - // Adds the constructor statements to the construtor. - constructor1->Statements->Add( attachStatement1 ); - - // Adds the construtor to the type members. - type1->Members->Add( constructor1 ); - - // A C# code generator produces the following source code for the preceeding example code: - // public class AttachEventTest - // { - // - // public AttachEventTest() - // { - // this.TestEvent += new System.EventHandler(this.TestMethod); - // } - // - // private event System.EventHandler TestEvent; - // - // private void TestMethod(object sender, System.EventArgs e) - // { - // } - // } - // - } - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/CPP/class1.cpp deleted file mode 100644 index 0e04788981c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/CPP/class1.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; - -namespace CodeAttributeArgumentCollectionExample -{ - public ref class Class1 - { - public: - Class1(){} - - - // CodeAttributeArgumentCollection - void CodeAttributeArgumentCollectionExample() - { - - // - // - // Creates an empty CodeAttributeArgumentCollection. - CodeAttributeArgumentCollection^ collection = gcnew CodeAttributeArgumentCollection; - // - - // - // Adds a CodeAttributeArgument to the collection. - collection->Add( gcnew CodeAttributeArgument( "Test Boolean Argument",gcnew CodePrimitiveExpression( true ) ) ); - // - - // - // Adds an array of CodeAttributeArgument objects to the collection. - array^arguments = {gcnew CodeAttributeArgument,gcnew CodeAttributeArgument}; - collection->AddRange( arguments ); - - // Adds a collection of CodeAttributeArgument objects to - // the collection. - CodeAttributeArgumentCollection^ argumentsCollection = gcnew CodeAttributeArgumentCollection; - argumentsCollection->Add( gcnew CodeAttributeArgument( "TestBooleanArgument",gcnew CodePrimitiveExpression( true ) ) ); - argumentsCollection->Add( gcnew CodeAttributeArgument( "TestIntArgument",gcnew CodePrimitiveExpression( 1 ) ) ); - collection->AddRange( argumentsCollection ); - // - - // - // Tests for the presence of a CodeAttributeArgument - // within the collection, and retrieves its index if it is found. - CodeAttributeArgument^ testArgument = gcnew CodeAttributeArgument( "Test Boolean Argument",gcnew CodePrimitiveExpression( true ) ); - int itemIndex = -1; - if ( collection->Contains( testArgument ) ) - itemIndex = collection->IndexOf( testArgument ); - // - - // - // Copies the contents of the collection beginning at index 0, - // to the specified CodeAttributeArgument array. - // 'arguments' is a CodeAttributeArgument array. - collection->CopyTo( arguments, 0 ); - // - - // - // Retrieves the count of the items in the collection. - int collectionCount = collection->Count; - // - - // - // Inserts a CodeAttributeArgument at index 0 of the collection. - collection->Insert( 0, gcnew CodeAttributeArgument( "Test Boolean Argument",gcnew CodePrimitiveExpression( true ) ) ); - // - - // - // Removes the specified CodeAttributeArgument from the collection. - CodeAttributeArgument^ argument = gcnew CodeAttributeArgument( "Test Boolean Argument",gcnew CodePrimitiveExpression( true ) ); - collection->Remove( argument ); - // - - // - // Removes the CodeAttributeArgument at index 0. - collection->RemoveAt( 0 ); - // - // - } - }; -} diff --git a/snippets/cpp/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/CPP/class1.cpp deleted file mode 100644 index cfcbb80230e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/CPP/class1.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; -using namespace System::Collections; - -namespace CodeAttributeDeclarationCollectionExample -{ - public ref class Class1 - { - public: - Class1(){} - - // CodeAttributeDeclarationCollection - void CodeAttributeDeclarationCollectionExample() - { - - // - // - // Creates an empty CodeAttributeDeclarationCollection. - CodeAttributeDeclarationCollection^ collection = gcnew CodeAttributeDeclarationCollection; - // - - // - // Adds a CodeAttributeDeclaration to the collection. - array^temp = {gcnew CodeAttributeArgument( gcnew CodePrimitiveExpression( "Test Description" ) )}; - collection->Add( gcnew CodeAttributeDeclaration( "DescriptionAttribute",temp ) ); - // - - // - // Adds an array of CodeAttributeDeclaration objects - // to the collection. - array^declarations = {gcnew CodeAttributeDeclaration,gcnew CodeAttributeDeclaration}; - collection->AddRange( declarations ); - - // Adds a collection of CodeAttributeDeclaration objects - // to the collection. - CodeAttributeDeclarationCollection^ declarationsCollection = gcnew CodeAttributeDeclarationCollection; - array^temp1 = {gcnew CodeAttributeArgument( gcnew CodePrimitiveExpression( "Test Description" ) )}; - declarationsCollection->Add( gcnew CodeAttributeDeclaration( "DescriptionAttribute",temp1 ) ); - array^temp2 = {gcnew CodeAttributeArgument( gcnew CodePrimitiveExpression( true ) )}; - declarationsCollection->Add( gcnew CodeAttributeDeclaration( "BrowsableAttribute",temp2 ) ); - collection->AddRange( declarationsCollection ); - // - - // - // Tests for the presence of a CodeAttributeDeclaration in - // the collection, and retrieves its index if it is found. - array^temp3 = {gcnew CodeAttributeArgument( gcnew CodePrimitiveExpression( "Test Description" ) )}; - CodeAttributeDeclaration^ testdeclaration = gcnew CodeAttributeDeclaration( "DescriptionAttribute",temp3 ); - int itemIndex = -1; - if ( collection->Contains( testdeclaration ) ) - itemIndex = collection->IndexOf( testdeclaration ); - // - - // - // Copies the contents of the collection, beginning at index 0, - // to the specified CodeAttributeDeclaration array. - // 'declarations' is a CodeAttributeDeclaration array. - collection->CopyTo( declarations, 0 ); - // - - // - // Retrieves the count of the items in the collection. - int collectionCount = collection->Count; - // - - // - // Inserts a CodeAttributeDeclaration at index 0 of the collection. - array^temp4 = {gcnew CodeAttributeArgument( gcnew CodePrimitiveExpression( "Test Description" ) )}; - collection->Insert( 0, gcnew CodeAttributeDeclaration( "DescriptionAttribute",temp4 ) ); - // - - // - // Removes the specified CodeAttributeDeclaration from - // the collection. - array^temp5 = {gcnew CodeAttributeArgument( gcnew CodePrimitiveExpression( "Test Description" ) )}; - CodeAttributeDeclaration^ declaration = gcnew CodeAttributeDeclaration( "DescriptionAttribute",temp5 ); - collection->Remove( declaration ); - // - - // - // Removes the CodeAttributeDeclaration at index 0. - collection->RemoveAt( 0 ); - // - // - } - }; -} diff --git a/snippets/cpp/VS_Snippets_CLR/CodeBaseReferenceExpressionExample/CPP/codebasereferenceexpressionexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeBaseReferenceExpressionExample/CPP/codebasereferenceexpressionexample.cpp deleted file mode 100644 index 636d5881825..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeBaseReferenceExpressionExample/CPP/codebasereferenceexpressionexample.cpp +++ /dev/null @@ -1,29 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; -public ref class CodeBaseReferenceExpressionExample -{ -public: - CodeBaseReferenceExpressionExample() - { - - // - // Example method invoke expression uses CodeBaseReferenceExpression to produce - // a base.Dispose method call - CodeMethodInvokeExpression^ methodInvokeExpression = - gcnew CodeMethodInvokeExpression( // Creates a method invoke expression - gcnew CodeBaseReferenceExpression, // targetObjectparameter can be a base class reference - "Dispose",gcnew array{} ); // Method name and method parameter arguments - - // A C# code generator produces the following source code for the preceeding example code: - // base.Dispose(); - // - } - -}; - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeBinaryOperatorExpression/CPP/codebinaryoperatorexpressionexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeBinaryOperatorExpression/CPP/codebinaryoperatorexpressionexample.cpp deleted file mode 100644 index 5acadb676c2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeBinaryOperatorExpression/CPP/codebinaryoperatorexpressionexample.cpp +++ /dev/null @@ -1,32 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSamples -{ - public ref class CodeBinaryOperatorExpressionExample - { - public: - CodeBinaryOperatorExpressionExample() - { - - // - // This CodeBinaryOperatorExpression represents the addition of 1 and 2. - - // Right operand. - CodeBinaryOperatorExpression^ addMethod = gcnew CodeBinaryOperatorExpression( gcnew CodePrimitiveExpression( 1 ),CodeBinaryOperatorType::Add,gcnew CodePrimitiveExpression( 2 ) ); - - // A C# code generator produces the following source code for the preceeding example code: - // (1 + 2) - // - } - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeCastExpressionExample/CPP/codecastexpressionexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeCastExpressionExample/CPP/codecastexpressionexample.cpp deleted file mode 100644 index 6bcd05541f1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeCastExpressionExample/CPP/codecastexpressionexample.cpp +++ /dev/null @@ -1,33 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSamples -{ - public ref class CodeCastExpressionExample - { - public: - CodeCastExpressionExample() - { - - // - // This CodeCastExpression casts an Int32 of 1000 to an Int64. - - // targetType parameter indicating the target type of the cast. - // The CodeExpression to cast, here an Int32 value of 1000. - CodeCastExpression^ castExpression = gcnew CodeCastExpression( "System.Int64",gcnew CodePrimitiveExpression( 1000 ) ); - - // A C# code generator produces the following source code for the preceeding example code: - // ((long)(1000)); - // - } - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeCatchClauseCollectionExample/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/CodeCatchClauseCollectionExample/CPP/class1.cpp deleted file mode 100644 index b1f1d3cb90e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeCatchClauseCollectionExample/CPP/class1.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; - -namespace CodeCatchClauseCollectionExample -{ - public ref class Class1 - { - public: - Class1(){} - - // CodeCatchClauseCollection - void CodeCatchClauseCollectionExample() - { - // - // - // Creates an empty CodeCatchClauseCollection. - CodeCatchClauseCollection^ collection = gcnew CodeCatchClauseCollection; - // - - // - // Adds a CodeCatchClause to the collection. - collection->Add( gcnew CodeCatchClause( "e" ) ); - // - - // - // Adds an array of CodeCatchClause objects to the collection. - array^clauses = {gcnew CodeCatchClause,gcnew CodeCatchClause}; - collection->AddRange( clauses ); - - // Adds a collection of CodeCatchClause objects to the collection. - CodeCatchClauseCollection^ clausesCollection = gcnew CodeCatchClauseCollection; - clausesCollection->Add( gcnew CodeCatchClause( "e",gcnew CodeTypeReference( System::ArgumentOutOfRangeException::typeid ) ) ); - clausesCollection->Add( gcnew CodeCatchClause( "e" ) ); - collection->AddRange( clausesCollection ); - // - - // - // Tests for the presence of a CodeCatchClause in the - // collection, and retrieves its index if it is found. - CodeCatchClause^ testClause = gcnew CodeCatchClause( "e" ); - int itemIndex = -1; - if ( collection->Contains( testClause ) ) - itemIndex = collection->IndexOf( testClause ); - // - - // - // Copies the contents of the collection beginning at index 0 to the specified CodeCatchClause array. - // 'clauses' is a CodeCatchClause array. - collection->CopyTo( clauses, 0 ); - // - - // - // Retrieves the count of the items in the collection. - int collectionCount = collection->Count; - // - - // - // Inserts a CodeCatchClause at index 0 of the collection. - collection->Insert( 0, gcnew CodeCatchClause( "e" ) ); - // - - // - // Removes the specified CodeCatchClause from the collection. - CodeCatchClause^ clause = gcnew CodeCatchClause( "e" ); - collection->Remove( clause ); - // - - // - // Removes the CodeCatchClause at index 0. - collection->RemoveAt( 0 ); - // - // - } - }; -} diff --git a/snippets/cpp/VS_Snippets_CLR/CodeCommentExample/CPP/codecommentexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeCommentExample/CPP/codecommentexample.cpp deleted file mode 100644 index f4f7099d6a3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeCommentExample/CPP/codecommentexample.cpp +++ /dev/null @@ -1,37 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSamples -{ - public ref class CodeCommentExample - { - public: - CodeCommentExample() - { - - // - // Create a CodeComment with some example comment text. - - // The text of the comment. - // Whether the comment is a comment intended for documentation purposes. - CodeComment^ comment = gcnew CodeComment( "This comment was generated from a System.CodeDom.CodeComment",false ); - - // Create a CodeCommentStatement that contains the comment, in order - // to add the comment to a CodeTypeDeclaration Members collection. - CodeCommentStatement^ commentStatement = gcnew CodeCommentStatement( comment ); - - // A C# code generator produces the following source code for the preceeding example code: - // // This comment was generated from a System.CodeDom.CodeComment - // - } - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeCommentStatementCollectionExample/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/CodeCommentStatementCollectionExample/CPP/class1.cpp deleted file mode 100644 index c779ba5e491..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeCommentStatementCollectionExample/CPP/class1.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; - -namespace CodeCommentStatementCollectionExample -{ - public ref class Class1 - { - public: - Class1(){} - - // CodeCommentStatementCollection - void CodeCommentStatementCollectionExample() - { - - // - // - // Creates an empty CodeCommentStatementCollection. - CodeCommentStatementCollection^ collection = gcnew CodeCommentStatementCollection; - // - - // - // Adds a CodeCommentStatement to the collection. - collection->Add( gcnew CodeCommentStatement( "Test comment" ) ); - // - - // - // Adds an array of CodeCommentStatement objects to the collection. - array^comments = {gcnew CodeCommentStatement( "Test comment" ),gcnew CodeCommentStatement( "Another test comment" )}; - collection->AddRange( comments ); - - // Adds a collection of CodeCommentStatement objects to the collection. - CodeCommentStatementCollection^ commentsCollection = gcnew CodeCommentStatementCollection; - commentsCollection->Add( gcnew CodeCommentStatement( "Test comment" ) ); - commentsCollection->Add( gcnew CodeCommentStatement( "Another test comment" ) ); - collection->AddRange( commentsCollection ); - // - - // - // Tests for the presence of a CodeCommentStatement in the - // collection, and retrieves its index if it is found. - CodeCommentStatement^ testComment = gcnew CodeCommentStatement( "Test comment" ); - int itemIndex = -1; - if ( collection->Contains( testComment ) ) - itemIndex = collection->IndexOf( testComment ); - // - - // - // Copies the contents of the collection, beginning at index 0, - // to the specified CodeCommentStatement array. - // 'comments' is a CodeCommentStatement array. - collection->CopyTo( comments, 0 ); - // - - // - // Retrieves the count of the items in the collection. - int collectionCount = collection->Count; - // - - // - // Inserts a CodeCommentStatement at index 0 of the collection. - collection->Insert( 0, gcnew CodeCommentStatement( "Test comment" ) ); - // - - // - // Removes the specified CodeCommentStatement from the collection. - CodeCommentStatement^ comment = gcnew CodeCommentStatement( "Test comment" ); - collection->Remove( comment ); - // - - // - // Removes the CodeCommentStatement at index 0. - collection->RemoveAt( 0 ); - // - // - } - }; -} diff --git a/snippets/cpp/VS_Snippets_CLR/CodeConditionStatementExample/CPP/codeconditionstatementexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeConditionStatementExample/CPP/codeconditionstatementexample.cpp deleted file mode 100644 index 9209d6fd754..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeConditionStatementExample/CPP/codeconditionstatementexample.cpp +++ /dev/null @@ -1,40 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSamples -{ - public ref class CodeConditionStatementExample - { - public: - CodeConditionStatementExample() - { - - // - // Create a CodeConditionStatement that tests a boolean value named boolean. - array^temp0 = {gcnew CodeCommentStatement( "If condition is true, execute these statements." )}; - array^temp1 = {gcnew CodeCommentStatement( "Else block. If condition is false, execute these statements." )}; - - // The statements to execute if the condition evalues to false. - CodeConditionStatement^ conditionalStatement = gcnew CodeConditionStatement( gcnew CodeVariableReferenceExpression( "boolean" ),temp0,temp1 ); - - // A C# code generator produces the following source code for the preceeding example code: - // if (boolean) - // { - // // If condition is true, execute these statements. - // } - // else { - // // Else block. If condition is false, execute these statements. - // } - // - } - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeConstructorExample/CPP/codeconstructorexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeConstructorExample/CPP/codeconstructorexample.cpp deleted file mode 100644 index f222b742baf..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeConstructorExample/CPP/codeconstructorexample.cpp +++ /dev/null @@ -1,130 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::Reflection; - -namespace CodeDomSamples -{ - public ref class CodeConstructorExample - { - public: - CodeConstructorExample() - { - - // - // This example declares two types, one of which inherits from another, - // and creates a set of different styles of constructors using CodeConstructor. - // Creates a new CodeCompileUnit to contain the program graph. - CodeCompileUnit^ CompileUnit = gcnew CodeCompileUnit; - - // Declares a new namespace object and names it. - CodeNamespace^ Samples = gcnew CodeNamespace( "Samples" ); - - // Adds the namespace object to the compile unit. - CompileUnit->Namespaces->Add( Samples ); - - // Adds a new namespace import for the System namespace. - Samples->Imports->Add( gcnew CodeNamespaceImport( "System" ) ); - - // Declares a new type and names it. - CodeTypeDeclaration^ BaseType = gcnew CodeTypeDeclaration( "BaseType" ); - - // Adds the new type to the namespace object's type collection. - Samples->Types->Add( BaseType ); - - // Declares a default constructor that takes no arguments. - CodeConstructor^ defaultConstructor = gcnew CodeConstructor; - defaultConstructor->Attributes = MemberAttributes::Public; - - // Adds the constructor to the Members collection of the BaseType. - BaseType->Members->Add( defaultConstructor ); - - // Declares a constructor that takes a string argument. - CodeConstructor^ stringConstructor = gcnew CodeConstructor; - stringConstructor->Attributes = MemberAttributes::Public; - - // Declares a parameter of type string named "TestStringParameter". - stringConstructor->Parameters->Add( gcnew CodeParameterDeclarationExpression( "System.String","TestStringParameter" ) ); - - // Adds the constructor to the Members collection of the BaseType. - BaseType->Members->Add( stringConstructor ); - - // Declares a type that derives from BaseType and names it. - CodeTypeDeclaration^ DerivedType = gcnew CodeTypeDeclaration( "DerivedType" ); - - // The DerivedType class inherits from the BaseType class. - DerivedType->BaseTypes->Add( gcnew CodeTypeReference( "BaseType" ) ); - - // Adds the new type to the namespace object's type collection. - Samples->Types->Add( DerivedType ); - - // Declare a constructor that takes a string argument and calls the base class constructor with it. - CodeConstructor^ baseStringConstructor = gcnew CodeConstructor; - baseStringConstructor->Attributes = MemberAttributes::Public; - - // Declares a parameter of type string named "TestStringParameter". - baseStringConstructor->Parameters->Add( gcnew CodeParameterDeclarationExpression( "System.String","TestStringParameter" ) ); - - // Calls a base class constructor with the TestStringParameter parameter. - baseStringConstructor->BaseConstructorArgs->Add( gcnew CodeVariableReferenceExpression( "TestStringParameter" ) ); - - // Adds the constructor to the Members collection of the DerivedType. - DerivedType->Members->Add( baseStringConstructor ); - - // Declares a constructor overload that calls another constructor for the type with a predefined argument. - CodeConstructor^ overloadConstructor = gcnew CodeConstructor; - overloadConstructor->Attributes = MemberAttributes::Public; - - // Sets the argument to pass to a base constructor method. - overloadConstructor->ChainedConstructorArgs->Add( gcnew CodePrimitiveExpression( "Test" ) ); - - // Adds the constructor to the Members collection of the DerivedType. - DerivedType->Members->Add( overloadConstructor ); - - // Declares a constructor overload that calls the default constructor for the type. - CodeConstructor^ overloadConstructor2 = gcnew CodeConstructor; - overloadConstructor2->Attributes = MemberAttributes::Public; - overloadConstructor2->Parameters->Add( gcnew CodeParameterDeclarationExpression( "System.Int32","TestIntParameter" ) ); - - // Sets the argument to pass to a base constructor method. - overloadConstructor2->ChainedConstructorArgs->Add( gcnew CodeSnippetExpression( "" ) ); - - // Adds the constructor to the Members collection of the DerivedType. - DerivedType->Members->Add( overloadConstructor2 ); - - // A C# code generator produces the following source code for the preceeding example code: - // public class BaseType { - // - // public BaseType() { - // } - // - // public BaseType(string TestStringParameter) { - // } - // } - // - // public class DerivedType : BaseType { - // - // public DerivedType(string TestStringParameter) : - // base(TestStringParameter) { - // } - // - // public DerivedType() : - // this("Test") { - // } - // - // public DerivedType(int TestIntParameter) : - // this() { - // } - // } - // - } - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeDelegateInvokeExpressionExample/CPP/codedelegateinvokeexpressionexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeDelegateInvokeExpressionExample/CPP/codedelegateinvokeexpressionexample.cpp deleted file mode 100644 index 7e7167c2f2c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeDelegateInvokeExpressionExample/CPP/codedelegateinvokeexpressionexample.cpp +++ /dev/null @@ -1,98 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSamples -{ - public ref class CodeDelegateInvokeExpressionExample - { - public: - CodeDelegateInvokeExpressionExample() - { - - // - // Declares a type to contain the delegate and constructor method. - CodeTypeDeclaration^ type1 = gcnew CodeTypeDeclaration( "DelegateInvokeTest" ); - - // Declares an event that accepts a custom delegate type of "TestDelegate". - CodeMemberEvent^ event1 = gcnew CodeMemberEvent; - event1->Name = "TestEvent"; - event1->Type = gcnew CodeTypeReference( "DelegateInvokeTest.TestDelegate" ); - type1->Members->Add( event1 ); - - // Declares a delegate type called TestDelegate with an EventArgs parameter. - CodeTypeDelegate^ delegate1 = gcnew CodeTypeDelegate( "TestDelegate" ); - delegate1->Parameters->Add( gcnew CodeParameterDeclarationExpression( "System.Object","sender" ) ); - delegate1->Parameters->Add( gcnew CodeParameterDeclarationExpression( "System.EventArgs","e" ) ); - type1->Members->Add( delegate1 ); - - // Declares a method that matches the "TestDelegate" method signature. - CodeMemberMethod^ method1 = gcnew CodeMemberMethod; - method1->Name = "TestMethod"; - method1->Parameters->Add( gcnew CodeParameterDeclarationExpression( "System.Object","sender" ) ); - method1->Parameters->Add( gcnew CodeParameterDeclarationExpression( "System.EventArgs","e" ) ); - type1->Members->Add( method1 ); - - // Defines a constructor that attaches a TestDelegate delegate pointing to the TestMethod method - // to the TestEvent event. - CodeConstructor^ constructor1 = gcnew CodeConstructor; - constructor1->Attributes = MemberAttributes::Public; - constructor1->Statements->Add( gcnew CodeCommentStatement( "Attaches a delegate to the TestEvent event." ) ); - - // Creates and attaches a delegate to the TestEvent. - CodeDelegateCreateExpression^ createDelegate1 = gcnew CodeDelegateCreateExpression( gcnew CodeTypeReference( "DelegateInvokeTest.TestDelegate" ),gcnew CodeThisReferenceExpression,"TestMethod" ); - CodeAttachEventStatement^ attachStatement1 = gcnew CodeAttachEventStatement( gcnew CodeThisReferenceExpression,"TestEvent",createDelegate1 ); - constructor1->Statements->Add( attachStatement1 ); - constructor1->Statements->Add( gcnew CodeCommentStatement( "Invokes the TestEvent event." ) ); - - // Invokes the TestEvent. - array^temp0 = {gcnew CodeThisReferenceExpression,gcnew CodeObjectCreateExpression( "System.EventArgs", nullptr )}; - CodeDelegateInvokeExpression^ invoke1 = gcnew CodeDelegateInvokeExpression( gcnew CodeEventReferenceExpression( gcnew CodeThisReferenceExpression,"TestEvent" ),temp0 ); - constructor1->Statements->Add( invoke1 ); - type1->Members->Add( constructor1 ); - - // A C# code generator produces the following source code for the preceeding example code: - // public class DelegateInvokeTest - // { - // - // public DelegateInvokeTest() - // { - // // Attaches a delegate to the TestEvent event. - // this.TestEvent += new DelegateInvokeTest.TestDelegate(this.TestMethod); - // // Invokes the TestEvent event. - // this.TestEvent(this, new System.EventArgs()); - // } - // - // private event DelegateInvokeTest.TestDelegate TestEvent; - // - // private void TestMethod(object sender, System.EventArgs e) - // { - // } - // - // public delegate void TestDelegate(object sender, System.EventArgs e); - // } - // - } - - void DelegateInvokeOnlyType() - { - - // - // Invokes the delegates for an event named TestEvent, passing a local object reference and a new System.EventArgs. - array^temp1 = {gcnew CodeThisReferenceExpression,gcnew CodeObjectCreateExpression( "System.EventArgs", nullptr )}; - CodeDelegateInvokeExpression^ invoke1 = gcnew CodeDelegateInvokeExpression( gcnew CodeEventReferenceExpression( gcnew CodeThisReferenceExpression,"TestEvent" ),temp1 ); - - // A C# code generator produces the following source code for the preceeding example code: - // this.TestEvent(this, new System.EventArgs()); - // - } - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeDomExample/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/CodeDomExample/CPP/source.cpp deleted file mode 100644 index 2f548be0a78..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeDomExample/CPP/source.cpp +++ /dev/null @@ -1,309 +0,0 @@ -/* -// CodeDOMExample_CPP.cpp : main project file. - -#include "stdafx.h" - -using namespace System; - -int main(array ^args) -{ - Console::WriteLine(L"Hello World"); - return 0; -} -*/ - -// -#using -#using -#using -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; -using namespace System::Collections; -using namespace System::ComponentModel; -using namespace System::Diagnostics; -using namespace System::Drawing; -using namespace System::IO; -using namespace System::Windows::Forms; -using namespace Microsoft::CSharp; -using namespace Microsoft::VisualBasic; -using namespace Microsoft::JScript; -using namespace System::Security::Permissions; - -// This example demonstrates building a Hello World program graph -// using System.CodeDom elements. It calls code generator and -// code compiler methods to build the program using CSharp, VB, or -// JScript. A Windows Forms interface is included. Note: Code -// must be compiled and linked with the Microsoft.JScript assembly. -namespace CodeDOMExample -{ - [PermissionSet(SecurityAction::Demand, Name="FullTrust")] - public ref class CodeDomExample - { - public: - // - // Build a Hello World program graph using - // System::CodeDom types. - static CodeCompileUnit^ BuildHelloWorldGraph() - { - // Create a new CodeCompileUnit to contain - // the program graph. - CodeCompileUnit^ compileUnit = gcnew CodeCompileUnit; - - // Declare a new namespace called Samples. - CodeNamespace^ samples = gcnew CodeNamespace( "Samples" ); - - // Add the new namespace to the compile unit. - compileUnit->Namespaces->Add( samples ); - - // Add the new namespace import for the System namespace. - samples->Imports->Add( gcnew CodeNamespaceImport( "System" ) ); - - // Declare a new type called Class1. - CodeTypeDeclaration^ class1 = gcnew CodeTypeDeclaration( "Class1" ); - - // Add the new type to the namespace's type collection. - samples->Types->Add( class1 ); - - // Declare a new code entry point method. - CodeEntryPointMethod^ start = gcnew CodeEntryPointMethod; - - // Create a type reference for the System::Console class. - CodeTypeReferenceExpression^ csSystemConsoleType = gcnew CodeTypeReferenceExpression( "System.Console" ); - - // Build a Console::WriteLine statement. - CodeMethodInvokeExpression^ cs1 = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"WriteLine", gcnew CodePrimitiveExpression("Hello World!") ); - - // Add the WriteLine call to the statement collection. - start->Statements->Add( cs1 ); - - // Build another Console::WriteLine statement. - CodeMethodInvokeExpression^ cs2 = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"WriteLine", gcnew CodePrimitiveExpression( "Press the Enter key to continue." ) ); - - // Add the WriteLine call to the statement collection. - start->Statements->Add( cs2 ); - - // Build a call to System::Console::ReadLine. - CodeMethodReferenceExpression^ csReadLine = gcnew CodeMethodReferenceExpression( csSystemConsoleType, "ReadLine" ); - CodeMethodInvokeExpression^ cs3 = gcnew CodeMethodInvokeExpression( csReadLine, gcnew array(0) ); - - // Add the ReadLine statement. - start->Statements->Add( cs3 ); - - // Add the code entry point method to - // the Members collection of the type. - class1->Members->Add( start ); - return compileUnit; - } - // - - // - static void GenerateCode( CodeDomProvider^ provider, CodeCompileUnit^ compileunit ) - { - // Build the source file name with the appropriate - // language extension. - String^ sourceFile; - if ( provider->FileExtension->StartsWith( "." ) ) - { - sourceFile = String::Concat( "TestGraph", provider->FileExtension ); - } - else - { - sourceFile = String::Concat( "TestGraph.", provider->FileExtension ); - } - - // Create an IndentedTextWriter, constructed with - // a StreamWriter to the source file. - IndentedTextWriter^ tw = gcnew IndentedTextWriter( gcnew StreamWriter( sourceFile,false )," " ); - - // Generate source code using the code generator. - provider->GenerateCodeFromCompileUnit( compileunit, tw, gcnew CodeGeneratorOptions ); - - // Close the output file. - tw->Close(); - } - // - - // - static CompilerResults^ CompileCode( CodeDomProvider^ provider, String^ sourceFile, String^ exeFile ) - { - // Configure a CompilerParameters that links System.dll - // and produces the specified executable file. - array^referenceAssemblies = {"System.dll"}; - CompilerParameters^ cp = gcnew CompilerParameters( referenceAssemblies,exeFile,false ); - - // Generate an executable rather than a DLL file. - cp->GenerateExecutable = true; - - // Invoke compilation. - CompilerResults^ cr = provider->CompileAssemblyFromFile( cp, sourceFile ); - - // Return the results of compilation. - return cr; - } - // - }; - - public ref class CodeDomExampleForm: public System::Windows::Forms::Form - { - private: - static System::Windows::Forms::Button^ run_button = gcnew System::Windows::Forms::Button; - static System::Windows::Forms::Button^ compile_button = gcnew System::Windows::Forms::Button; - static System::Windows::Forms::Button^ generate_button = gcnew System::Windows::Forms::Button; - static System::Windows::Forms::TextBox^ textBox1 = gcnew System::Windows::Forms::TextBox; - static System::Windows::Forms::ComboBox^ comboBox1 = gcnew System::Windows::Forms::ComboBox; - static System::Windows::Forms::Label^ label1 = gcnew System::Windows::Forms::Label; - void generate_button_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ ) - { - CodeDomProvider^ provider = GetCurrentProvider(); - CodeDomExample::GenerateCode( provider, CodeDomExample::BuildHelloWorldGraph() ); - - // Build the source file name with the appropriate - // language extension. - String^ sourceFile; - if ( provider->FileExtension->StartsWith( "." ) ) - { - sourceFile = String::Concat( "TestGraph", provider->FileExtension ); - } - else - { - sourceFile = String::Concat( "TestGraph.", provider->FileExtension ); - } - - - // Read in the generated source file and - // display the source text. - StreamReader^ sr = gcnew StreamReader( sourceFile ); - textBox1->Text = sr->ReadToEnd(); - sr->Close(); - } - - CodeDomProvider^ GetCurrentProvider() - { - CodeDomProvider^ provider; - if ( String::Compare( dynamic_cast(this->comboBox1->SelectedItem), "CSharp" ) == 0 ) - provider = CodeDomProvider::CreateProvider("CSharp"); - else - if ( String::Compare( dynamic_cast(this->comboBox1->SelectedItem), "Visual Basic" ) == 0 ) - provider = CodeDomProvider::CreateProvider("VisualBasic"); - else - if ( String::Compare( dynamic_cast(this->comboBox1->SelectedItem), "JScript" ) == 0 ) - provider = CodeDomProvider::CreateProvider("JScript"); - else - provider = CodeDomProvider::CreateProvider("CSharp"); - - return provider; - } - - void compile_button_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ ) - { - CodeDomProvider^ provider = GetCurrentProvider(); - - // Build the source file name with the appropriate - // language extension. - String^ sourceFile = String::Concat( "TestGraph.", provider->FileExtension ); - - // Compile the source file into an executable output file. - CompilerResults^ cr = CodeDomExample::CompileCode( provider, sourceFile, "TestGraph.exe" ); - if ( cr->Errors->Count > 0 ) - { - // Display compilation errors. - textBox1->Text = String::Concat( "Errors encountered while building ", sourceFile, " into ", cr->PathToAssembly, ": \r\n\n" ); - System::CodeDom::Compiler::CompilerError^ ce; - for ( int i = 0; i < cr->Errors->Count; i++ ) - { - ce = cr->Errors[i]; - textBox1->AppendText( String::Concat( ce->ToString(), "\r\n" ) ); - - } - run_button->Enabled = false; - } - else - { - textBox1->Text = String::Concat( "Source ", sourceFile, " built into ", cr->PathToAssembly, " with no errors." ); - run_button->Enabled = true; - } - } - - void run_button_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ ) - { - Process::Start( "TestGraph.exe" ); - } - - public: - CodeDomExampleForm() - { - this->SuspendLayout(); - - // Set properties for label1. - this->label1->Location = System::Drawing::Point( 395, 20 ); - this->label1->Size = System::Drawing::Size( 180, 22 ); - this->label1->Text = "Select a programming language:"; - - // Set properties for comboBox1. - this->comboBox1->Location = System::Drawing::Point( 560, 16 ); - this->comboBox1->Size = System::Drawing::Size( 190, 23 ); - this->comboBox1->Name = "comboBox1"; - array^temp1 = {"CSharp","Visual Basic","JScript"}; - this->comboBox1->Items->AddRange( temp1 ); - this->comboBox1->Anchor = (System::Windows::Forms::AnchorStyles)(System::Windows::Forms::AnchorStyles::Left | System::Windows::Forms::AnchorStyles::Right | System::Windows::Forms::AnchorStyles::Top); - this->comboBox1->SelectedIndex = 0; - - // Set properties for generate_button. - this->generate_button->Location = System::Drawing::Point( 8, 16 ); - this->generate_button->Name = "generate_button"; - this->generate_button->Size = System::Drawing::Size( 120, 23 ); - this->generate_button->Text = "Generate Code"; - this->generate_button->Click += gcnew System::EventHandler( this, &CodeDomExampleForm::generate_button_Click ); - - // Set properties for compile_button. - this->compile_button->Location = System::Drawing::Point( 136, 16 ); - this->compile_button->Name = "compile_button"; - this->compile_button->Size = System::Drawing::Size( 120, 23 ); - this->compile_button->Text = "Compile"; - this->compile_button->Click += gcnew System::EventHandler( this, &CodeDomExampleForm::compile_button_Click ); - - // Set properties for run_button. - this->run_button->Enabled = false; - this->run_button->Location = System::Drawing::Point( 264, 16 ); - this->run_button->Name = "run_button"; - this->run_button->Size = System::Drawing::Size( 120, 23 ); - this->run_button->Text = "Run"; - this->run_button->Click += gcnew System::EventHandler( this, &CodeDomExampleForm::run_button_Click ); - - // Set properties for textBox1. - 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, 48 ); - this->textBox1->Multiline = true; - this->textBox1->ScrollBars = System::Windows::Forms::ScrollBars::Vertical; - this->textBox1->Name = "textBox1"; - this->textBox1->Size = System::Drawing::Size( 744, 280 ); - this->textBox1->Text = ""; - - // Set properties for the CodeDomExampleForm. - this->AutoScaleBaseSize = System::Drawing::Size( 5, 13 ); - this->ClientSize = System::Drawing::Size( 768, 340 ); - this->MinimumSize = System::Drawing::Size( 750, 340 ); - array^myControl = {this->textBox1,this->run_button,this->compile_button,this->generate_button,this->comboBox1,this->label1}; - this->Controls->AddRange( myControl ); - this->Name = "CodeDomExampleForm"; - this->Text = "CodeDom Hello World Example"; - this->ResumeLayout( false ); - } - - public: - ~CodeDomExampleForm() - { - } - }; - -} - -[STAThread] -int main() -{ - Application::Run( gcnew CodeDOMExample::CodeDomExampleForm ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeDomPartialTypeExample/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/CodeDomPartialTypeExample/CPP/source.cpp deleted file mode 100644 index 080c30b3d2c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeDomPartialTypeExample/CPP/source.cpp +++ /dev/null @@ -1,439 +0,0 @@ - -// The following example builds a CodeDom source graph for a simple -// class that represents document properties. The source for the -// graph is generated, saved to a file, compiled into an executable, -// and run. -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; -using namespace System::Collections; -using namespace System::ComponentModel; -using namespace System::IO; -using namespace System::Diagnostics; - -// -// Build the source graph using System.CodeDom types. -CodeCompileUnit^ DocumentPropertyGraphBase() -{ - // Create a new CodeCompileUnit for the source graph. - CodeCompileUnit^ docPropUnit = gcnew CodeCompileUnit; - - // Declare a new namespace called DocumentSamples. - CodeNamespace^ sampleSpace = gcnew CodeNamespace( "DocumentSamples" ); - - // Add the new namespace to the compile unit. - docPropUnit->Namespaces->Add( sampleSpace ); - - // Add an import statement for the System namespace. - sampleSpace->Imports->Add( gcnew CodeNamespaceImport( "System" ) ); - - // Declare a new class called DocumentProperties. - // - CodeTypeDeclaration^ baseClass = gcnew CodeTypeDeclaration( "DocumentProperties" ); - baseClass->IsPartial = true; - baseClass->IsClass = true; - baseClass->Attributes = MemberAttributes::Public; - baseClass->BaseTypes->Add( gcnew CodeTypeReference( System::Object::typeid ) ); - - // Add the DocumentProperties class to the namespace. - sampleSpace->Types->Add( baseClass ); - // - - // ------Build the DocumentProperty.Main method------ - // Declare the Main method of the class. - CodeEntryPointMethod^ mainMethod = gcnew CodeEntryPointMethod; - mainMethod->Comments->Add( gcnew CodeCommentStatement( " Perform a simple test of the class methods." ) ); - - // Add the code entry point method to the Members - // collection of the type. - baseClass->Members->Add( mainMethod ); - mainMethod->Statements->Add( gcnew CodeCommentStatement( "Initialize a class instance and display it." ) ); - - // - // Initialize a local DocumentProperty instance, named myDoc. - // Use the DocumentProperty constructor to set the author, - // title, and date. Set the publish date to DateTime.Now. - CodePrimitiveExpression^ docTitlePrimitive = gcnew CodePrimitiveExpression( "Cubicle Survival Strategies" ); - CodePrimitiveExpression^ docAuthorPrimitive = gcnew CodePrimitiveExpression( "John Smith" ); - - // Store the value of DateTime.Now in a local variable, to re-use - // the same value later. - CodeTypeReferenceExpression^ docDateClass = gcnew CodeTypeReferenceExpression( "DateTime" ); - CodePropertyReferenceExpression^ docDateNow = gcnew CodePropertyReferenceExpression( docDateClass,"Now" ); - CodeVariableDeclarationStatement^ publishNow = gcnew CodeVariableDeclarationStatement( DateTime::typeid,"publishNow",docDateNow ); - mainMethod->Statements->Add( publishNow ); - CodeVariableReferenceExpression^ publishNowRef = gcnew CodeVariableReferenceExpression( "publishNow" ); - array^ctorParams = {docTitlePrimitive,docAuthorPrimitive,publishNowRef}; - CodeObjectCreateExpression^ initDocConstruct = gcnew CodeObjectCreateExpression( "DocumentProperties",ctorParams ); - CodeVariableDeclarationStatement^ myDocDeclare = gcnew CodeVariableDeclarationStatement( "DocumentProperties","myDoc",initDocConstruct ); - mainMethod->Statements->Add( myDocDeclare ); - // - - // Create a variable reference for the myDoc instance. - CodeVariableReferenceExpression^ myDocInstance = gcnew CodeVariableReferenceExpression( "myDoc" ); - - // Create a type reference for the System.Console class. - CodeTypeReferenceExpression^ csSystemConsoleType = gcnew CodeTypeReferenceExpression( "System.Console" ); - - // Build Console.WriteLine statement. - CodeMethodInvokeExpression^ consoleWriteLine0 = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"WriteLine",gcnew CodePrimitiveExpression( "** Document properties test **" ) ); - - // Add the WriteLine call to the statement collection. - mainMethod->Statements->Add( consoleWriteLine0 ); - - // Build Console.WriteLine("First document:"). - CodeMethodInvokeExpression^ consoleWriteLine1 = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"WriteLine",gcnew CodePrimitiveExpression( "First document:" ) ); - - // Add the WriteLine call to the statement collection. - mainMethod->Statements->Add( consoleWriteLine1 ); - - // Add a statement to display the myDoc instance properties. - CodeMethodInvokeExpression^ myDocToString = gcnew CodeMethodInvokeExpression( myDocInstance,"ToString" ); - CodeMethodInvokeExpression^ consoleWriteLine2 = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"WriteLine",myDocToString ); - mainMethod->Statements->Add( consoleWriteLine2 ); - - // Add a statement to display the myDoc instance hashcode property. - CodeMethodInvokeExpression^ myDocHashCode = gcnew CodeMethodInvokeExpression( myDocInstance,"GetHashCode" ); - array^writeHashCodeParams = {gcnew CodePrimitiveExpression( " Hash code: {0}" ),myDocHashCode}; - CodeMethodInvokeExpression^ consoleWriteLine3 = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"WriteLine",writeHashCodeParams ); - mainMethod->Statements->Add( consoleWriteLine3 ); - - // Add statements to create another instance. - mainMethod->Statements->Add( gcnew CodeCommentStatement( "Create another instance." ) ); - CodeVariableDeclarationStatement^ myNewDocDeclare = gcnew CodeVariableDeclarationStatement( "DocumentProperties","myNewDoc",initDocConstruct ); - mainMethod->Statements->Add( myNewDocDeclare ); - - // Create a variable reference for the myNewDoc instance. - CodeVariableReferenceExpression^ myNewDocInstance = gcnew CodeVariableReferenceExpression( "myNewDoc" ); - - // Build Console.WriteLine("Second document:"). - CodeMethodInvokeExpression^ consoleWriteLine5 = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"WriteLine",gcnew CodePrimitiveExpression( "Second document:" ) ); - - // Add the WriteLine call to the statement collection. - mainMethod->Statements->Add( consoleWriteLine5 ); - - // Add a statement to display the myNewDoc instance properties. - CodeMethodInvokeExpression^ myNewDocToString = gcnew CodeMethodInvokeExpression( myNewDocInstance,"ToString" ); - CodeMethodInvokeExpression^ consoleWriteLine6 = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"WriteLine",myNewDocToString ); - mainMethod->Statements->Add( consoleWriteLine6 ); - - // Add a statement to display the myNewDoc instance hashcode property. - CodeMethodInvokeExpression^ myNewDocHashCode = gcnew CodeMethodInvokeExpression( myNewDocInstance,"GetHashCode" ); - array^writeNewHashCodeParams = {gcnew CodePrimitiveExpression( " Hash code: {0}" ),myNewDocHashCode}; - CodeMethodInvokeExpression^ consoleWriteLine7 = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"WriteLine",writeNewHashCodeParams ); - mainMethod->Statements->Add( consoleWriteLine7 ); - - // - // Build a compound statement to compare the two instances. - mainMethod->Statements->Add( gcnew CodeCommentStatement( "Compare the two instances." ) ); - CodeMethodInvokeExpression^ myDocEquals = gcnew CodeMethodInvokeExpression( myDocInstance,"Equals",myNewDocInstance ); - CodePrimitiveExpression^ equalLine = gcnew CodePrimitiveExpression( "Second document is equal to the first." ); - CodePrimitiveExpression^ notEqualLine = gcnew CodePrimitiveExpression( "Second document is not equal to the first." ); - CodeMethodInvokeExpression^ equalWriteLine = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"WriteLine",equalLine ); - CodeMethodInvokeExpression^ notEqualWriteLine = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"WriteLine",notEqualLine ); - array^equalStatements = {gcnew CodeExpressionStatement( equalWriteLine )}; - array^notEqualStatements = {gcnew CodeExpressionStatement( notEqualWriteLine )}; - CodeConditionStatement^ docCompare = gcnew CodeConditionStatement( myDocEquals,equalStatements,notEqualStatements ); - mainMethod->Statements->Add( docCompare ); - // - - // - // Add a statement to change the myDoc.Author property: - mainMethod->Statements->Add( gcnew CodeCommentStatement( "Change the author of the original instance." ) ); - CodePropertyReferenceExpression^ myDocAuthor = gcnew CodePropertyReferenceExpression( myDocInstance,"Author" ); - CodePrimitiveExpression^ newDocAuthor = gcnew CodePrimitiveExpression( "Jane Doe" ); - CodeAssignStatement^ myDocAuthorAssign = gcnew CodeAssignStatement( myDocAuthor,newDocAuthor ); - mainMethod->Statements->Add( myDocAuthorAssign ); - // - - // Add a statement to display the modified instance. - CodeMethodInvokeExpression^ consoleWriteLine8 = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"WriteLine",gcnew CodePrimitiveExpression( "Modified original document:" ) ); - mainMethod->Statements->Add( consoleWriteLine8 ); - - // Reuse the myDoc.ToString statement built earlier. - mainMethod->Statements->Add( consoleWriteLine2 ); - - // Reuse the comparison block built earlier. - mainMethod->Statements->Add( gcnew CodeCommentStatement( "Compare the two instances again." ) ); - mainMethod->Statements->Add( docCompare ); - - // Add a statement to prompt the user to hit a key. - - // Build another call to System.WriteLine. - // Add string parameter to the WriteLine method. - CodeMethodInvokeExpression^ consoleWriteLine9 = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"WriteLine",gcnew CodePrimitiveExpression( "Press the Enter key to continue." ) ); - mainMethod->Statements->Add( consoleWriteLine9 ); - - // Build a call to System.ReadLine. - CodeMethodInvokeExpression^ consoleReadLine = gcnew CodeMethodInvokeExpression( csSystemConsoleType,"ReadLine" ); - mainMethod->Statements->Add( consoleReadLine ); - - // Define a few common expressions for the class methods. - CodePropertyReferenceExpression^ thisTitle = gcnew CodePropertyReferenceExpression( gcnew CodeThisReferenceExpression,"docTitle" ); - CodePropertyReferenceExpression^ thisAuthor = gcnew CodePropertyReferenceExpression( gcnew CodeThisReferenceExpression,"docAuthor" ); - CodePropertyReferenceExpression^ thisDate = gcnew CodePropertyReferenceExpression( gcnew CodeThisReferenceExpression,"docDate" ); - CodeTypeReferenceExpression^ stringType = gcnew CodeTypeReferenceExpression( String::typeid ); - CodePrimitiveExpression^ trueConst = gcnew CodePrimitiveExpression( true ); - CodePrimitiveExpression^ falseConst = gcnew CodePrimitiveExpression( false ); - - // ------Build the DocumentProperty.Equals method------ - CodeMemberMethod^ baseEquals = gcnew CodeMemberMethod; - baseEquals->Attributes = static_cast(MemberAttributes::Public | MemberAttributes::Override | MemberAttributes::Overloaded); - baseEquals->ReturnType = gcnew CodeTypeReference( bool::typeid ); - baseEquals->Name = "Equals"; - baseEquals->Parameters->Add( gcnew CodeParameterDeclarationExpression( Object::typeid,"obj" ) ); - baseEquals->Statements->Add( gcnew CodeCommentStatement( "Override System.Object.Equals method." ) ); - CodeVariableReferenceExpression^ objVar = gcnew CodeVariableReferenceExpression( "obj" ); - CodeCastExpression^ objCast = gcnew CodeCastExpression( "DocumentProperties",objVar ); - CodePropertyReferenceExpression^ objTitle = gcnew CodePropertyReferenceExpression( objCast,"Title" ); - CodePropertyReferenceExpression^ objAuthor = gcnew CodePropertyReferenceExpression( objCast,"Author" ); - CodePropertyReferenceExpression^ objDate = gcnew CodePropertyReferenceExpression( objCast,"PublishDate" ); - CodeMethodInvokeExpression^ objTitleEquals = gcnew CodeMethodInvokeExpression( objTitle,"Equals",thisTitle ); - CodeMethodInvokeExpression^ objAuthorEquals = gcnew CodeMethodInvokeExpression( objAuthor,"Equals",thisAuthor ); - CodeMethodInvokeExpression^ objDateEquals = gcnew CodeMethodInvokeExpression( objDate,"Equals",thisDate ); - CodeBinaryOperatorExpression^ andEquals1 = gcnew CodeBinaryOperatorExpression( objTitleEquals,CodeBinaryOperatorType::BooleanAnd,objAuthorEquals ); - CodeBinaryOperatorExpression^ andEquals2 = gcnew CodeBinaryOperatorExpression( andEquals1,CodeBinaryOperatorType::BooleanAnd,objDateEquals ); - array^returnTrueStatements = {gcnew CodeMethodReturnStatement( trueConst )}; - array^returnFalseStatements = {gcnew CodeMethodReturnStatement( falseConst )}; - CodeConditionStatement^ objEquals = gcnew CodeConditionStatement( andEquals2,returnTrueStatements,returnFalseStatements ); - baseEquals->Statements->Add( objEquals ); - baseClass->Members->Add( baseEquals ); - - // ------Build the DocumentProperty.GetHashCode method------ - CodeMemberMethod^ baseHash = gcnew CodeMemberMethod; - baseHash->Attributes = static_cast(MemberAttributes::Public | MemberAttributes::Override); - baseHash->ReturnType = gcnew CodeTypeReference( int::typeid ); - baseHash->Name = "GetHashCode"; - baseHash->Statements->Add( gcnew CodeCommentStatement( "Override System.Object.GetHashCode method." ) ); - CodeMethodInvokeExpression^ hashTitle = gcnew CodeMethodInvokeExpression( thisTitle,"GetHashCode" ); - CodeMethodInvokeExpression^ hashAuthor = gcnew CodeMethodInvokeExpression( thisAuthor,"GetHashCode" ); - CodeMethodInvokeExpression^ hashDate = gcnew CodeMethodInvokeExpression( thisDate,"GetHashCode" ); - CodeBinaryOperatorExpression^ orHash1 = gcnew CodeBinaryOperatorExpression( hashTitle,CodeBinaryOperatorType::BitwiseOr,hashAuthor ); - CodeBinaryOperatorExpression^ andHash = gcnew CodeBinaryOperatorExpression( orHash1,CodeBinaryOperatorType::BitwiseAnd,hashDate ); - baseHash->Statements->Add( gcnew CodeMethodReturnStatement( andHash ) ); - baseClass->Members->Add( baseHash ); - - // ------Build the DocumentProperty.ToString method------ - CodeMemberMethod^ docToString = gcnew CodeMemberMethod; - docToString->Attributes = static_cast(MemberAttributes::Public | MemberAttributes::Override); - docToString->ReturnType = gcnew CodeTypeReference( String::typeid ); - docToString->Name = "ToString"; - docToString->Statements->Add( gcnew CodeCommentStatement( "Override System.Object.ToString method." ) ); - CodeMethodInvokeExpression^ baseToString = gcnew CodeMethodInvokeExpression( gcnew CodeBaseReferenceExpression,"ToString" ); - CodePrimitiveExpression^ formatString = gcnew CodePrimitiveExpression( "{0} ({1} by {2}, {3})" ); - array^formatParams = {formatString,baseToString,thisTitle,thisAuthor,thisDate}; - CodeMethodInvokeExpression^ stringFormat = gcnew CodeMethodInvokeExpression( stringType,"Format",formatParams ); - docToString->Statements->Add( gcnew CodeMethodReturnStatement( stringFormat ) ); - baseClass->Members->Add( docToString ); - return docPropUnit; -} -// - -void DocumentPropertyGraphExpand( interior_ptr docPropUnit ) -{ - // Expand on the DocumentProperties class, - // adding the constructor and property implementation. - // - CodeTypeDeclaration^ baseClass = gcnew CodeTypeDeclaration( "DocumentProperties" ); - baseClass->IsPartial = true; - baseClass->IsClass = true; - baseClass->Attributes = MemberAttributes::Public; - - // Extend the DocumentProperties class in the unit namespace. - ( *docPropUnit)->Namespaces[ 0 ]->Types->Add( baseClass ); - // - - // ------Declare the internal class fields------ - baseClass->Members->Add( gcnew CodeMemberField( "String","docTitle" ) ); - baseClass->Members->Add( gcnew CodeMemberField( "String","docAuthor" ) ); - baseClass->Members->Add( gcnew CodeMemberField( "DateTime","docDate" ) ); - - // ------Build the DocumentProperty constructor------ - CodeConstructor^ docPropCtor = gcnew CodeConstructor; - docPropCtor->Attributes = MemberAttributes::Public; - docPropCtor->Parameters->Add( gcnew CodeParameterDeclarationExpression( "String","title" ) ); - docPropCtor->Parameters->Add( gcnew CodeParameterDeclarationExpression( "String","author" ) ); - docPropCtor->Parameters->Add( gcnew CodeParameterDeclarationExpression( "DateTime","publishDate" ) ); - CodeFieldReferenceExpression^ myTitle = gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"docTitle" ); - CodeVariableReferenceExpression^ inTitle = gcnew CodeVariableReferenceExpression( "title" ); - CodeAssignStatement^ myDocTitleAssign = gcnew CodeAssignStatement( myTitle,inTitle ); - docPropCtor->Statements->Add( myDocTitleAssign ); - CodeFieldReferenceExpression^ myAuthor = gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"docAuthor" ); - CodeVariableReferenceExpression^ inAuthor = gcnew CodeVariableReferenceExpression( "author" ); - CodeAssignStatement^ myDocAuthorAssign = gcnew CodeAssignStatement( myAuthor,inAuthor ); - docPropCtor->Statements->Add( myDocAuthorAssign ); - CodeFieldReferenceExpression^ myDate = gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"docDate" ); - CodeVariableReferenceExpression^ inDate = gcnew CodeVariableReferenceExpression( "publishDate" ); - CodeAssignStatement^ myDocDateAssign = gcnew CodeAssignStatement( myDate,inDate ); - docPropCtor->Statements->Add( myDocDateAssign ); - baseClass->Members->Add( docPropCtor ); - - // ------Build the DocumentProperty properties------ - CodeMemberProperty^ docTitleProp = gcnew CodeMemberProperty; - docTitleProp->HasGet = true; - docTitleProp->HasSet = true; - docTitleProp->Name = "Title"; - docTitleProp->Type = gcnew CodeTypeReference( "String" ); - docTitleProp->Attributes = MemberAttributes::Public; - docTitleProp->GetStatements->Add( gcnew CodeMethodReturnStatement( gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"docTitle" ) ) ); - docTitleProp->SetStatements->Add( gcnew CodeAssignStatement( gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"docTitle" ),gcnew CodePropertySetValueReferenceExpression ) ); - baseClass->Members->Add( docTitleProp ); - CodeMemberProperty^ docAuthorProp = gcnew CodeMemberProperty; - docAuthorProp->HasGet = true; - docAuthorProp->HasSet = true; - docAuthorProp->Name = "Author"; - docAuthorProp->Type = gcnew CodeTypeReference( "String" ); - docAuthorProp->Attributes = MemberAttributes::Public; - docAuthorProp->GetStatements->Add( gcnew CodeMethodReturnStatement( gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"docAuthor" ) ) ); - docAuthorProp->SetStatements->Add( gcnew CodeAssignStatement( gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"docAuthor" ),gcnew CodePropertySetValueReferenceExpression ) ); - baseClass->Members->Add( docAuthorProp ); - CodeMemberProperty^ docDateProp = gcnew CodeMemberProperty; - docDateProp->HasGet = true; - docDateProp->HasSet = true; - docDateProp->Name = "PublishDate"; - docDateProp->Type = gcnew CodeTypeReference( "DateTime" ); - docDateProp->Attributes = MemberAttributes::Public; - docDateProp->GetStatements->Add( gcnew CodeMethodReturnStatement( gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"docDate" ) ) ); - docDateProp->SetStatements->Add( gcnew CodeAssignStatement( gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"docDate" ),gcnew CodePropertySetValueReferenceExpression ) ); - baseClass->Members->Add( docDateProp ); -} - -String^ GenerateCode( CodeDomProvider^ provider, CodeCompileUnit^ compileUnit ) -{ - // Build the source file name with the language - // extension (vb, cs, js). - String^ sourceFile = ""; - - // Write the source out in the selected language if - // the code generator supports partial type declarations. - if ( provider->Supports( GeneratorSupport::PartialTypes ) ) - { - if ( provider->FileExtension[ 0 ] == '.' ) - { - sourceFile = String::Format( "DocProp{0}", provider->FileExtension ); - } - else - { - sourceFile = String::Format( "DocProp.{0}", provider->FileExtension ); - } - - // Create a TextWriter to a StreamWriter to an output file. - IndentedTextWriter^ outWriter = gcnew IndentedTextWriter( gcnew StreamWriter( sourceFile,false )," " ); - - // Generate source code using the code generator. - provider->GenerateCodeFromCompileUnit( compileUnit, outWriter, nullptr ); - - // Close the output file. - outWriter->Close(); - } - - return sourceFile; -} - -// -bool CompileCode( CodeDomProvider^ provider, String^ sourceFile, String^ exeFile ) -{ - CompilerParameters^ cp = gcnew CompilerParameters; - - // Generate an executable instead of - // a class library. - cp->GenerateExecutable = true; - - // Set the assembly file name to generate. - cp->OutputAssembly = exeFile; - - // Save the assembly as a physical file. - cp->GenerateInMemory = false; - - // Generate debug information. - cp->IncludeDebugInformation = true; - - // Add an assembly reference. - cp->ReferencedAssemblies->Add( "System.dll" ); - - // Set the warning level at which - // the compiler should abort compilation - // if a warning of this level occurs. - cp->WarningLevel = 3; - - // Set whether to treat all warnings as errors. - cp->TreatWarningsAsErrors = false; - if ( provider->Supports( GeneratorSupport::EntryPointMethod ) ) - { - // Specify the class that contains - // the main method of the executable. - cp->MainClass = "DocumentSamples.DocumentProperties"; - } - - // Invoke compilation. - CompilerResults^ cr = provider->CompileAssemblyFromFile( cp, sourceFile ); - if ( cr->Errors->Count > 0 ) - { - // Display compilation errors. - Console::WriteLine( "Errors building {0} into {1}", sourceFile, cr->PathToAssembly ); - IEnumerator^ myEnum = cr->Errors->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - CompilerError^ ce = safe_cast(myEnum->Current); - Console::WriteLine( " {0}", ce ); - Console::WriteLine(); - } - } - else - { - Console::WriteLine( "Source {0} built into {1} successfully.", sourceFile, cr->PathToAssembly ); - } - - // Return the results of compilation. - if ( cr->Errors->Count > 0 ) - { - return false; - } - else - { - return true; - } -} -// - -[STAThread] -int main() -{ - CodeDomProvider^ provider = nullptr; - String^ exeName = "DocProp.exe"; - Console::WriteLine( "Enter the source language for DocumentProperties class (cs, vb, etc):" ); - String^ inputLang = Console::ReadLine(); - Console::WriteLine(); - if ( CodeDomProvider::IsDefinedLanguage( inputLang ) ) - { - provider = CodeDomProvider::CreateProvider( inputLang ); - } - - if ( provider == nullptr ) - { - Console::WriteLine( "There is no CodeDomProvider for the input language." ); - } - else - { - CodeCompileUnit^ docPropertyUnit = DocumentPropertyGraphBase(); - DocumentPropertyGraphExpand( &docPropertyUnit ); - String^ sourceFile = GenerateCode( provider, docPropertyUnit ); - if ( !String::IsNullOrEmpty( sourceFile ) ) - { - Console::WriteLine( "Document property class code generated." ); - if ( CompileCode( provider, sourceFile, exeName ) ) - { - Console::WriteLine( "Starting DocProp executable." ); - Process::Start( exeName ); - } - } - else - { - Console::WriteLine( "Could not generate source file." ); - Console::WriteLine( "Target language code generator might not support partial type declarations." ); - } - } -} - diff --git a/snippets/cpp/VS_Snippets_CLR/CodeDomSampleBatch/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/CodeDomSampleBatch/CPP/class1.cpp deleted file mode 100644 index 1cc24bf7789..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeDomSampleBatch/CPP/class1.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSampleBatch -{ - public ref class Class1 - { - public: - Class1(){} - - static CodeCompileUnit^ CreateCompileUnit() - { - CodeCompileUnit^ cu = gcnew CodeCompileUnit; - - // - // Creates a code expression for a CodeExpressionStatement to contain. - array^ temp = {gcnew CodePrimitiveExpression( "Example string" )}; - CodeExpression^ invokeExpression = gcnew CodeMethodInvokeExpression( - gcnew CodeTypeReferenceExpression( "Console" ),"Write",temp ); - - // Creates a statement using a code expression. - CodeExpressionStatement^ expressionStatement; - expressionStatement = gcnew CodeExpressionStatement( invokeExpression ); - - // A C++ code generator produces the following source code for the preceeding example code: - - // Console::Write( "Example string" ); - // - - // - // Creates a CodeLinePragma that references line 100 of the file "example.cs". - CodeLinePragma^ pragma = gcnew CodeLinePragma( "example.cs",100 ); - // - - // - // Creates a CodeSnippetExpression that represents a literal string that - // can be used as an expression in a CodeDOM graph. - CodeSnippetExpression^ literalExpression = - gcnew CodeSnippetExpression( "Literal expression" ); - // - - // - // Creates a statement using a literal string. - CodeSnippetStatement^ literalStatement = - gcnew CodeSnippetStatement( "Console.Write(\"Test literal statement output\")" ); - // - - // - // Creates a type member using a literal string. - CodeSnippetTypeMember^ literalMember = - gcnew CodeSnippetTypeMember( "public static void TestMethod() {}" ); - // - return cu; - } - - static CodeCompileUnit^ CreateSnippetCompileUnit() - { - // - // Creates a compile unit using a literal sring; - String^ literalCode; - literalCode = "using System; namespace TestLiteralCode " + - "{ public class TestClass { public TestClass() {} } }"; - CodeSnippetCompileUnit^ csu = gcnew CodeSnippetCompileUnit( literalCode ); - // - return csu; - } - - // CodeNamespaceImportCollection - void CodeNamespaceImportCollectionExample() - { - // - // - // Creates an empty CodeNamespaceImportCollection. - CodeNamespaceImportCollection^ collection = - gcnew CodeNamespaceImportCollection; - // - - // - // Adds a CodeNamespaceImport to the collection. - collection->Add( gcnew CodeNamespaceImport( "System" ) ); - // - - // - // Adds an array of CodeNamespaceImport objects to the collection. - array^ Imports = { - gcnew CodeNamespaceImport( "System" ), - gcnew CodeNamespaceImport( "System.Drawing" )}; - collection->AddRange( Imports ); - // - - // - // Retrieves the count of the items in the collection. - int collectionCount = collection->Count; - // - // - } - }; -} diff --git a/snippets/cpp/VS_Snippets_CLR/CodeDom_CompilerInfo/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/CodeDom_CompilerInfo/CPP/source.cpp deleted file mode 100644 index 6d0058c9957..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeDom_CompilerInfo/CPP/source.cpp +++ /dev/null @@ -1,327 +0,0 @@ - - -// System.CodeDom.Compiler.CompilerInfo -// -// Requires .NET Framework version 2.0 or higher. -// -// The following example displays compiler configuration settings. -// Command-line arguments are used to specify a compiler language, -// file extension, or provider type. For the given input, the -// example determines the corresponding code compiler settings. -// -// -// Command-line argument examples: -// -// - Displays Visual Basic, C#, and JScript compiler settings. -// Language CSharp -// - Displays the compiler settings for C#. -// All -// - Displays settings for all configured compilers. -// Config Pascal -// - Displays settings for configured Pascal language provider, -// if one exists. -// Extension .vb -// - Displays settings for the compiler associated with the .vb -// file extension. -#using -#using - -using namespace System; -using namespace System::Globalization; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; -using namespace Microsoft::CSharp; -using namespace Microsoft::VisualBasic; -using namespace System::Configuration; -using namespace System::Security::Permissions; - -namespace CodeDomCompilerInfoSample -{ - [PermissionSet(SecurityAction::Demand, Name="FullTrust")] - public ref class CompilerInfoSample - { - public: - static void Main( array^args ) - { - String^ queryCommand = ""; - String^ queryArg = ""; - int iNumArguments = args->Length; - - // Get input command-line arguments. - if ( iNumArguments > 0 ) - { - queryCommand = args[ 0 ]->ToUpper( CultureInfo::InvariantCulture ); - if ( iNumArguments > 1 ) - queryArg = args[ 1 ]; - } - - // Determine which method to call. - Console::WriteLine(); - if ( queryCommand->Equals( "LANGUAGE" ) ) - DisplayCompilerInfoForLanguage( queryArg ); // Display compiler information for input language. - else if ( queryCommand->Equals( "EXTENSION" ) ) - DisplayCompilerInfoUsingExtension( queryArg ); // Display compiler information for input file extension. - else if ( queryCommand->Equals( "CONFIG" ) ) - DisplayCompilerInfoForConfigLanguage( queryArg ); // Display settings for the configured language provider. - else if ( queryCommand->Equals( "ALL" ) ) - DisplayAllCompilerInfo(); // Display compiler information for all configured language providers. - else - { - // There was no command-line argument, or the - // command-line argument was not recognized. - // Display the C#, Visual Basic and JScript - // compiler information. - DisplayCSharpCompilerInfo(); - DisplayVBCompilerInfo(); - DisplayJScriptCompilerInfo(); - } - } - - - private: - static void DisplayCSharpCompilerInfo() - { - // - // Get the provider for Microsoft.CSharp -// CodeDomProvider^ provider = CodeDomProvider.CreateProvider("CSharp"); - CodeDomProvider^ provider = CodeDomProvider::CreateProvider("CSharp"); - - if ( provider ) - { - // Display the C# language provider information. - Console::WriteLine( "CSharp provider is {0}", provider->ToString() ); - Console::WriteLine( " Provider hash code: {0}", provider->GetHashCode().ToString() ); - Console::WriteLine( " Default file extension: {0}", provider->FileExtension ); - } - - // - Console::WriteLine(); - } - - static void DisplayVBCompilerInfo() - { - // - // Get the provider for Microsoft.VisualBasic -// CodeDomProvider^ provider = CodeDomProvider.CreateProvider("VisualBasic"); - CodeDomProvider^ provider = CodeDomProvider::CreateProvider("VisualBasic"); - if ( provider ) // Display the Visual Basic language provider information. - { - Console::WriteLine( "Visual Basic provider is {0}", provider->ToString() ); - Console::WriteLine( " Provider hash code: {0}", provider->GetHashCode().ToString() ); - Console::WriteLine( " Default file extension: {0}", provider->FileExtension ); - } - - // - Console::WriteLine(); - } - - static void DisplayJScriptCompilerInfo() - { - // - // Get the provider for JScript. - CodeDomProvider^ provider; - try - { -// provider = CodeDomProvider.CreateProvider("JScript"); - provider = CodeDomProvider::CreateProvider("JScript"); - if ( provider ) - { - // Display the JScript language provider information. - Console::WriteLine( "JScript language provider is {0}", provider->ToString() ); - Console::WriteLine( " Provider hash code: {0}", provider->GetHashCode().ToString() ); - Console::WriteLine( " Default file extension: {0}", provider->FileExtension ); - Console::WriteLine(); - } - } - catch ( ConfigurationException^ e ) - { - // The JScript language provider was not found. - Console::WriteLine( "There is no configured JScript language provider." ); - } - - // - } - - static void DisplayCompilerInfoUsingExtension( String^ fileExtension ) - { - // - if ( !fileExtension->StartsWith( "." ) ) - fileExtension = String::Concat( ".", fileExtension ); - - // Get the language associated with the file extension. - CodeDomProvider^ provider = nullptr; - if ( CodeDomProvider::IsDefinedExtension( fileExtension ) ) - { - String^ language = CodeDomProvider::GetLanguageFromExtension( fileExtension ); - if ( language ) - Console::WriteLine( "The language \"{0}\" is associated with file extension \"{1}\"\n", - language, fileExtension ); - - // Check for a corresponding language provider. - if ( language && CodeDomProvider::IsDefinedLanguage( language ) ) - { - provider = CodeDomProvider::CreateProvider( language ); - if ( provider ) - { - // Display information about this language provider. - Console::WriteLine( "Language provider: {0}\n", provider->ToString() ); - - // Get the compiler settings for this language. - CompilerInfo^ langCompilerInfo = CodeDomProvider::GetCompilerInfo( language ); - if ( langCompilerInfo ) - { - CompilerParameters^ langCompilerConfig = langCompilerInfo->CreateDefaultCompilerParameters(); - if ( langCompilerConfig ) - { - Console::WriteLine( " Compiler options: {0}", langCompilerConfig->CompilerOptions ); - Console::WriteLine( " Compiler warning level: {0}", langCompilerConfig->WarningLevel.ToString() ); - } - } - } - } - } - - if ( provider == nullptr ) // Tell the user that the language provider was not found. - Console::WriteLine( "There is no language provider associated with input file extension \"{0}\".", fileExtension ); - - // - } - - static void DisplayCompilerInfoForLanguage( String^ language ) - { - // - CodeDomProvider^ provider = nullptr; - - // Check for a provider corresponding to the input language. - if ( CodeDomProvider::IsDefinedLanguage( language ) ) - { - provider = CodeDomProvider::CreateProvider( language ); - if ( provider ) - { - // Display information about this language provider. - Console::WriteLine( "Language provider: {0}", provider->ToString() ); - Console::WriteLine(); - Console::WriteLine( " Default file extension: {0}", provider->FileExtension ); - Console::WriteLine(); - - // Get the compiler settings for this language. - CompilerInfo^ langCompilerInfo = CodeDomProvider::GetCompilerInfo( language ); - if ( langCompilerInfo ) - { - CompilerParameters^ langCompilerConfig = langCompilerInfo->CreateDefaultCompilerParameters(); - if ( langCompilerConfig ) - { - Console::WriteLine( " Compiler options: {0}", langCompilerConfig->CompilerOptions ); - Console::WriteLine( " Compiler warning level: {0}", langCompilerConfig->WarningLevel.ToString() ); - } - } - } - } - - if ( provider == nullptr ) // Tell the user that the language provider was not found. - Console::WriteLine( "There is no provider configured for input language \"{0}\".", language ); - - // - } - - static void DisplayCompilerInfoForConfigLanguage( String^ configLanguage ) - { - // - CodeDomProvider^ provider = nullptr; - CompilerInfo^ info = CodeDomProvider::GetCompilerInfo( configLanguage ); - - // Check whether there is a provider configured for this language. - if ( info->IsCodeDomProviderTypeValid ) - { - // Get a provider instance using the configured type information. - provider = dynamic_cast(Activator::CreateInstance( info->CodeDomProviderType )); - if ( provider ) - { - // Display information about this language provider. - Console::WriteLine( "Language provider: {0}", provider->ToString() ); - Console::WriteLine(); - Console::WriteLine( " Default file extension: {0}", provider->FileExtension ); - Console::WriteLine(); - - // Get the compiler settings for this language. - CompilerParameters^ langCompilerConfig = info->CreateDefaultCompilerParameters(); - if ( langCompilerConfig ) - { - Console::WriteLine( " Compiler options: {0}", langCompilerConfig->CompilerOptions ); - Console::WriteLine( " Compiler warning level: {0}", langCompilerConfig->WarningLevel.ToString() ); - } - } - } - - if ( provider == nullptr ) // Tell the user that the language provider was not found. - Console::WriteLine( "There is no provider configured for input language \"{0}\".", configLanguage ); - - // - } - - static void DisplayAllCompilerInfo() - { - // - array^allCompilerInfo = CodeDomProvider::GetAllCompilerInfo(); - for ( int i = 0; i < allCompilerInfo->Length; i++ ) - { - String^ defaultLanguage; - String^ defaultExtension; - CompilerInfo^ info = allCompilerInfo[ i ]; - CodeDomProvider^ provider = nullptr; - if ( info ) - provider = info->CreateProvider(); - - if ( provider ) - { - // Display information about this configured provider. - Console::WriteLine( "Language provider: {0}", provider->ToString() ); - Console::WriteLine(); - Console::WriteLine( " Supported file extension(s):" ); - array^extensions = info->GetExtensions(); - for ( int i = 0; i < extensions->Length; i++ ) - Console::WriteLine( " {0}", extensions[ i ] ); - - defaultExtension = provider->FileExtension; - if ( !defaultExtension->StartsWith( "." ) ) - defaultExtension = String::Concat( ".", defaultExtension ); - - Console::WriteLine( " Default file extension: {0}\n", defaultExtension ); - Console::WriteLine( " Supported language(s):" ); - array^languages = info->GetLanguages(); - for ( int i = 0; i < languages->Length; i++ ) - Console::WriteLine( " {0}", languages[ i ] ); - - defaultLanguage = CodeDomProvider::GetLanguageFromExtension( defaultExtension ); - Console::WriteLine( " Default language: {0}", defaultLanguage ); - Console::WriteLine(); - - // Get the compiler settings for this provider. - CompilerParameters^ langCompilerConfig = info->CreateDefaultCompilerParameters(); - if ( langCompilerConfig ) - { - Console::WriteLine( " Compiler options: {0}", langCompilerConfig->CompilerOptions ); - Console::WriteLine( " Compiler warning level: {0}", langCompilerConfig->WarningLevel.ToString() ); - } - } - - } - // - } - - }; - -} - - -// The main entry point for the application. - -[STAThread] -int main( int argc, char *argv[] ) -{ - CodeDomCompilerInfoSample::CompilerInfoSample::Main( Environment::GetCommandLineArgs() ); - Console::WriteLine("\n\nPress ENTER to return"); - Console::ReadLine(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeEntryPointMethod/CPP/codeentrypointmethodexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeEntryPointMethod/CPP/codeentrypointmethodexample.cpp deleted file mode 100644 index 98d30708b47..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeEntryPointMethod/CPP/codeentrypointmethodexample.cpp +++ /dev/null @@ -1,59 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSamples -{ - public ref class CodeEntryPointMethodExample - { - public: - - // - // Builds a Hello World Program Graph using System.CodeDom objects - static CodeCompileUnit^ BuildHelloWorldGraph() - { - - // Create a new CodeCompileUnit to contain the program graph - CodeCompileUnit^ CompileUnit = gcnew CodeCompileUnit; - - // Declare a new namespace object and name it - CodeNamespace^ Samples = gcnew CodeNamespace( "Samples" ); - - // Add the namespace object to the compile unit - CompileUnit->Namespaces->Add( Samples ); - - // Add a new namespace import for the System namespace - Samples->Imports->Add( gcnew CodeNamespaceImport( "System" ) ); - - // Declare a new type object and name it - CodeTypeDeclaration^ Class1 = gcnew CodeTypeDeclaration( "Class1" ); - - // Add the new type to the namespace object's type collection - Samples->Types->Add( Class1 ); - - // Declare a new code entry point method - CodeEntryPointMethod^ Start = gcnew CodeEntryPointMethod; - - // Create a new method invoke expression - array^temp = {gcnew CodePrimitiveExpression( "Hello World!" )}; - CodeMethodInvokeExpression^ cs1 = gcnew CodeMethodInvokeExpression( gcnew CodeTypeReferenceExpression( "System.Console" ),"WriteLine",temp ); - - // Add the new method code statement - Start->Statements->Add( gcnew CodeExpressionStatement( cs1 ) ); - - // Add the code entry point method to the type's members collection - Class1->Members->Add( Start ); - return CompileUnit; - - // - } - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeExpressionCollectionExample/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/CodeExpressionCollectionExample/CPP/class1.cpp deleted file mode 100644 index 8a1f531f50a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeExpressionCollectionExample/CPP/class1.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeExpressionCollectionExample -{ - public ref class Class1 - { - public: - Class1(){} - - // CodeExpressionCollection - void CodeExpressionCollectionExample() - { - // - // - // Creates an empty CodeExpressionCollection. - CodeExpressionCollection^ collection = gcnew CodeExpressionCollection; - // - - // - // Adds a CodeExpression to the collection. - collection->Add( gcnew CodePrimitiveExpression( true ) ); - // - - // - // Adds an array of CodeExpression objects to the collection. - array^expressions = {gcnew CodePrimitiveExpression( true ),gcnew CodePrimitiveExpression( true )}; - collection->AddRange( expressions ); - - // Adds a collection of CodeExpression objects to the collection. - CodeExpressionCollection^ expressionsCollection = gcnew CodeExpressionCollection; - expressionsCollection->Add( gcnew CodePrimitiveExpression( true ) ); - expressionsCollection->Add( gcnew CodePrimitiveExpression( true ) ); - collection->AddRange( expressionsCollection ); - // - - // - // Tests for the presence of a CodeExpression in the - // collection, and retrieves its index if it is found. - CodeExpression^ testComment = gcnew CodePrimitiveExpression( true ); - int itemIndex = -1; - if ( collection->Contains( testComment ) ) - itemIndex = collection->IndexOf( testComment ); - // - - // - // Copies the contents of the collection beginning at index 0 to the specified CodeExpression array. - // 'expressions' is a CodeExpression array. - collection->CopyTo( expressions, 0 ); - // - - // - // Retrieves the count of the items in the collection. - int collectionCount = collection->Count; - // - - // - // Inserts a CodeExpression at index 0 of the collection. - collection->Insert( 0, gcnew CodePrimitiveExpression( true ) ); - // - - // - // Removes the specified CodeExpression from the collection. - CodeExpression^ expression = gcnew CodePrimitiveExpression( true ); - collection->Remove( expression ); - // - - // - // Removes the CodeExpression at index 0. - collection->RemoveAt( 0 ); - // - // - } - }; -} diff --git a/snippets/cpp/VS_Snippets_CLR/CodeGeneratorOptionsExample/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/CodeGeneratorOptionsExample/CPP/class1.cpp deleted file mode 100644 index be4a228d29c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeGeneratorOptionsExample/CPP/class1.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; - -[STAThread] -int main() -{ - // - // Creates a new CodeGeneratorOptions. - CodeGeneratorOptions^ genOptions = gcnew CodeGeneratorOptions; - - // Sets a value indicating that the code generator should insert blank lines between type members. - genOptions->BlankLinesBetweenMembers = true; - - // Sets the style of bracing format to use: either S"Block" to start a - // bracing block on the same line as the declaration of its container, or - // S"C" to start the bracing for the block on the following line. - genOptions->BracingStyle = "C"; - - // Sets a value indicating that the code generator should not append an else, - // catch or finally block, including brackets, at the closing line of a preceeding if or try block. - genOptions->ElseOnClosing = false; - - // Sets the String* to indent each line with. - genOptions->IndentString = " "; - - // Uses the CodeGeneratorOptions indexer property to set an - // example Object* to the type's String*-keyed ListDictionary. - // Custom ICodeGenerator* implementations can use objects - // in this dictionary to customize process behavior. - genOptions[ "CustomGeneratorOptionStringExampleID" ] = "BuildFlags: /A /B /C /D /E"; - // - - Console::WriteLine( genOptions ); -} diff --git a/snippets/cpp/VS_Snippets_CLR/CodeGotoStatementExample/CPP/codegotostatementexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeGotoStatementExample/CPP/codegotostatementexample.cpp deleted file mode 100644 index cab34001736..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeGotoStatementExample/CPP/codegotostatementexample.cpp +++ /dev/null @@ -1,59 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSamples -{ - public ref class CodeGotoStatementExample - { - public: - CodeGotoStatementExample() - { - - // - // Declares a type to contain the example code. - CodeTypeDeclaration^ type1 = gcnew CodeTypeDeclaration( "Type1" ); - - // Declares an entry point method. - CodeEntryPointMethod^ entry1 = gcnew CodeEntryPointMethod; - type1->Members->Add( entry1 ); - - // Adds a goto statement to continue program flow at the "JumpToLabel" label. - CodeGotoStatement^ goto1 = gcnew CodeGotoStatement( "JumpToLabel" ); - entry1->Statements->Add( goto1 ); - - // Invokes Console.WriteLine to print "Test Output", which is skipped by the goto statement. - array^temp = {gcnew CodePrimitiveExpression( "Test Output." )}; - CodeMethodInvokeExpression^ method1 = gcnew CodeMethodInvokeExpression( gcnew CodeTypeReferenceExpression( "System.Console" ),"WriteLine",temp ); - entry1->Statements->Add( method1 ); - - // Declares a label named "JumpToLabel" associated with a method to output a test string using Console.WriteLine. - array^temp2 = {gcnew CodePrimitiveExpression( "Output from labeled statement." )}; - CodeMethodInvokeExpression^ method2 = gcnew CodeMethodInvokeExpression( gcnew CodeTypeReferenceExpression( "System.Console" ),"WriteLine",temp2 ); - CodeLabeledStatement^ label1 = gcnew CodeLabeledStatement( "JumpToLabel",gcnew CodeExpressionStatement( method2 ) ); - entry1->Statements->Add( label1 ); - - // A C# code generator produces the following source code for the preceeding example code: - // public class Type1 - // { - // - // public static void Main() - // { - // goto JumpToLabel; - // System.Console.WriteLine("Test Output"); - // JumpToLabel: - // System.Console.WriteLine("Output from labeled statement."); - // } - // } - // - } - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeIterationStatementExample/CPP/codeiterationstatementexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeIterationStatementExample/CPP/codeiterationstatementexample.cpp deleted file mode 100644 index c3a1463a6e3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeIterationStatementExample/CPP/codeiterationstatementexample.cpp +++ /dev/null @@ -1,35 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSamples -{ - public ref class CodeIterationStatementExample - { - public: - CodeIterationStatementExample() - { - // - // Declares and initializes an integer variable named testInt. - CodeVariableDeclarationStatement^ testInt = gcnew CodeVariableDeclarationStatement( int::typeid,"testInt",gcnew CodePrimitiveExpression( (int^)0 ) ); - array^writelineparams = {gcnew CodeMethodInvokeExpression( gcnew CodeVariableReferenceExpression( "testInt" ),"ToString",nullptr )}; - array^codestatements = {gcnew CodeExpressionStatement( gcnew CodeMethodInvokeExpression( gcnew CodeMethodReferenceExpression( gcnew CodeTypeReferenceExpression( "Console" ),"WriteLine" ),writelineparams ) )}; - - // Creates a for loop that sets testInt to 0 and continues incrementing testInt by 1 each loop until testInt is not less than 10. - - // Each loop iteration the value of the integer is output using the Console.WriteLine method. - CodeIterationStatement^ forLoop = gcnew CodeIterationStatement( gcnew CodeAssignStatement( gcnew CodeVariableReferenceExpression( "testInt" ),gcnew CodePrimitiveExpression( 1 ) ),gcnew CodeBinaryOperatorExpression( gcnew CodeVariableReferenceExpression( "testInt" ),CodeBinaryOperatorType::LessThan,gcnew CodePrimitiveExpression( 10 ) ),gcnew CodeAssignStatement( gcnew CodeVariableReferenceExpression( "testInt" ),gcnew CodeBinaryOperatorExpression( gcnew CodeVariableReferenceExpression( "testInt" ),CodeBinaryOperatorType::Add,gcnew CodePrimitiveExpression( 1 ) ) ),codestatements ); - - // A C# code generator produces the following source code for the preceeding example code: - // int testInt = 0; - // for (testInt = 1; (testInt < 10); testInt = (testInt + 1)) { - // Console.WriteLine(testInt.ToString()); - // - } - }; -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeMemberEventSample/CPP/codemembereventexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeMemberEventSample/CPP/codemembereventexample.cpp deleted file mode 100644 index 26b6cf744fb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeMemberEventSample/CPP/codemembereventexample.cpp +++ /dev/null @@ -1,59 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSamples -{ - public ref class CodeMemberEventExample - { - public: - CodeMemberEventExample() - { - - // - // Declares a type to contain an event and constructor method. - CodeTypeDeclaration^ type1 = gcnew CodeTypeDeclaration( "EventTest" ); - - // - // Declares an event that accepts a delegate type of System.EventHandler. - CodeMemberEvent^ event1 = gcnew CodeMemberEvent; - - // Sets a name for the event. - event1->Name = "TestEvent"; - - // Sets the type of event. - event1->Type = gcnew CodeTypeReference( "System.EventHandler" ); - - // A C# code generator produces the following source code for the preceeding example code: - // private event System.EventHandler TestEvent; - // - // Adds the event to the type members collection. - type1->Members->Add( event1 ); - - // Declares an empty type constructor. - CodeConstructor^ constructor1 = gcnew CodeConstructor; - constructor1->Attributes = MemberAttributes::Public; - type1->Members->Add( constructor1 ); - - // A C# code generator produces the following source code for the preceeding example code: - // public class EventTest - // { - // - // public EventTest() - // { - // } - // - // private event System.EventHandler TestEvent; - // } - // - } - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeMemberFieldExample/CPP/codememberfieldexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeMemberFieldExample/CPP/codememberfieldexample.cpp deleted file mode 100644 index a6523e8e7f4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeMemberFieldExample/CPP/codememberfieldexample.cpp +++ /dev/null @@ -1,46 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSamples -{ - public ref class CodeMemberFieldExample - { - public: - CodeMemberFieldExample() - { - - // - // Declares a type to contain a field and a constructor method. - CodeTypeDeclaration^ type1 = gcnew CodeTypeDeclaration( "FieldTest" ); - - // Declares a field of type String named testStringField. - CodeMemberField^ field1 = gcnew CodeMemberField( "System.String","TestStringField" ); - type1->Members->Add( field1 ); - - // Declares an empty type constructor. - CodeConstructor^ constructor1 = gcnew CodeConstructor; - constructor1->Attributes = MemberAttributes::Public; - type1->Members->Add( constructor1 ); - - // A C# code generator produces the following source code for the preceeding example code: - // public class FieldTest - // { - // private string testStringField; - // - // public FieldTest() - // { - // } - // } - // - } - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeMemberFieldPublicConstExample/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/CodeMemberFieldPublicConstExample/CPP/class1.cpp deleted file mode 100644 index 85f2cca6311..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeMemberFieldPublicConstExample/CPP/class1.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeMemberField_PublicConst_Example -{ - public ref class Class1 - { - private: - static CodeCompileUnit^ GetCompileUnit() - { - CodeCompileUnit^ cu = gcnew CodeCompileUnit; - CodeNamespace^ nsp = gcnew CodeNamespace( "TestNamespace" ); - cu->Namespaces->Add( nsp ); - CodeTypeDeclaration^ testType = gcnew CodeTypeDeclaration( "testType" ); - nsp->Types->Add( testType ); - - // - // This example demonstrates declaring a public constant type member field. - - // When declaring a public constant type member field, you must set a particular - // access and scope mask to the member attributes of the field in order for the - // code generator to properly generate the field as a constant field. - - // Declares an integer field using a CodeMemberField - CodeMemberField^ constPublicField = gcnew CodeMemberField( int::typeid,"testConstPublicField" ); - - // Resets the access and scope mask bit flags of the member attributes of the field - // before setting the member attributes of the field to public and constant. - constPublicField->Attributes = (MemberAttributes)((constPublicField->Attributes & ~MemberAttributes::AccessMask & ~MemberAttributes::ScopeMask) | MemberAttributes::Public | MemberAttributes::Const); - // - - testType->Members->Add( constPublicField ); - return cu; - } - }; -} diff --git a/snippets/cpp/VS_Snippets_CLR/CodeMemberMethodExample/CPP/codemembermethodexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeMemberMethodExample/CPP/codemembermethodexample.cpp deleted file mode 100644 index 8175a5921e6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeMemberMethodExample/CPP/codemembermethodexample.cpp +++ /dev/null @@ -1,37 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSamples -{ - public ref class CodeMemberMethodExample - { - public: - CodeMemberMethodExample() - { - - // - // Defines a method that returns a string passed to it. - CodeMemberMethod^ method1 = gcnew CodeMemberMethod; - method1->Name = "ReturnString"; - method1->ReturnType = gcnew CodeTypeReference( "System.String" ); - method1->Parameters->Add( gcnew CodeParameterDeclarationExpression( "System.String","text" ) ); - method1->Statements->Add( gcnew CodeMethodReturnStatement( gcnew CodeArgumentReferenceExpression( "text" ) ) ); - - // A C# code generator produces the following source code for the preceeding example code: - // private string ReturnString(string text) - // { - // return text; - // } - // - } - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeMemberPropertyExample/CPP/codememberpropertyexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeMemberPropertyExample/CPP/codememberpropertyexample.cpp deleted file mode 100644 index 7e2bc0cca2b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeMemberPropertyExample/CPP/codememberpropertyexample.cpp +++ /dev/null @@ -1,95 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSamples -{ - public ref class CodeMemberPropertyExample - { - public: - CodeMemberPropertyExample() - { - - // - // Declares a type to contain a field and a constructor method. - CodeTypeDeclaration^ type1 = gcnew CodeTypeDeclaration( "PropertyTest" ); - - // Declares a field of type String named testStringField. - CodeMemberField^ field1 = gcnew CodeMemberField( "System.String","testStringField" ); - type1->Members->Add( field1 ); - - // Declares a property of type String named StringProperty. - CodeMemberProperty^ property1 = gcnew CodeMemberProperty; - property1->Name = "StringProperty"; - property1->Type = gcnew CodeTypeReference( "System.String" ); - property1->Attributes = MemberAttributes::Public; - property1->GetStatements->Add( gcnew CodeMethodReturnStatement( gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"testStringField" ) ) ); - property1->SetStatements->Add( gcnew CodeAssignStatement( gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"testStringField" ),gcnew CodePropertySetValueReferenceExpression ) ); - type1->Members->Add( property1 ); - - // Declares an empty type constructor. - CodeConstructor^ constructor1 = gcnew CodeConstructor; - constructor1->Attributes = MemberAttributes::Public; - type1->Members->Add( constructor1 ); - - // A C# code generator produces the following source code for the preceeding example code: - // public class PropertyTest - // { - // - // private string testStringField; - // - // public PropertyTest() - // { - // } - // - // public virtual string StringProperty - // { - // get - // { - // return this.testStringField; - // } - // set - // { - // this.testStringField = value; - // } - // } - // } - // - } - - void SpecificExample() - { - - // - // Declares a property of type String named StringProperty. - CodeMemberProperty^ property1 = gcnew CodeMemberProperty; - property1->Name = "StringProperty"; - property1->Type = gcnew CodeTypeReference( "System.String" ); - property1->Attributes = MemberAttributes::Public; - property1->GetStatements->Add( gcnew CodeMethodReturnStatement( gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"testStringField" ) ) ); - property1->SetStatements->Add( gcnew CodeAssignStatement( gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"testStringField" ),gcnew CodePropertySetValueReferenceExpression ) ); - - // A C# code generator produces the following source code for the preceeding example code: - // public virtual string StringProperty - // { - // get - // { - // return this.testStringField; - // } - // set - // { - // this.testStringField = value; - // } - // } - // - } - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeMethodInvokeExpression/CPP/codemethodinvokeexpressionexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeMethodInvokeExpression/CPP/codemethodinvokeexpressionexample.cpp deleted file mode 100644 index e6f645922d9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeMethodInvokeExpression/CPP/codemethodinvokeexpressionexample.cpp +++ /dev/null @@ -1,32 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSamples -{ - public ref class CodeMethodInvokeExpressionExample - { - public: - CodeMethodInvokeExpressionExample() - { - - // - array^temp0 = {gcnew CodePrimitiveExpression( true )}; - - // parameters array contains the parameters for the method. - CodeMethodInvokeExpression^ methodInvoke = gcnew CodeMethodInvokeExpression( gcnew CodeThisReferenceExpression,"Dispose",temp0 ); - - // A C# code generator produces the following source code for the preceeding example code: - // this.Dispose(true); - // - } - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeMethodReferenceExample/CPP/codemethodreferenceexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeMethodReferenceExample/CPP/codemethodreferenceexample.cpp deleted file mode 100644 index 5bb3d9a74c0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeMethodReferenceExample/CPP/codemethodreferenceexample.cpp +++ /dev/null @@ -1,53 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; -public ref class CodeMethodReferenceExample -{ -public: - CodeMethodReferenceExample() - { - - // - // Declares a type to contain the example code. - CodeTypeDeclaration^ type1 = gcnew CodeTypeDeclaration( "Type1" ); - - // Declares a method. - CodeMemberMethod^ method1 = gcnew CodeMemberMethod; - method1->Name = "TestMethod"; - type1->Members->Add( method1 ); - - // Declares a type constructor that calls a method. - CodeConstructor^ constructor1 = gcnew CodeConstructor; - constructor1->Attributes = MemberAttributes::Public; - type1->Members->Add( constructor1 ); - - // Invokes the TestMethod method of the current type object. - CodeMethodReferenceExpression^ methodRef1 = gcnew CodeMethodReferenceExpression( gcnew CodeThisReferenceExpression,"TestMethod" ); - array^temp0; - CodeMethodInvokeExpression^ invoke1 = gcnew CodeMethodInvokeExpression( methodRef1,temp0 ); - constructor1->Statements->Add( invoke1 ); - - // - } - - void InvokeExample() - { - - // - // Invokes the TestMethod method of the current type object. - CodeMethodReferenceExpression^ methodRef1 = gcnew CodeMethodReferenceExpression( gcnew CodeThisReferenceExpression,"TestMethod" ); - array^temp1; - CodeMethodInvokeExpression^ invoke1 = gcnew CodeMethodInvokeExpression( methodRef1,temp1 ); - - // A C# code generator produces the following source code for the preceeding example code: - // this.TestMethod(); - // - } - -}; - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeMultiExample/CPP/codemultiexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeMultiExample/CPP/codemultiexample.cpp deleted file mode 100644 index 038d748adc7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeMultiExample/CPP/codemultiexample.cpp +++ /dev/null @@ -1,66 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; -public ref class CodeMultiExample -{ -public: - CodeMultiExample(){} - - void CodeEventReferenceExample() - { - - // - // Represents a reference to an event. - CodeEventReferenceExpression^ eventRef1 = gcnew CodeEventReferenceExpression( gcnew CodeThisReferenceExpression,"TestEvent" ); - - // A C# code generator produces the following source code for the preceeding example code: - // this.TestEvent - // - } - - void CodeIndexerExample() - { - - // - array^temp1 = {gcnew CodePrimitiveExpression( 1 )}; - System::CodeDom::CodeIndexerExpression^ indexerExpression = gcnew CodeIndexerExpression( gcnew CodeThisReferenceExpression,temp1 ); - - // A C# code generator produces the following source code for the preceeding example code: - // this[1]; - // - } - - void CodeDirectionExample() - { - - // - // Declares a parameter passed by reference using a CodeDirectionExpression. - array^param1 = {gcnew CodeDirectionExpression( FieldDirection::Ref,gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"TestParameter" ) )}; - - // Invokes a method on this named TestMethod using the direction expression as a parameter. - CodeMethodInvokeExpression^ methodInvoke1 = gcnew CodeMethodInvokeExpression( gcnew CodeThisReferenceExpression,"TestMethod",param1 ); - - // A C# code generator produces the following source code for the preceeding example code: - // this.TestMethod(ref TestParameter); - // - } - - void CreateExpressionExample() - { - - // - array^temp0 = gcnew array(0); - CodeObjectCreateExpression^ objectCreate1 = gcnew CodeObjectCreateExpression( "System.DateTime",temp0 ); - - // A C# code generator produces the following source code for the preceeding example code: - // new System.DateTime(); - // - } - -}; - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeNamespaceCollectionExample/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/CodeNamespaceCollectionExample/CPP/class1.cpp deleted file mode 100644 index 1fa3cdbea7d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeNamespaceCollectionExample/CPP/class1.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeNamespaceCollectionExample -{ - public ref class Class1 - { - public: - Class1(){} - - // CodeNamespaceCollection - void CodeNamespaceCollectionExample() - { - // - // - // Creates an empty CodeNamespaceCollection. - CodeNamespaceCollection^ collection = gcnew CodeNamespaceCollection; - // - - // - // Adds a CodeNamespace to the collection. - collection->Add( gcnew CodeNamespace( "TestNamespace" ) ); - // - - // - // Adds an array of CodeNamespace objects to the collection. - array^namespaces = {gcnew CodeNamespace( "TestNamespace1" ),gcnew CodeNamespace( "TestNamespace2" )}; - collection->AddRange( namespaces ); - - // Adds a collection of CodeNamespace objects to the collection. - CodeNamespaceCollection^ namespacesCollection = gcnew CodeNamespaceCollection; - namespacesCollection->Add( gcnew CodeNamespace( "TestNamespace1" ) ); - namespacesCollection->Add( gcnew CodeNamespace( "TestNamespace2" ) ); - collection->AddRange( namespacesCollection ); - // - - // - // Tests for the presence of a CodeNamespace in the collection, - // and retrieves its index if it is found. - CodeNamespace^ testNamespace = gcnew CodeNamespace( "TestNamespace" ); - int itemIndex = -1; - if ( collection->Contains( testNamespace ) ) - itemIndex = collection->IndexOf( testNamespace ); - // - - // - // Copies the contents of the collection beginning at index 0, - // to the specified CodeNamespace array. - // 'namespaces' is a CodeNamespace array. - collection->CopyTo( namespaces, 0 ); - // - - // - // Retrieves the count of the items in the collection. - int collectionCount = collection->Count; - // - - // - // Inserts a CodeNamespace at index 0 of the collection. - collection->Insert( 0, gcnew CodeNamespace( "TestNamespace" ) ); - // - - // - // Removes the specified CodeNamespace from the collection. - CodeNamespace^ namespace_ = gcnew CodeNamespace( "TestNamespace" ); - collection->Remove( namespace_ ); - // - - // - // Removes the CodeNamespace at index 0. - collection->RemoveAt( 0 ); - // - // - } - }; -} diff --git a/snippets/cpp/VS_Snippets_CLR/CodeNamespaceExample/CPP/codenamespaceexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeNamespaceExample/CPP/codenamespaceexample.cpp deleted file mode 100644 index e2d0cf27fab..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeNamespaceExample/CPP/codenamespaceexample.cpp +++ /dev/null @@ -1,32 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSamples -{ - public ref class CodeMemberEventExample - { - public: - CodeMemberEventExample() - { - - // - CodeCompileUnit^ compileUnit = gcnew CodeCompileUnit; - CodeNamespace^ namespace1 = gcnew CodeNamespace( "TestNamespace" ); - compileUnit->Namespaces->Add( namespace1 ); - - // A C# code generator produces the following source code for the preceeding example code: - // namespace TestNamespace { - // } - // - } - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeNamespaceImportExample/CPP/codenamespaceimportexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeNamespaceImportExample/CPP/codenamespaceimportexample.cpp deleted file mode 100644 index ac420b30839..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeNamespaceImportExample/CPP/codenamespaceimportexample.cpp +++ /dev/null @@ -1,45 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSamples -{ - public ref class CodeNamespaceImportExample - { - public: - CodeNamespaceImportExample() - { - - // - // Declares a compile unit to contain a namespace. - CodeCompileUnit^ compileUnit = gcnew CodeCompileUnit; - - // Declares a namespace named TestNamespace. - CodeNamespace^ testNamespace = gcnew CodeNamespace( "TestNamespace" ); - - // Adds the namespace to the namespace collection of the compile unit. - compileUnit->Namespaces->Add( testNamespace ); - - // Declares a namespace import of the System namespace. - CodeNamespaceImport^ import1 = gcnew CodeNamespaceImport( "System" ); - - // Adds the namespace import to the namespace imports collection of the namespace. - testNamespace->Imports->Add( import1 ); - - // A C# code generator produces the following source code for the preceeding example code: - // namespace TestNamespace { - // using System; - // - // } - // - } - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeParameterDeclarationExample/CPP/codeparameterdeclarationexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeParameterDeclarationExample/CPP/codeparameterdeclarationexample.cpp deleted file mode 100644 index 8e07b2222f8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeParameterDeclarationExample/CPP/codeparameterdeclarationexample.cpp +++ /dev/null @@ -1,52 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSamples -{ - public ref class CodeParameterDeclarationExample - { - public: - CodeParameterDeclarationExample() - { - - // - // Declares a new type to contain the example methods. - CodeTypeDeclaration^ type1 = gcnew CodeTypeDeclaration( "Type1" ); - CodeConstructor^ constructor1 = gcnew CodeConstructor; - constructor1->Attributes = MemberAttributes::Public; - type1->Members->Add( constructor1 ); - - // - // Declares a method. - CodeMemberMethod^ method1 = gcnew CodeMemberMethod; - method1->Name = "TestMethod"; - - // Declares a string parameter passed by reference. - CodeParameterDeclarationExpression^ param1 = gcnew CodeParameterDeclarationExpression( "System.String","stringParam" ); - param1->Direction = FieldDirection::Ref; - method1->Parameters->Add( param1 ); - - // Declares a Int32 parameter passed by incoming field. - CodeParameterDeclarationExpression^ param2 = gcnew CodeParameterDeclarationExpression( "System.Int32","intParam" ); - param2->Direction = FieldDirection::Out; - method1->Parameters->Add( param2 ); - - // A C# code generator produces the following source code for the preceeding example code: - // private void TestMethod(ref string stringParam, out int intParam) { - // } - // - type1->Members->Add( method1 ); - - // - } - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/CPP/class1.cpp deleted file mode 100644 index 3b66a3fe5b6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/CPP/class1.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeParameterDeclarationExpressionCollectionExample -{ - public ref class Class1 - { - public: - Class1(){} - - // CodeParameterDeclarationExpressionCollection - void CodeParameterDeclarationExpressionCollectionExample() - { - // - // - // Creates an empty CodeParameterDeclarationExpressionCollection. - CodeParameterDeclarationExpressionCollection^ collection = gcnew CodeParameterDeclarationExpressionCollection; - // - - // - // Adds a CodeParameterDeclarationExpression to the collection. - collection->Add( gcnew CodeParameterDeclarationExpression( int::typeid,"testIntArgument" ) ); - // - - // - // Adds an array of CodeParameterDeclarationExpression objects - // to the collection. - array^parameters = {gcnew CodeParameterDeclarationExpression( int::typeid,"testIntArgument" ),gcnew CodeParameterDeclarationExpression( bool::typeid,"testBoolArgument" )}; - collection->AddRange( parameters ); - - // Adds a collection of CodeParameterDeclarationExpression objects - // to the collection. - CodeParameterDeclarationExpressionCollection^ parametersCollection = gcnew CodeParameterDeclarationExpressionCollection; - parametersCollection->Add( gcnew CodeParameterDeclarationExpression( int::typeid,"testIntArgument" ) ); - parametersCollection->Add( gcnew CodeParameterDeclarationExpression( bool::typeid,"testBoolArgument" ) ); - collection->AddRange( parametersCollection ); - // - - // - // Tests for the presence of a CodeParameterDeclarationExpression - // in the collection, and retrieves its index if it is found. - CodeParameterDeclarationExpression^ testParameter = gcnew CodeParameterDeclarationExpression( int::typeid,"testIntArgument" ); - int itemIndex = -1; - if ( collection->Contains( testParameter ) ) - itemIndex = collection->IndexOf( testParameter ); - // - - // - // Copies the contents of the collection beginning at index 0 to the specified CodeParameterDeclarationExpression array. - // 'parameters' is a CodeParameterDeclarationExpression array. - collection->CopyTo( parameters, 0 ); - // - - // - // Retrieves the count of the items in the collection. - int collectionCount = collection->Count; - // - - // - // Inserts a CodeParameterDeclarationExpression at index 0 - // of the collection. - collection->Insert( 0, gcnew CodeParameterDeclarationExpression( int::typeid,"testIntArgument" ) ); - // - - // - // Removes the specified CodeParameterDeclarationExpression - // from the collection. - CodeParameterDeclarationExpression^ parameter = gcnew CodeParameterDeclarationExpression( int::typeid,"testIntArgument" ); - collection->Remove( parameter ); - // - - // - // Removes the CodeParameterDeclarationExpression at index 0. - collection->RemoveAt( 0 ); - // - // - } - }; -} diff --git a/snippets/cpp/VS_Snippets_CLR/CodePrimitiveExpressionExample/CPP/codeprimitiveexpressionexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodePrimitiveExpressionExample/CPP/codeprimitiveexpressionexample.cpp deleted file mode 100644 index 9056a9d5683..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodePrimitiveExpressionExample/CPP/codeprimitiveexpressionexample.cpp +++ /dev/null @@ -1,37 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSamples -{ - public ref class CodePrimitiveExpressionExample - { - public: - CodePrimitiveExpressionExample() - { - - // - // Represents a string. - CodePrimitiveExpression^ stringPrimitive = gcnew CodePrimitiveExpression( "Test String" ); - - // Represents an integer. - CodePrimitiveExpression^ intPrimitive = gcnew CodePrimitiveExpression( 10 ); - - // Represents a floating point number. - CodePrimitiveExpression^ floatPrimitive = gcnew CodePrimitiveExpression( 1.03189 ); - - // Represents a null value expression. - CodePrimitiveExpression^ nullPrimitive = gcnew CodePrimitiveExpression( 0 ); - - // - } - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodePropertySetValueExample/CPP/codepropertysetvalueexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodePropertySetValueExample/CPP/codepropertysetvalueexample.cpp deleted file mode 100644 index 6a937caac58..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodePropertySetValueExample/CPP/codepropertysetvalueexample.cpp +++ /dev/null @@ -1,70 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSamples -{ - public ref class CodePropertySetValueExample - { - public: - CodePropertySetValueExample() - { - - // - // Declares a type. - CodeTypeDeclaration^ type1 = gcnew CodeTypeDeclaration( "Type1" ); - - // Declares a constructor. - CodeConstructor^ constructor1 = gcnew CodeConstructor; - constructor1->Attributes = MemberAttributes::Public; - type1->Members->Add( constructor1 ); - - // Declares an integer field. - CodeMemberField^ field1 = gcnew CodeMemberField( "System.Int32","integerField" ); - type1->Members->Add( field1 ); - - // Declares a property. - CodeMemberProperty^ property1 = gcnew CodeMemberProperty; - - // Declares a property get statement to return the value of the integer field. - property1->GetStatements->Add( gcnew CodeMethodReturnStatement( gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"integerField" ) ) ); - - // Declares a property set statement to set the value to the integer field. - // The CodePropertySetValueReferenceExpression represents the value argument passed to the property set statement. - property1->SetStatements->Add( gcnew CodeAssignStatement( gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"integerField" ),gcnew CodePropertySetValueReferenceExpression ) ); - type1->Members->Add( property1 ); - - // A C# code generator produces the following source code for the preceeding example code: - // public class Type1 - // { - // - // private int integerField; - // - // public Type1() - // { - // } - // - // private int integerProperty - // { - // get - // { - // return this.integerField; - // } - // set - // { - // this.integerField = value; - // } - // } - // } - // - } - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeReferenceExample/CPP/codereferenceexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeReferenceExample/CPP/codereferenceexample.cpp deleted file mode 100644 index b6dcd099dd2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeReferenceExample/CPP/codereferenceexample.cpp +++ /dev/null @@ -1,53 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSamples -{ - public ref class CodeReferenceExample - { - public: - CodeReferenceExample(){} - - void CodeFieldReferenceExample() - { - - // - CodeFieldReferenceExpression^ fieldRef1 = gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"TestField" ); - - // A C# code generator produces the following source code for the preceeding example code: - // this.TestField - // - } - - void CodePropertyReferenceExample() - { - - // - CodePropertyReferenceExpression^ propertyRef1 = gcnew CodePropertyReferenceExpression( gcnew CodeThisReferenceExpression,"TestProperty" ); - - // A C# code generator produces the following source code for the preceeding example code: - // this.TestProperty - // - } - - void CodeVariableReferenceExample() - { - - // - CodeVariableReferenceExpression^ variableRef1 = gcnew CodeVariableReferenceExpression( "TestVariable" ); - - // A C# code generator produces the following source code for the preceeding example code: - // TestVariable - // - } - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeRemoveEventExample/CPP/coderemoveeventexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeRemoveEventExample/CPP/coderemoveeventexample.cpp deleted file mode 100644 index 4f5f9c70446..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeRemoveEventExample/CPP/coderemoveeventexample.cpp +++ /dev/null @@ -1,33 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSamples -{ - public ref class CodeRemoveEventExample - { - public: - CodeRemoveEventExample() - { - - // - // Creates a delegate of type System.EventHandler pointing to a method named OnMouseEnter. - CodeDelegateCreateExpression^ mouseEnterDelegate = gcnew CodeDelegateCreateExpression( gcnew CodeTypeReference( "System.EventHandler" ),gcnew CodeThisReferenceExpression,"OnMouseEnter" ); - - // Creates a remove event statement that removes the delegate from the TestEvent event. - CodeRemoveEventStatement^ removeEvent1 = gcnew CodeRemoveEventStatement( gcnew CodeThisReferenceExpression,"TestEvent",mouseEnterDelegate ); - - // A C# code generator produces the following source code for the preceeding example code: - // this.TestEvent -= new System.EventHandler(this.OnMouseEnter); - // - } - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeStatementCollectionExample/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/CodeStatementCollectionExample/CPP/class1.cpp deleted file mode 100644 index 03265e75e7f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeStatementCollectionExample/CPP/class1.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeStatementCollectionExample -{ - public ref class Class1 - { - public: - Class1(){} - - // CodeStatementCollection - void CodeStatementCollectionExample() - { - - // - // - // Creates an empty CodeStatementCollection. - CodeStatementCollection^ collection = gcnew CodeStatementCollection; - // - - // - // Adds a CodeStatement to the collection. - collection->Add( gcnew CodeCommentStatement( "Test comment statement" ) ); - // - - // - // Adds an array of CodeStatement objects to the collection. - array^statements = {gcnew CodeCommentStatement( "Test comment statement" ),gcnew CodeCommentStatement( "Test comment statement" )}; - collection->AddRange( statements ); - - // Adds a collection of CodeStatement objects to the collection. - CodeStatement^ testStatement = gcnew CodeCommentStatement( "Test comment statement" ); - CodeStatementCollection^ statementsCollection = gcnew CodeStatementCollection; - statementsCollection->Add( gcnew CodeCommentStatement( "Test comment statement" ) ); - statementsCollection->Add( gcnew CodeCommentStatement( "Test comment statement" ) ); - statementsCollection->Add( testStatement ); - collection->AddRange( statementsCollection ); - // - - // - // Tests for the presence of a CodeStatement in the - // collection, and retrieves its index if it is found. - int itemIndex = -1; - if ( collection->Contains( testStatement ) ) - itemIndex = collection->IndexOf( testStatement ); - // - - // - // Copies the contents of the collection beginning at index 0 to the specified CodeStatement array. - // 'statements' is a CodeStatement array. - collection->CopyTo( statements, 0 ); - // - - // - // Retrieves the count of the items in the collection. - int collectionCount = collection->Count; - // - - // - // Inserts a CodeStatement at index 0 of the collection. - collection->Insert( 0, gcnew CodeCommentStatement( "Test comment statement" ) ); - // - - // - // Removes the specified CodeStatement from the collection. - collection->Remove( testStatement ); - // - - // - // Removes the CodeStatement at index 0. - collection->RemoveAt( 0 ); - // - // - } - }; -} diff --git a/snippets/cpp/VS_Snippets_CLR/CodeThrowExceptionStatement/CPP/codethrowexceptionstatementexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeThrowExceptionStatement/CPP/codethrowexceptionstatementexample.cpp deleted file mode 100644 index 54009857661..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeThrowExceptionStatement/CPP/codethrowexceptionstatementexample.cpp +++ /dev/null @@ -1,24 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -public ref class CodeThrowExceptionStatementExample -{ -public: - CodeThrowExceptionStatementExample() - { - // - // This CodeThrowExceptionStatement throws a new System.Exception. - array^temp0; - CodeThrowExceptionStatement^ throwException = gcnew CodeThrowExceptionStatement( gcnew CodeObjectCreateExpression( gcnew CodeTypeReference( System::Exception::typeid ),temp0 ) ); - - // A C# code generator produces the following source code for the preceeding example code: - // throw new System.Exception(); - // - } -}; -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeTryCatchFinallyExample/CPP/codetrycatchfinallyexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeTryCatchFinallyExample/CPP/codetrycatchfinallyexample.cpp deleted file mode 100644 index cb97225e885..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeTryCatchFinallyExample/CPP/codetrycatchfinallyexample.cpp +++ /dev/null @@ -1,81 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; -public ref class CodeTryCatchFinallyExample -{ -public: - CodeTryCatchFinallyExample() - { - - // - // Declares a type to contain a try...catch block. - CodeTypeDeclaration^ type1 = gcnew CodeTypeDeclaration( "TryCatchTest" ); - - // Defines a method that throws an exception of type System.ApplicationException. - CodeMemberMethod^ method1 = gcnew CodeMemberMethod; - method1->Name = "ThrowApplicationException"; - array^temp = {gcnew CodePrimitiveExpression( "Test Application Exception" )}; - method1->Statements->Add( gcnew CodeThrowExceptionStatement( gcnew CodeObjectCreateExpression( "System.ApplicationException",temp ) ) ); - type1->Members->Add( method1 ); - - // Defines a constructor that calls the ThrowApplicationException method from a try block. - CodeConstructor^ constructor1 = gcnew CodeConstructor; - constructor1->Attributes = MemberAttributes::Public; - type1->Members->Add( constructor1 ); - - // Defines a try statement that calls the ThrowApplicationException method. - CodeTryCatchFinallyStatement^ try1 = gcnew CodeTryCatchFinallyStatement; - try1->TryStatements->Add( gcnew CodeMethodInvokeExpression( gcnew CodeThisReferenceExpression,"ThrowApplicationException", nullptr ) ); - constructor1->Statements->Add( try1 ); - - // Defines a catch clause for exceptions of type ApplicationException. - CodeCatchClause^ catch1 = gcnew CodeCatchClause( "ex",gcnew CodeTypeReference( "System.ApplicationException" ) ); - catch1->Statements->Add( gcnew CodeCommentStatement( "Handle any System.ApplicationException here." ) ); - try1->CatchClauses->Add( catch1 ); - - // Defines a catch clause for any remaining unhandled exception types. - CodeCatchClause^ catch2 = gcnew CodeCatchClause( "ex" ); - catch2->Statements->Add( gcnew CodeCommentStatement( "Handle any other exception type here." ) ); - try1->CatchClauses->Add( catch2 ); - - // Defines a finally block by adding to the FinallyStatements collection. - try1->FinallyStatements->Add( gcnew CodeCommentStatement( "Handle any finally block statements." ) ); - - // A C# code generator produces the following source code for the preceeding example code: - // public class TryCatchTest - // { - // - // public TryCatchTest() - // { - // try - // { - // this.ThrowApplicationException(); - // } - // catch (System.ApplicationException ex) - // { - // // Handle any System.ApplicationException here. - // } - // catch (System.Exception ex) - // { - // // Handle any other exception type here. - // } - // finally { - // // Handle any finally block statements. - // } - // } - // - // private void ThrowApplicationException() - // { - // throw new System.ApplicationException("Test Application Exception"); - // } - // } - // - } - -}; - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeTypeConstructorExample/CPP/codetypeconstructorexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeTypeConstructorExample/CPP/codetypeconstructorexample.cpp deleted file mode 100644 index aefa0b83158..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeTypeConstructorExample/CPP/codetypeconstructorexample.cpp +++ /dev/null @@ -1,42 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSamples -{ - public ref class CodeTypeConstructorExample - { - public: - CodeTypeConstructorExample() - { - - // - // Declares a new type for a static constructor. - CodeTypeDeclaration^ type1 = gcnew CodeTypeDeclaration( "Type1" ); - - // Declares a static constructor. - CodeTypeConstructor^ constructor2 = gcnew CodeTypeConstructor; - - // Adds the static constructor to the type. - type1->Members->Add( constructor2 ); - - // A C# code generator produces the following source code for the preceeding example code: - // public class Type1 - // { - // - // static Type1() - // { - // } - // } - // - } - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/CPP/class1.cpp deleted file mode 100644 index eb0a71bdaee..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/CPP/class1.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeTypeDeclarationCollectionExample -{ - public ref class Class1 - { - public: - Class1(){} - - // CodeTypeDeclarationCollection - void CodeTypeDeclarationCollectionExample() - { - - // - // - // Creates an empty CodeTypeDeclarationCollection. - CodeTypeDeclarationCollection^ collection = gcnew CodeTypeDeclarationCollection; - // - - // - // Adds a CodeTypeDeclaration to the collection. - collection->Add( gcnew CodeTypeDeclaration( "TestType" ) ); - // - - // - // Adds an array of CodeTypeDeclaration objects to the collection. - array^declarations = {gcnew CodeTypeDeclaration( "TestType1" ),gcnew CodeTypeDeclaration( "TestType2" )}; - collection->AddRange( declarations ); - - // Adds a collection of CodeTypeDeclaration objects to the - // collection. - CodeTypeDeclarationCollection^ declarationsCollection = gcnew CodeTypeDeclarationCollection; - declarationsCollection->Add( gcnew CodeTypeDeclaration( "TestType1" ) ); - declarationsCollection->Add( gcnew CodeTypeDeclaration( "TestType2" ) ); - collection->AddRange( declarationsCollection ); - // - - // - // Tests for the presence of a CodeTypeDeclaration in the - // collection, and retrieves its index if it is found. - CodeTypeDeclaration^ testDeclaration = gcnew CodeTypeDeclaration( "TestType" ); - int itemIndex = -1; - if ( collection->Contains( testDeclaration ) ) - itemIndex = collection->IndexOf( testDeclaration ); - // - - // - // Copies the contents of the collection, beginning at index 0, - // to the specified CodeTypeDeclaration array. - // 'declarations' is a CodeTypeDeclaration array. - collection->CopyTo( declarations, 0 ); - // - - // - // Retrieves the count of the items in the collection. - int collectionCount = collection->Count; - // - - // - // Inserts a CodeTypeDeclaration at index 0 of the collection. - collection->Insert( 0, gcnew CodeTypeDeclaration( "TestType" ) ); - // - - // - // Removes the specified CodeTypeDeclaration from the collection. - CodeTypeDeclaration^ declaration = gcnew CodeTypeDeclaration( "TestType" ); - collection->Remove( declaration ); - // - - // - // Removes the CodeTypeDeclaration at index 0. - collection->RemoveAt( 0 ); - // - // - } - }; -} diff --git a/snippets/cpp/VS_Snippets_CLR/CodeTypeDeclarationExample/CPP/codetypedeclarationexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeTypeDeclarationExample/CPP/codetypedeclarationexample.cpp deleted file mode 100644 index ac817d9918f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeTypeDeclarationExample/CPP/codetypedeclarationexample.cpp +++ /dev/null @@ -1,41 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::Reflection; - -namespace CodeDomSamples -{ - public ref class CodeTypeDeclarationExample - { - public: - CodeTypeDeclarationExample() - { - - // - // Creates a new type declaration. - - // name parameter indicates the name of the type. - CodeTypeDeclaration^ newType = gcnew CodeTypeDeclaration( "TestType" ); - - // Sets the member attributes for the type to private. - newType->Attributes = MemberAttributes::Private; - - // Sets a base class which the type inherits from. - newType->BaseTypes->Add( "BaseType" ); - - // A C# code generator produces the following source code for the preceeding example code: - // class TestType : BaseType - // { - // } - // - } - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeTypeDelegateExample/CPP/codetypedelegateexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeTypeDelegateExample/CPP/codetypedelegateexample.cpp deleted file mode 100644 index 79266531f92..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeTypeDelegateExample/CPP/codetypedelegateexample.cpp +++ /dev/null @@ -1,78 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSamples -{ - public ref class CodeTypeDelegateExample - { - public: - CodeTypeDelegateExample() - { - - // - // Declares a type to contain the delegate and constructor method. - CodeTypeDeclaration^ type1 = gcnew CodeTypeDeclaration( "DelegateTest" ); - - // Declares an event that accepts a custom delegate type of "TestDelegate". - CodeMemberEvent^ event1 = gcnew CodeMemberEvent; - event1->Name = "TestEvent"; - event1->Type = gcnew CodeTypeReference( "DelegateTest.TestDelegate" ); - type1->Members->Add( event1 ); - - // - // Declares a delegate type called TestDelegate with an EventArgs parameter. - CodeTypeDelegate^ delegate1 = gcnew CodeTypeDelegate( "TestDelegate" ); - delegate1->Parameters->Add( gcnew CodeParameterDeclarationExpression( "System.Object","sender" ) ); - delegate1->Parameters->Add( gcnew CodeParameterDeclarationExpression( "System.EventArgs","e" ) ); - - // A C# code generator produces the following source code for the preceeding example code: - // public delegate void TestDelegate(object sender, System.EventArgs e); - // - type1->Members->Add( delegate1 ); - - // Declares a method that matches the "TestDelegate" method signature. - CodeMemberMethod^ method1 = gcnew CodeMemberMethod; - method1->Name = "TestMethod"; - method1->Parameters->Add( gcnew CodeParameterDeclarationExpression( "System.Object","sender" ) ); - method1->Parameters->Add( gcnew CodeParameterDeclarationExpression( "System.EventArgs","e" ) ); - type1->Members->Add( method1 ); - - // Defines a constructor that attaches a TestDelegate delegate pointing to the TestMethod method - // to the TestEvent event. - CodeConstructor^ constructor1 = gcnew CodeConstructor; - constructor1->Attributes = MemberAttributes::Public; - CodeDelegateCreateExpression^ createDelegate1 = gcnew CodeDelegateCreateExpression( gcnew CodeTypeReference( "DelegateTest.TestDelegate" ),gcnew CodeThisReferenceExpression,"TestMethod" ); - CodeAttachEventStatement^ attachStatement1 = gcnew CodeAttachEventStatement( gcnew CodeThisReferenceExpression,"TestEvent",createDelegate1 ); - constructor1->Statements->Add( attachStatement1 ); - type1->Members->Add( constructor1 ); - - // A C# code generator produces the following source code for the preceeding example code: - // public class DelegateTest - // { - // - // public DelegateTest() - // { - // this.TestEvent += new DelegateTest.TestDelegate(this.TestMethod); - // } - // - // private event DelegateTest.TestDelegate TestEvent; - // - // private void TestMethod(object sender, System.EventArgs e) - // { - // } - // - // public delegate void TestDelegate(object sender, System.EventArgs e); - // } - // - } - - }; - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CodeTypeMemberCollectionExample/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/CodeTypeMemberCollectionExample/CPP/class1.cpp deleted file mode 100644 index 764de1a8a1d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeTypeMemberCollectionExample/CPP/class1.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeTypeMemberCollectionExample -{ - public ref class Class1 - { - public: - Class1(){} - - // CodeTypeMemberCollection - void CodeTypeMemberCollectionExample() - { - - // - // - // Creates an empty CodeTypeMemberCollection. - CodeTypeMemberCollection^ collection = gcnew CodeTypeMemberCollection; - // - - // - // Adds a CodeTypeMember to the collection. - collection->Add( gcnew CodeMemberField( "System.String","TestStringField" ) ); - // - - // - // Adds an array of CodeTypeMember objects to the collection. - array^members = {gcnew CodeMemberField( "System.String","TestStringField1" ),gcnew CodeMemberField( "System.String","TestStringField2" )}; - collection->AddRange( members ); - - // Adds a collection of CodeTypeMember objects to the collection. - CodeTypeMemberCollection^ membersCollection = gcnew CodeTypeMemberCollection; - membersCollection->Add( gcnew CodeMemberField( "System.String","TestStringField1" ) ); - membersCollection->Add( gcnew CodeMemberField( "System.String","TestStringField2" ) ); - collection->AddRange( membersCollection ); - // - - // - // Tests for the presence of a CodeTypeMember in the collection, - // and retrieves its index if it is found. - CodeTypeMember^ testMember = gcnew CodeMemberField( "System.String","TestStringField" ); - int itemIndex = -1; - if ( collection->Contains( testMember ) ) - itemIndex = collection->IndexOf( testMember ); - // - - // - // Copies the contents of the collection, beginning at index 0, - // to the specified CodeTypeMember array. - // 'members' is a CodeTypeMember array. - collection->CopyTo( members, 0 ); - // - - // - // Retrieves the count of the items in the collection. - int collectionCount = collection->Count; - // - - // - // Inserts a CodeTypeMember at index 0 of the collection. - collection->Insert( 0, gcnew CodeMemberField( "System.String","TestStringField" ) ); - // - - // - // Removes the specified CodeTypeMember from the collection. - CodeTypeMember^ member = gcnew CodeMemberField( "System.String","TestStringField" ); - collection->Remove( member ); - // - - // - // Removes the CodeTypeMember at index 0. - collection->RemoveAt( 0 ); - // - // - } - }; -} diff --git a/snippets/cpp/VS_Snippets_CLR/CodeTypeOfExample/CPP/codetypeofexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeTypeOfExample/CPP/codetypeofexample.cpp deleted file mode 100644 index c1b459722a5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeTypeOfExample/CPP/codetypeofexample.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; - -namespace CodeDomSamples -{ - public ref class CodeTypeOfExample - { - public: - static void Main() - { - ShowTypeReference(); - Console::WriteLine(); - ShowTypeReferenceExpression(); - } - - static void ShowTypeReference() - { - // - // Creates a reference to the System.DateTime type. - CodeTypeReference^ typeRef1 = gcnew CodeTypeReference("System.DateTime"); - - // Creates a typeof expression for the specified type reference. - CodeTypeOfExpression^ typeof1 = gcnew CodeTypeOfExpression(typeRef1); - - // Create a C# code provider - CodeDomProvider^ provider = CodeDomProvider::CreateProvider("CSharp"); - - // Generate code and send the output to the console - provider->GenerateCodeFromExpression(typeof1, Console::Out, gcnew CodeGeneratorOptions()); - // The code generator produces the following source code for the preceeding example code: - // typeof(System.DateTime) - // - } - - static void ShowTypeReferenceExpression() - { - // - // Creates an expression referencing the System.DateTime type. - CodeTypeReferenceExpression^ typeRef1 = gcnew CodeTypeReferenceExpression("System.DateTime"); - - // Create a C# code provider - CodeDomProvider^ provider = CodeDomProvider::CreateProvider("CSharp"); - - // Generate code and send the output to the console - provider->GenerateCodeFromExpression(typeRef1, Console::Out, gcnew CodeGeneratorOptions()); - // The code generator produces the following source code for the preceeding example code: - - // System.DateTime - - // - } - }; -} - -int main() -{ - CodeDomSamples::CodeTypeOfExample::Main(); -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/CodeTypeReferenceCollection/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/CodeTypeReferenceCollection/CPP/class1.cpp deleted file mode 100644 index ab613ec0d11..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeTypeReferenceCollection/CPP/class1.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeTypeReferenceCollectionExample -{ - public ref class Class1 - { - public: - Class1(){} - - // CodeTypeReferenceCollection - void CodeTypeReferenceCollectionExample() - { - // - // - // Creates an empty CodeTypeReferenceCollection. - CodeTypeReferenceCollection^ collection = gcnew CodeTypeReferenceCollection; - // - - // - // Adds a CodeTypeReference to the collection. - collection->Add( gcnew CodeTypeReference( bool::typeid ) ); - // - - // - // Adds an array of CodeTypeReference objects to the collection. - array^references = {gcnew CodeTypeReference( bool::typeid ),gcnew CodeTypeReference( bool::typeid )}; - collection->AddRange( references ); - - // Adds a collection of CodeTypeReference objects to the collection. - CodeTypeReferenceCollection^ referencesCollection = gcnew CodeTypeReferenceCollection; - referencesCollection->Add( gcnew CodeTypeReference( bool::typeid ) ); - referencesCollection->Add( gcnew CodeTypeReference( bool::typeid ) ); - collection->AddRange( referencesCollection ); - // - - // - // Tests for the presence of a CodeTypeReference in the - // collection, and retrieves its index if it is found. - CodeTypeReference^ testReference = gcnew CodeTypeReference( bool::typeid ); - int itemIndex = -1; - if ( collection->Contains( testReference ) ) - itemIndex = collection->IndexOf( testReference ); - // - - // - // Copies the contents of the collection, beginning at index 0, - // to the specified CodeTypeReference array. - // 'references' is a CodeTypeReference array. - collection->CopyTo( references, 0 ); - // - - // - // Retrieves the count of the items in the collection. - int collectionCount = collection->Count; - // - - // - // Inserts a CodeTypeReference at index 0 of the collection. - collection->Insert( 0, gcnew CodeTypeReference( bool::typeid ) ); - // - - // - // Removes the specified CodeTypeReference from the collection. - CodeTypeReference^ reference = gcnew CodeTypeReference( bool::typeid ); - collection->Remove( reference ); - // - - // - // Removes the CodeTypeReference at index 0. - collection->RemoveAt( 0 ); - // - // - } - }; -} diff --git a/snippets/cpp/VS_Snippets_CLR/CodeVariableDeclarationStatementExample/CPP/codevariabledeclarationstatementexample.cpp b/snippets/cpp/VS_Snippets_CLR/CodeVariableDeclarationStatementExample/CPP/codevariabledeclarationstatementexample.cpp deleted file mode 100644 index a97b2b691ab..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CodeVariableDeclarationStatementExample/CPP/codevariabledeclarationstatementexample.cpp +++ /dev/null @@ -1,28 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; - -namespace CodeDomSamples -{ - public ref class CodeVariableDeclarationStatementExample - { - public: - CodeVariableDeclarationStatementExample() - { - // - // Type of the variable to declare. - // Name of the variable to declare. - // Optional initExpression parameter initializes the variable. - CodeVariableDeclarationStatement^ variableDeclaration = gcnew CodeVariableDeclarationStatement( String::typeid,"TestString",gcnew CodePrimitiveExpression( "Testing" ) ); - - // A C# code generator produces the following source code for the preceeding example code: - // string TestString = "Testing"; - // - } - }; -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/CompilerErrorCollectionExample/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/CompilerErrorCollectionExample/CPP/class1.cpp deleted file mode 100644 index 8a41cb9003d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CompilerErrorCollectionExample/CPP/class1.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; - -public ref class Class1 -{ -public: - Class1(){} - - // CompilerErrorCollection - void CompilerErrorCollectionExample() - { - - // - // - // Creates an empty CompilerErrorCollection. - CompilerErrorCollection^ collection = gcnew CompilerErrorCollection; - // - - // - // Adds a CompilerError to the collection. - collection->Add( gcnew CompilerError( "Testfile::cs",5,10,"CS0001","Example error text" ) ); - // - - // - // Adds an array of CompilerError objects to the collection. - array^errors = {gcnew CompilerError( "Testfile.cs",5,10,"CS0001","Example error text" ),gcnew CompilerError( "Testfile::cs",5,10,"CS0001","Example error text" )}; - collection->AddRange( errors ); - - // Adds a collection of CompilerError objects to the collection. - CompilerErrorCollection^ errorsCollection = gcnew CompilerErrorCollection; - errorsCollection->Add( gcnew CompilerError( "Testfile.cs",5,10,"CS0001","Example error text" ) ); - errorsCollection->Add( gcnew CompilerError( "Testfile.cs",5,10,"CS0001","Example error text" ) ); - collection->AddRange( errorsCollection ); - // - - // - // Tests for the presence of a CompilerError in the - // collection, and retrieves its index if it is found. - CompilerError^ testError = gcnew CompilerError( "Testfile.cs",5,10,"CS0001","Example error text" ); - int itemIndex = -1; - if ( collection->Contains( testError ) ) - itemIndex = collection->IndexOf( testError ); - // - - // - // Copies the contents of the collection, beginning at index 0, - // to the specified CompilerError array. - // 'errors' is a CompilerError array. - collection->CopyTo( errors, 0 ); - // - - // - // Retrieves the count of the items in the collection. - int collectionCount = collection->Count; - // - - // - // Inserts a CompilerError at index 0 of the collection. - collection->Insert( 0, gcnew CompilerError( "Testfile.cs",5,10,"CS0001","Example error text" ) ); - // - - // - // Removes the specified CompilerError from the collection. - CompilerError^ error = gcnew CompilerError( "Testfile.cs",5,10,"CS0001","Example error text" ); - collection->Remove( error ); - // - - // - // Removes the CompilerError at index 0. - collection->RemoveAt( 0 ); - // - // - } -}; diff --git a/snippets/cpp/VS_Snippets_CLR/CompilerParametersExample/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/CompilerParametersExample/CPP/source.cpp deleted file mode 100644 index 2ee1d38b759..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CompilerParametersExample/CPP/source.cpp +++ /dev/null @@ -1,234 +0,0 @@ -// The following example builds a CodeDom source graph for a simple -// Hello World program. The source is then saved to a file, -// compiled into an executable, and run. - -// This example is based loosely on the CodeDom example, but its -// primary intent is to illustrate the CompilerParameters class. - -// Notice that the snippet 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 is Whidbey. -#using -// -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; -using namespace System::Collections; -using namespace System::ComponentModel; -using namespace System::IO; -using namespace System::Diagnostics; - -// Build a Hello World program graph using System.CodeDom types. -static CodeCompileUnit^ BuildHelloWorldGraph() -{ - // Create a new CodeCompileUnit to contain the program graph. - CodeCompileUnit^ compileUnit = gcnew CodeCompileUnit; - - // Declare a new namespace called Samples. - CodeNamespace^ samples = gcnew CodeNamespace( "Samples" ); - // Add the new namespace to the compile unit. - compileUnit->Namespaces->Add( samples ); - - // Add the new namespace import for the System namespace. - samples->Imports->Add( gcnew CodeNamespaceImport( "System" ) ); - - // Declare a new type called Class1. - CodeTypeDeclaration^ class1 = gcnew CodeTypeDeclaration( "Class1" ); - // Add the new type to the namespace's type collection. - samples->Types->Add( class1 ); - - // Declare a new code entry point method - CodeEntryPointMethod^ start = gcnew CodeEntryPointMethod; - - // Create a type reference for the System::Console class. - CodeTypeReferenceExpression^ csSystemConsoleType = - gcnew CodeTypeReferenceExpression( "System.Console" ); - - // Build a Console::WriteLine statement. - CodeMethodInvokeExpression^ cs1 = gcnew CodeMethodInvokeExpression( - csSystemConsoleType, "WriteLine", - gcnew CodePrimitiveExpression( "Hello World!" ) ); - - // Add the WriteLine call to the statement collection. - start->Statements->Add( cs1 ); - - // Build another Console::WriteLine statement. - CodeMethodInvokeExpression^ cs2 = gcnew CodeMethodInvokeExpression( - csSystemConsoleType, "WriteLine", - gcnew CodePrimitiveExpression( "Press the Enter key to continue." ) ); - // Add the WriteLine call to the statement collection. - start->Statements->Add( cs2 ); - - // Build a call to System::Console::ReadLine. - CodeMethodReferenceExpression^ csReadLine = gcnew CodeMethodReferenceExpression( - csSystemConsoleType, "ReadLine" ); - CodeMethodInvokeExpression^ cs3 = gcnew CodeMethodInvokeExpression( - csReadLine,gcnew array(0) ); - - // Add the ReadLine statement. - start->Statements->Add( cs3 ); - - // Add the code entry point method to the Members collection - // of the type. - class1->Members->Add( start ); - - return compileUnit; -} - -static String^ GenerateCode( CodeDomProvider^ provider, CodeCompileUnit^ compileunit ) -{ - // Build the source file name with the language extension (vb, cs, js). - String^ sourceFile = String::Empty; - - if ( provider->FileExtension->StartsWith( "." ) ) - { - sourceFile = String::Concat( "HelloWorld", provider->FileExtension ); - } - else - { - sourceFile = String::Concat( "HelloWorld.", provider->FileExtension ); - } - - // Create a TextWriter to a StreamWriter to an output file. - IndentedTextWriter^ tw = gcnew IndentedTextWriter( - gcnew StreamWriter( sourceFile,false )," " ); - // Generate source code using the code generator. - provider->GenerateCodeFromCompileUnit( compileunit, tw, gcnew CodeGeneratorOptions ); - // Close the output file. - tw->Close(); - return sourceFile; -} - -// -static bool CompileCode( CodeDomProvider^ provider, - String^ sourceFile, - String^ exeFile ) -{ - - CompilerParameters^ cp = gcnew CompilerParameters; - if ( !cp) - { - return false; - } - - // Generate an executable instead of - // a class library. - cp->GenerateExecutable = true; - - // Set the assembly file name to generate. - cp->OutputAssembly = exeFile; - - // Generate debug information. - cp->IncludeDebugInformation = true; - - // Add an assembly reference. - cp->ReferencedAssemblies->Add( "System.dll" ); - - // Save the assembly as a physical file. - cp->GenerateInMemory = false; - - // Set the level at which the compiler - // should start displaying warnings. - cp->WarningLevel = 3; - - // Set whether to treat all warnings as errors. - cp->TreatWarningsAsErrors = false; - - // Set compiler argument to optimize output. - cp->CompilerOptions = "/optimize"; - - // Set a temporary files collection. - // The TempFileCollection stores the temporary files - // generated during a build in the current directory, - // and does not delete them after compilation. - cp->TempFiles = gcnew TempFileCollection( ".",true ); - - if ( provider->Supports( GeneratorSupport::EntryPointMethod ) ) - { - // Specify the class that contains - // the main method of the executable. - cp->MainClass = "Samples.Class1"; - } - - if ( Directory::Exists( "Resources" ) ) - { - if ( provider->Supports( GeneratorSupport::Resources ) ) - { - // Set the embedded resource file of the assembly. - // This is useful for culture-neutral resources, - // or default (fallback) resources. - cp->EmbeddedResources->Add( "Resources\\Default.resources" ); - - // Set the linked resource reference files of the assembly. - // These resources are included in separate assembly files, - // typically localized for a specific language and culture. - cp->LinkedResources->Add( "Resources\\nb-no.resources" ); - } - } - - // Invoke compilation. - CompilerResults^ cr = provider->CompileAssemblyFromFile( cp, sourceFile ); - - if ( cr->Errors->Count > 0 ) - { - // Display compilation errors. - Console::WriteLine( "Errors building {0} into {1}", - sourceFile, cr->PathToAssembly ); - for each ( CompilerError^ ce in cr->Errors ) - { - Console::WriteLine( " {0}", ce->ToString() ); - Console::WriteLine(); - } - } - else - { - Console::WriteLine( "Source {0} built into {1} successfully.", - sourceFile, cr->PathToAssembly ); - } - - // Return the results of compilation. - if ( cr->Errors->Count > 0 ) - { - return false; - } - else - { - return true; - } -} -// - -[STAThread] -void main() -{ - String^ exeName = "HelloWorld.exe"; - CodeDomProvider^ provider = nullptr; - - Console::WriteLine( "Enter the source language for Hello World (cs, vb, etc):" ); - String^ inputLang = Console::ReadLine(); - Console::WriteLine(); - - if ( CodeDomProvider::IsDefinedLanguage( inputLang ) ) - { - CodeCompileUnit^ helloWorld = BuildHelloWorldGraph(); - provider = CodeDomProvider::CreateProvider( inputLang ); - if ( helloWorld && provider ) - { - String^ sourceFile = GenerateCode( provider, helloWorld ); - Console::WriteLine( "HelloWorld source code generated." ); - if ( CompileCode( provider, sourceFile, exeName ) ) - { - Console::WriteLine( "Starting HelloWorld executable." ); - Process::Start( exeName ); - } - } - } - - if ( provider == nullptr ) - { - Console::WriteLine( "There is no CodeDomProvider for the input language." ); - } -} -// - diff --git a/snippets/cpp/VS_Snippets_CLR/CompilerResultsExample/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/CompilerResultsExample/CPP/class1.cpp deleted file mode 100644 index 89f9230ed7d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CompilerResultsExample/CPP/class1.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; -using namespace System::Collections; -using namespace System::Security::Permissions; - -public ref class Class1 -{ -public: - Class1(){} - - // - // Displays information from a CompilerResults. - [PermissionSet(SecurityAction::Demand, Name="FullTrust")] - static void DisplayCompilerResults( System::CodeDom::Compiler::CompilerResults^ cr ) - { - - // If errors occurred during compilation, output the compiler output and errors. - if ( cr->Errors->Count > 0 ) - { - for ( int i = 0; i < cr->Output->Count; i++ ) - Console::WriteLine( cr->Output[ i ] ); - for ( int i = 0; i < cr->Errors->Count; i++ ) - Console::WriteLine( String::Concat( i, ": ", cr->Errors[ i ] ) ); - } - else - { - - // Display information ab->Item[Out] the* compiler's exit code and the generated assembly. - Console::WriteLine( "Compiler returned with result code: {0}", cr->NativeCompilerReturnValue ); - Console::WriteLine( "Generated assembly name: {0}", cr->CompiledAssembly->FullName ); - if ( cr->PathToAssembly == nullptr ) - Console::WriteLine( "The assembly has been generated in memory." ); - else - Console::WriteLine( "Path to assembly: {0}", cr->PathToAssembly ); - - // Display temporary files information. - if ( !cr->TempFiles->KeepFiles ) - Console::WriteLine( "Temporary build files were deleted." ); - else - { - Console::WriteLine( "Temporary build files were not deleted." ); - - // Display a list of the temporary build files - IEnumerator^ enu = cr->TempFiles->GetEnumerator(); - for ( int i = 0; enu->MoveNext(); i++ ) - Console::WriteLine("TempFile " + i.ToString() + ": " + (String^)(enu->Current) ); - } - } - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR/Console-EXPANDTABSEX/CPP/expandtabsex.cpp b/snippets/cpp/VS_Snippets_CLR/Console-EXPANDTABSEX/CPP/expandtabsex.cpp deleted file mode 100644 index 3c72773fc05..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Console-EXPANDTABSEX/CPP/expandtabsex.cpp +++ /dev/null @@ -1,66 +0,0 @@ - - -// This sample takes a given input and replaces each -// occurence of the tab character with 4 space characters. -// It also takes two command-line arguements: input file name, & output file name. -// Usage: -// EXPANDTABS inputfile.txt outputfile.txt -// System.Console.Read -// System.Console.WriteLine -// System.Console.Write -// System.Console.SetIn -// System.Console.SetOut -// System.Console.Error -// System.Console.Out -// -using namespace System; -using namespace System::IO; - -void main() -{ - const int tabSize = 4; - array^args = Environment::GetCommandLineArgs(); - String^ usageText = "Usage: EXPANDTABSEX inputfile.txt outputfile.txt"; - StreamWriter^ writer = nullptr; - - if ( args->Length < 3 ) - { - Console::WriteLine( usageText ); - return; - } - - try - { - writer = gcnew StreamWriter( args[ 2 ] ); - Console::SetOut( writer ); - Console::SetIn( gcnew StreamReader( args[ 1 ] ) ); - } - catch ( IOException^ e ) - { - TextWriter^ errorWriter = Console::Error; - errorWriter->WriteLine( e->Message ); - errorWriter->WriteLine( usageText ); - return; - } - - int i; - while ( (i = Console::Read()) != -1 ) - { - Char c = (Char)i; - if ( c == '\t' ) - Console::Write( ((String^)"")->PadRight( tabSize, ' ' ) ); - else - Console::Write( c ); - } - - writer->Close(); - - // Recover the standard output stream so that a - // completion message can be displayed. - StreamWriter^ standardOutput = gcnew StreamWriter(Console::OpenStandardOutput()); - standardOutput->AutoFlush = true; - Console::SetOut(standardOutput); - Console::WriteLine( "EXPANDTABSEX has completed the processing of {0}.", args[ 0 ] ); - return; -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.3DES.Create.Memory/CPP/memoryexample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.3DES.Create.Memory/CPP/memoryexample.cpp deleted file mode 100644 index f1d7dc04657..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.3DES.Create.Memory/CPP/memoryexample.cpp +++ /dev/null @@ -1,170 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -using namespace System::IO; - -array^ EncryptTextToMemory(String^ text, array^ key, array^ iv); -String^ DecryptTextFromMemory(array^ encrypted, array^ key, array^ iv); - -int main() -{ - try - { - array^ key; - array^ iv; - - // Create a new TripleDES object to generate a random key - // and initialization vector (IV). - { - TripleDES^ tripleDes; - - try - { - tripleDes = TripleDES::Create(); - key = tripleDes->Key; - iv = tripleDes->IV; - } - finally - { - delete tripleDes; - } - } - - // Create a string to encrypt. - String^ original = "Here is some data to encrypt."; - - // Encrypt the string to an in-memory buffer. - array^ encrypted = EncryptTextToMemory(original, key, iv); - - // Decrypt the buffer back to a string. - String^ decrypted = DecryptTextFromMemory(encrypted, key, iv); - - // Display the decrypted string to the console. - Console::WriteLine(decrypted); - } - catch (Exception^ e) - { - Console::WriteLine(e->Message); - } -} - -array^ EncryptTextToMemory(String^ text, array^ key, array^ iv) -{ - MemoryStream^ mStream = nullptr; - - try - { - // Create a MemoryStream. - mStream = gcnew MemoryStream; - - TripleDES^ tripleDes = nullptr; - ICryptoTransform^ encryptor = nullptr; - CryptoStream^ cStream = nullptr; - - try - { - // Create a new TripleDES object. - tripleDes = TripleDES::Create(); - // Create a TripleDES encryptor from the key and IV - encryptor = tripleDes->CreateEncryptor(key, iv); - // Create a CryptoStream using the MemoryStream and encryptor - cStream = gcnew CryptoStream(mStream, encryptor, CryptoStreamMode::Write); - - // Convert the provided string to a byte array. - array^ toEncrypt = Encoding::UTF8->GetBytes(text); - - // Write the byte array to the crypto stream. - cStream->Write(toEncrypt, 0, toEncrypt->Length); - - // Disposing the CryptoStream completes the encryption and flushes the stream. - delete cStream; - - // Get an array of bytes from the MemoryStream that holds the encrypted data. - array^ ret = mStream->ToArray(); - - // Return the encrypted buffer. - return ret; - } - finally - { - if (cStream != nullptr) - delete cStream; - - if (encryptor != nullptr) - delete encryptor; - - if (tripleDes != nullptr) - delete tripleDes; - } - } - catch (CryptographicException^ e) - { - Console::WriteLine("A Cryptographic error occurred: {0}", e->Message); - throw; - } - finally - { - if (mStream != nullptr) - delete mStream; - } -} - -String^ DecryptTextFromMemory(array^ encrypted, array^ key, array^ iv) -{ - MemoryStream^ mStream = nullptr; - TripleDES^ tripleDes = nullptr; - ICryptoTransform^ decryptor = nullptr; - CryptoStream^ cStream = nullptr; - - try - { - // Create buffer to hold the decrypted data. - // TripleDES-encrypted data will always be slightly bigger than the decrypted data. - array^ decrypted = gcnew array(encrypted->Length); - Int32 offset = 0; - - // Create a new MemoryStream using the provided array of encrypted data. - mStream = gcnew MemoryStream(encrypted); - // Create a new TripleDES object. - tripleDes = TripleDES::Create(); - // Create a TripleDES decryptor from the key and IV - decryptor = tripleDes->CreateDecryptor(key, iv); - // Create a CryptoStream using the MemoryStream and decryptor - cStream = gcnew CryptoStream(mStream, decryptor, CryptoStreamMode::Read); - - // Keep reading from the CryptoStream until it finishes (returns 0). - Int32 read = 1; - - while (read > 0) - { - read = cStream->Read(decrypted, offset, decrypted->Length - offset); - offset += read; - } - - // Convert the buffer into a string and return it. - return Encoding::UTF8->GetString(decrypted, 0, offset); - } - catch (CryptographicException^ e) - { - Console::WriteLine("A Cryptographic error occurred: {0}", e->Message); - throw; - } - finally - { - if (cStream != nullptr) - delete cStream; - - if (decryptor != nullptr) - delete decryptor; - - if (tripleDes != nullptr) - delete tripleDes; - - if (mStream != nullptr) - delete mStream; - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/DateTime Operators/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/DateTime Operators/CPP/class1.cpp deleted file mode 100644 index e1bc418aedf..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/DateTime Operators/CPP/class1.cpp +++ /dev/null @@ -1,30 +0,0 @@ -using namespace System; - -int main() -{ - // Addition operator - // - System::DateTime dTime( 1980, 8, 5 ); - - // tSpan is 17 days, 4 hours, 2 minutes and 1 second. - System::TimeSpan tSpan( 17, 4, 2, 1 ); - - // Result gets 8/22/1980 4:02:01 AM. - System::DateTime result = dTime + tSpan; - // - - System::Console::WriteLine( result ); - - // Equality operator. - // - System::DateTime april19( 2001, 4, 19 ); - System::DateTime otherDate( 1991, 6, 5 ); - - // areEqual gets false. - bool areEqual = april19 == otherDate; - - otherDate = DateTime( 2001, 4, 19 ); - // areEqual gets true. - areEqual = april19 == otherDate; - // -} diff --git a/snippets/cpp/VS_Snippets_CLR/DateTime.Add/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/DateTime.Add/CPP/class1.cpp deleted file mode 100644 index 8d23921d77c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/DateTime.Add/CPP/class1.cpp +++ /dev/null @@ -1,12 +0,0 @@ -using namespace System; - -int main() -{ - // - // Calculate what day of the week is 36 days from this instant. - System::DateTime today = System::DateTime::Now; - System::TimeSpan duration( 36, 0, 0, 0 ); - System::DateTime answer = today.Add( duration ); - System::Console::WriteLine( " {0:dddd}", answer ); - // -} diff --git a/snippets/cpp/VS_Snippets_CLR/DateTime.AddDays/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/DateTime.AddDays/CPP/class1.cpp deleted file mode 100644 index 0cd42a84a60..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/DateTime.AddDays/CPP/class1.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// -using namespace System; - -int main() -{ - // Calculate what day of the week is 36 days from this instant. - DateTime today = System::DateTime::Now; - DateTime answer = today.AddDays( 36 ); - Console::WriteLine("Today: {0:dddd}", today); - Console::WriteLine("36 days from today: {0:dddd}", answer); -} -// The example displays output like the following: -// Today: Wednesday -// 36 days from today: Thursday -// diff --git a/snippets/cpp/VS_Snippets_CLR/DateTime.CompareTo/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/DateTime.CompareTo/CPP/class1.cpp deleted file mode 100644 index 90e6be09498..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/DateTime.CompareTo/CPP/class1.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// -using namespace System; -void main() -{ - - - System::DateTime theDay(System::DateTime::Today.Year,7,28); - int compareValue; - try - { - compareValue = theDay.CompareTo( System::DateTime::Today ); - } - catch ( ArgumentException^ ) - { - System::Console::WriteLine( "Value is not a DateTime" ); - return; - } - - if ( compareValue < 0 ) - { - System::Console::WriteLine( "{0:d} is in the past.", theDay ); - } - else - if ( compareValue == 0 ) - { - System::Console::WriteLine( "{0:d} is today!", theDay ); - } - else - // compareValue > 0 - { - System::Console::WriteLine( "{0:d} has not come yet.", theDay ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/DateTime.DayOfWeek/CPP/dow.cpp b/snippets/cpp/VS_Snippets_CLR/DateTime.DayOfWeek/CPP/dow.cpp deleted file mode 100644 index 9c3486e2cfa..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/DateTime.DayOfWeek/CPP/dow.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -// This example demonstrates the DateTime.DayOfWeek property -using namespace System; -int main() -{ - - // Assume the current culture is en-US. - // Create a DateTime for the first of May, 2003. - DateTime dt = DateTime(2003,5,1); - Console::WriteLine( "Is Thursday the day of the week for {0:d}?: {1}", dt, dt.DayOfWeek == DayOfWeek::Thursday ); - Console::WriteLine( "The day of the week for {0:d} is {1}.", dt, dt.DayOfWeek ); -} - -/* -This example produces the following results: - -Is Thursday the day of the week for 5/1/2003?: True -The day of the week for 5/1/2003 is Thursday. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/DateTime.DaysInMonth/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/DateTime.DaysInMonth/CPP/class1.cpp deleted file mode 100644 index 4cd3cdc577f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/DateTime.DaysInMonth/CPP/class1.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// -using namespace System; - -int main() -{ - const int July = 7; - const int Feb = 2; - - int daysInJuly = System::DateTime::DaysInMonth( 2001, July ); - Console::WriteLine(daysInJuly); - // daysInFeb gets 28 because the year 1998 was not a leap year. - int daysInFeb = System::DateTime::DaysInMonth( 1998, Feb ); - Console::WriteLine(daysInFeb); - // daysInFebLeap gets 29 because the year 1996 was a leap year. - int daysInFebLeap = System::DateTime::DaysInMonth( 1996, Feb ); - Console::WriteLine(daysInFebLeap); -} -// The example displays the following output: -// 31 -// 28 -// 29 -// diff --git a/snippets/cpp/VS_Snippets_CLR/DateTime.Equals/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/DateTime.Equals/CPP/class1.cpp deleted file mode 100644 index 3bccccac024..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/DateTime.Equals/CPP/class1.cpp +++ /dev/null @@ -1,22 +0,0 @@ -using namespace System; - -int main() -{ - // - System::DateTime today1 = System::DateTime( - System::DateTime::Today.Ticks ); - System::DateTime today2 = System::DateTime( - System::DateTime::Today.Ticks ); - System::DateTime tomorrow = System::DateTime( - System::DateTime::Today.AddDays( 1 ).Ticks ); - - // todayEqualsToday gets true. - bool todayEqualsToday = System::DateTime::Equals( today1, today2 ); - - // todayEqualsTomorrow gets false. - bool todayEqualsTomorrow = System::DateTime::Equals( today1, tomorrow ); - // - - System::Console::WriteLine( todayEqualsToday ); - System::Console::WriteLine( todayEqualsTomorrow ); -} diff --git a/snippets/cpp/VS_Snippets_CLR/DateTime.FromFileTime/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/DateTime.FromFileTime/CPP/class1.cpp deleted file mode 100644 index 6e94f44f925..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/DateTime.FromFileTime/CPP/class1.cpp +++ /dev/null @@ -1,44 +0,0 @@ -using namespace System; -using namespace System::IO; - -// This function takes a file's creation time as an unsigned long, -// and returns its age. -// -System::TimeSpan FileAge( long fileCreationTime ) -{ - System::DateTime now = System::DateTime::Now; - try - { - System::DateTime fCreationTime = - System::DateTime::FromFileTime( fileCreationTime ); - System::TimeSpan fileAge = now.Subtract( fCreationTime ); - return fileAge; - } - catch ( ArgumentOutOfRangeException^ ) - { - // fileCreationTime is not valid, so re-throw the exception. - throw; - } -} -// - -void main() -{ - System::Console::WriteLine( "Enter a file's path" ); - String^ filePath = System::Console::ReadLine(); - System::IO::FileInfo^ fInfo; - try - { - fInfo = gcnew System::IO::FileInfo( filePath ); - } - catch ( Exception^ ) - { - System::Console::WriteLine( "Error opening {0}", filePath ); - return; - } - - long fileTime = System::Convert::ToInt64( - fInfo->CreationTime.ToFileTime() ); - System::TimeSpan fileAge = FileAge( fileTime ); - System::Console::WriteLine( " {0}", fileAge ); -} diff --git a/snippets/cpp/VS_Snippets_CLR/DateTime.GetDateTimeFormats/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/DateTime.GetDateTimeFormats/CPP/class1.cpp deleted file mode 100644 index 436ff3e6d0e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/DateTime.GetDateTimeFormats/CPP/class1.cpp +++ /dev/null @@ -1,34 +0,0 @@ - -using namespace System; - -int main() -{ - // - DateTime july28 = DateTime(2009, 7, 28, 5, 23, 15, 16); - array^july28Formats = july28.GetDateTimeFormats(); - - // Print [Out] july28* in all DateTime formats using the default culture. - System::Collections::IEnumerator^ myEnum = july28Formats->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - String^ format = safe_cast(myEnum->Current); - System::Console::WriteLine( format ); - } - // - - // - DateTime juil28 = DateTime(2009, 7, 28, 5, 23, 15, 16); - IFormatProvider^ culture = gcnew System::Globalization::CultureInfo("fr-FR", true ); - - // Get the short date formats using the S"fr-FR" culture. - array^frenchJuly28Formats = juil28.GetDateTimeFormats(culture ); - - // Print [Out] july28* in all DateTime formats using fr-FR culture. - System::Collections::IEnumerator^ myEnum2 = frenchJuly28Formats->GetEnumerator(); - while ( myEnum2->MoveNext() ) - { - String^ format = safe_cast(myEnum2->Current); - System::Console::WriteLine(format ); - } - // -} diff --git a/snippets/cpp/VS_Snippets_CLR/DateTime.Subtraction/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/DateTime.Subtraction/CPP/class1.cpp deleted file mode 100644 index d3d290772b1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/DateTime.Subtraction/CPP/class1.cpp +++ /dev/null @@ -1,27 +0,0 @@ -using namespace System; - -int main() -{ - // - System::DateTime date1 = System::DateTime( 1996, 6, 3, 22, 15, 0 ); - System::DateTime date2 = System::DateTime( 1996, 12, 6, 13, 2, 0 ); - System::DateTime date3 = System::DateTime( 1996, 10, 12, 8, 42, 0 ); - - // diff1 gets 185 days, 14 hours, and 47 minutes. - System::TimeSpan diff1 = date2.Subtract( date1 ); - - // date4 gets 4/9/1996 5:55:00 PM. - System::DateTime date4 = date3.Subtract( diff1 ); - - // diff2 gets 55 days 4 hours and 20 minutes. - System::TimeSpan diff2 = date2 - date3; - - // date5 gets 4/9/1996 5:55:00 PM. - System::DateTime date5 = date1 - diff2; - // - - System::Console::WriteLine( diff1 ); - System::Console::WriteLine( date4 ); - System::Console::WriteLine( diff2 ); - System::Console::WriteLine( date4 ); -} diff --git a/snippets/cpp/VS_Snippets_CLR/DateTime.ToFileTime/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/DateTime.ToFileTime/CPP/class1.cpp deleted file mode 100644 index fd732ab14d0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/DateTime.ToFileTime/CPP/class1.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -using namespace System; - -// -int main() -{ - System::Console::WriteLine( "Enter the file path:" ); - String^ filePath = System::Console::ReadLine(); - if ( System::IO::File::Exists( filePath ) ) - { - System::DateTime fileCreationDateTime = System::IO::File::GetCreationTime( filePath ); - __int64 fileCreationFileTime = fileCreationDateTime.ToFileTime(); - System::Console::WriteLine( "{0} in file time is {1}.", fileCreationDateTime, fileCreationFileTime ); - } - else - { - System::Console::WriteLine( "{0} is an invalid file", filePath ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/DateTime.ToLocalTime ToUniversalTime/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/DateTime.ToLocalTime ToUniversalTime/CPP/class1.cpp deleted file mode 100644 index 9b140cbb13e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/DateTime.ToLocalTime ToUniversalTime/CPP/class1.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// -using namespace System; - -void main() -{ - Console::WriteLine("Enter a date and time."); - String^ strDateTime = Console::ReadLine(); - - DateTime localDateTime, univDateTime; - try - { - localDateTime = DateTime::Parse(strDateTime); - univDateTime = localDateTime.ToUniversalTime(); - - Console::WriteLine("{0} local time is {1} universal time.", - localDateTime, univDateTime ); - } - catch (FormatException^) - { - Console::WriteLine("Invalid format."); - return; - } - - Console::WriteLine("Enter a date and time in universal time."); - strDateTime = Console::ReadLine(); - - try - { - univDateTime = DateTime::Parse(strDateTime); - localDateTime = univDateTime.ToLocalTime(); - - Console::WriteLine("{0} universal time is {1} local time.", - univDateTime, localDateTime ); - } - catch (FormatException^) - { - Console::WriteLine("Invalid format."); - return; - } -} -// The example displays output like the following when run on a -// computer whose culture is en-US in the Pacific Standard Time zone: -// Enter a date and time. -// 12/10/2015 6:18 AM -// 12/10/2015 6:18:00 AM local time is 12/10/2015 2:18:00 PM universal time. -// Enter a date and time in universal time. -// 12/20/2015 6:42:00 -// 12/20/2015 6:42:00 AM universal time is 12/19/2015 10:42:00 PM local time. -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/Decimal Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/Decimal Example/CPP/source.cpp deleted file mode 100644 index 1d76e0d1879..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Decimal Example/CPP/source.cpp +++ /dev/null @@ -1,144 +0,0 @@ -using namespace System; - -namespace Snippets -{ -// - /// - /// Keeping my fortune in Decimals to avoid the round-off errors. - /// - public ref class PiggyBank - { - protected: - Decimal MyFortune; - - public: - void AddPenny() - { - MyFortune = System::Decimal::Add( MyFortune, Decimal(.01) ); - } - - System::Decimal Capacity() - { - return MyFortune.MaxValue; - } - - Decimal Dollars() - { - return Decimal::Floor( MyFortune ); - } - - Decimal Cents() - { - return Decimal::Subtract( MyFortune, Decimal::Floor( MyFortune ) ); - } - - virtual System::String^ ToString() override - { - return MyFortune.ToString("C")+" in piggy bank"; - } - }; -} -// - -using namespace Snippets; -int main( void ) -{ - PiggyBank ^ pb = gcnew PiggyBank; - for ( Int32 i = 0; i < 378; i++ ) - { - pb->AddPenny(); - - } - Console::WriteLine( pb ); -} - - -namespace Snippets2 -{ - // - public ref class PiggyBank - { - public: - Decimal Capacity() - { - return MyFortune.MaxValue; - } - - void AddPenny() - { - MyFortune = Decimal::Add(MyFortune, (Decimal).01); - } - - protected: - Decimal MyFortune; - }; - -} -// - -namespace Snippets3 -{ - // - public ref class PiggyBank - { - public: - Decimal Dollars() - { - return Decimal::Floor( MyFortune ); - } - - void AddPenny() - { - MyFortune = Decimal::Add(MyFortune, (Decimal).01); - } - - protected: - Decimal MyFortune; - }; - -} -// - -namespace Snippets4 -{ -// - public ref class PiggyBank - { - public: - Decimal Cents() - { - return Decimal::Subtract( MyFortune, Decimal::Floor( MyFortune ) ); - } - - void AddPenny() - { - MyFortune = Decimal::Add(MyFortune, (Decimal).01); - } - - protected: - Decimal MyFortune; - }; -} -// - -namespace Snippets5 -{ -// - public ref class PiggyBank - { - public: - void AddPenny() - { - MyFortune = Decimal::Add( MyFortune, (Decimal).01 ); - } - - virtual System::String^ ToString() override - { - return MyFortune.ToString("C")+" in piggy bank"; - } - - protected: - Decimal MyFortune; - }; -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Delegate.CreateDelegate_RelaxedFit/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR/Delegate.CreateDelegate_RelaxedFit/cpp/source.cpp deleted file mode 100644 index e8b0c924c07..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Delegate.CreateDelegate_RelaxedFit/cpp/source.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -// Define two classes to use in the demonstration, a base class and -// a class that derives from it. -// -public ref class Base {}; - -public ref class Derived : Base -{ - // Define a static method to use in the demonstration. The method - // takes an instance of Base and returns an instance of Derived. - // For the purposes of the demonstration, it is not necessary for - // the method to do anything useful. - // -public: - static Derived^ MyMethod(Base^ arg) - { - Base^ dummy = arg; - return gcnew Derived(); - } -}; - -// Define a delegate that takes an instance of Derived and returns an -// instance of Base. -// -public delegate Base^ Example(Derived^ arg); - -void main() -{ - // The binding flags needed to retrieve MyMethod. - BindingFlags flags = BindingFlags::Public | BindingFlags::Static; - - // Get a MethodInfo that represents MyMethod. - MethodInfo^ minfo = Derived::typeid->GetMethod("MyMethod", flags); - - // Demonstrate contravariance of parameter types and covariance - // of return types by using the delegate Example to represent - // MyMethod. The delegate binds to the method because the - // parameter of the delegate is more restrictive than the - // parameter of the method (that is, the delegate accepts an - // instance of Derived, which can always be safely passed to - // a parameter of type Base), and the return type of MyMethod - // is more restrictive than the return type of Example (that - // is, the method returns an instance of Derived, which can - // always be safely cast to type Base). - // - Example^ ex = - (Example^) Delegate::CreateDelegate(Example::typeid, minfo); - - // Execute MyMethod using the delegate Example. - // - Base^ b = ex(gcnew Derived()); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Dir_CreateDir/CPP/dir_createdir.cpp b/snippets/cpp/VS_Snippets_CLR/Dir_CreateDir/CPP/dir_createdir.cpp deleted file mode 100644 index 550cc864617..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Dir_CreateDir/CPP/dir_createdir.cpp +++ /dev/null @@ -1,35 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - - // Specify the directory you want to manipulate. - String^ path = "c:\\MyDir"; - try - { - - // Determine whether the directory exists. - if ( Directory::Exists( path ) ) - { - Console::WriteLine( "That path exists already." ); - return 0; - } - - // Try to create the directory. - DirectoryInfo^ di = Directory::CreateDirectory( path ); - Console::WriteLine( "The directory was created successfully at {0}.", Directory::GetCreationTime( path ) ); - - // 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/Double Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/Double Example/CPP/source.cpp deleted file mode 100644 index 95b5dde57f4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Double Example/CPP/source.cpp +++ /dev/null @@ -1,531 +0,0 @@ -using namespace System; -using namespace System::Globalization; - -namespace Snippets -{ - // - // The Temperature class stores the temperature as a Double - // and delegates most of the functionality to the Double - // implementation. - public ref class Temperature: public IComparable, public IFormattable - { - // IComparable.CompareTo implementation. - public: - virtual int CompareTo( Object^ obj ) - { - if (obj == nullptr) return 1; - - if (dynamic_cast(obj) ) - { - Temperature^ temp = (Temperature^)(obj); - return m_value.CompareTo( temp->m_value ); - } - throw gcnew ArgumentException( "object is not a Temperature" ); - } - - // IFormattable.ToString implementation. - virtual String^ ToString( String^ format, IFormatProvider^ provider ) - { - if ( format != nullptr ) - { - if ( format->Equals( "F" ) ) - { - return String::Format( "{0}'F", this->Value.ToString() ); - } - - if ( format->Equals( "C" ) ) - { - return String::Format( "{0}'C", this->Celsius.ToString() ); - } - } - return m_value.ToString( format, provider ); - } - - // Parses the temperature from a string in the form - // [ws][sign]digits['F|'C][ws] - static Temperature^ Parse( String^ s, NumberStyles styles, IFormatProvider^ provider ) - { - Temperature^ temp = gcnew Temperature; - - if ( s->TrimEnd(nullptr)->EndsWith( "'F" ) ) - { - temp->Value = Double::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ), styles, provider ); - } - else - if ( s->TrimEnd(nullptr)->EndsWith( "'C" ) ) - { - temp->Celsius = Double::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ), styles, provider ); - } - else - { - temp->Value = Double::Parse( s, styles, provider ); - } - return temp; - } - - protected: - double m_value; - - public: - property double Value - { - double get() - { - return m_value; - } - - void set( double value ) - { - m_value = value; - } - } - - property double Celsius - { - double get() - { - return (m_value - 32.0) / 1.8; - } - - void set( double value ) - { - m_value = 1.8 * value + 32.0; - } - } - }; - // - - ref class Launcher - { - public: - static void Main() - { - Temperature^ t1 = Temperature::Parse( "20'F", NumberStyles::Float, nullptr ); - Console::WriteLine( t1->ToString( "F", nullptr ) ); - - String^ str1 = t1->ToString( "C", nullptr ); - Console::WriteLine( str1 ); - - Temperature^ t2 = Temperature::Parse( str1, NumberStyles::Float, nullptr ); - Console::WriteLine( t2->ToString( "F", nullptr ) ); - - Console::WriteLine( t1->CompareTo( t2 ) ); - - Temperature^ t3 = Temperature::Parse( "20'C", NumberStyles::Float, nullptr ); - Console::WriteLine( t3->ToString( "F", nullptr ) ); - - Console::WriteLine( t1->CompareTo( t3 ) ); - - Console::ReadLine(); - } - }; -} - -namespace Snippets2 -{ - // - public ref class Temperature - { - public: - static property double MinValue - { - double get() - { - return Double::MinValue; - } - } - - static property double MaxValue - { - double get() - { - return Double::MaxValue; - } - } - - protected: - // The value holder - double m_value; - - public: - property double Value - { - double get() - { - return m_value; - } - void set( double value ) - { - m_value = value; - } - } - - property double Celsius - { - double get() - { - return (m_value - 32.0) / 1.8; - } - void set( double value ) - { - m_value = 1.8 * value + 32.0; - } - } - }; -// -} - -namespace Snippets3 -{ - // - public ref class Temperature: public IComparable - { - // IComparable.CompareTo implementation. - public: - virtual int CompareTo( Object^ obj ) - { - if (obj == nullptr) return 1; - - if ( dynamic_cast(obj) ) - { - Temperature^ temp = dynamic_cast(obj); - - return m_value.CompareTo( temp->m_value ); - } - - throw gcnew ArgumentException( "object is not a Temperature" ); - } - - protected: - // The value holder - double m_value; - - public: - property double Value - { - double get() - { - return m_value; - } - void set( double value ) - { - m_value = value; - } - } - - property double Celsius - { - double get() - { - return (m_value - 32.0) / 1.8; - } - void set( double value ) - { - m_value = 1.8 * value + 32.0; - } - } - }; -// -} - -namespace Snippets4 -{ - // - public ref class Temperature: public IFormattable - { - // IFormattable.ToString implementation. - public: - virtual String^ ToString( String^ format, IFormatProvider^ provider ) - { - if ( format != nullptr ) - { - if ( format->Equals( "F" ) ) - { - return String::Format( "{0}'F", this->Value.ToString() ); - } - - if ( format->Equals( "C" ) ) - { - return String::Format( "{0}'C", this->Celsius.ToString() ); - } - } - - return m_value.ToString( format, provider ); - } - - protected: - // The value holder - double m_value; - - public: - property double Value - { - double get() - { - return m_value; - } - void set( double value ) - { - m_value = value; - } - } - - property double Celsius - { - double get() - { - return (m_value - 32.0) / 1.8; - } - void set( double value ) - { - m_value = 1.8 * value + 32.0; - } - } - }; -// -} - -namespace Snippets5 -{ - // - public ref class Temperature - { - // Parses the temperature from a string in form - // [ws][sign]digits['F|'C][ws] - public: - static Temperature^ Parse( String^ s ) - { - Temperature^ temp = gcnew Temperature; - if ( s->TrimEnd(nullptr)->EndsWith( "'F" ) ) - { - temp->Value = Double::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ) ); - } - else - if ( s->TrimEnd(nullptr)->EndsWith( "'C" ) ) - { - temp->Celsius = Double::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ) ); - } - else - { - temp->Value = Double::Parse( s ); - } - - return temp; - } - - protected: - // The value holder - double m_value; - - public: - property double Value - { - double get() - { - return m_value; - } - void set( double value ) - { - m_value = value; - } - } - - property double Celsius - { - double get() - { - return (m_value - 32.0) / 1.8; - } - void set( double value ) - { - m_value = 1.8 * value + 32.0; - } - } - }; -// -} - -namespace Snippets6 -{ - // - public ref class Temperature - { - // Parses the temperature from a string in form - // [ws][sign]digits['F|'C][ws] - public: - static Temperature^ Parse( String^ s, IFormatProvider^ provider ) - { - Temperature^ temp = gcnew Temperature; - if ( s->TrimEnd(nullptr)->EndsWith( "'F" ) ) - { - temp->Value = Double::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ), provider ); - } - else - if ( s->TrimEnd(nullptr)->EndsWith( "'C" ) ) - { - temp->Celsius = Double::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ), provider ); - } - else - { - temp->Value = Double::Parse( s, provider ); - } - - return temp; - } - - protected: - // The value holder - double m_value; - - public: - property double Value - { - double get() - { - return m_value; - } - void set( double value ) - { - m_value = value; - } - } - - property double Celsius - { - double get() - { - return (m_value - 32.0) / 1.8; - } - void set( double value ) - { - m_value = 1.8 * value + 32.0; - } - } - }; -// -} - -namespace Snippets7 -{ - // - public ref class Temperature - { - // Parses the temperature from a string in form - // [ws][sign]digits['F|'C][ws] - public: - static Temperature^ Parse( String^ s, NumberStyles styles ) - { - Temperature^ temp = gcnew Temperature; - if ( s->TrimEnd(nullptr)->EndsWith( "'F" ) ) - { - temp->Value = Double::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ), styles ); - } - else - if ( s->TrimEnd(nullptr)->EndsWith( "'C" ) ) - { - temp->Celsius = Double::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ), styles ); - } - else - { - temp->Value = Double::Parse( s, styles ); - } - - return temp; - } - - protected: - // The value holder - double m_value; - - public: - property double Value - { - double get() - { - return m_value; - } - void set( double value ) - { - m_value = value; - } - } - - property double Celsius - { - double get() - { - return (m_value - 32.0) / 1.8; - } - void set( double value ) - { - m_value = 1.8 * value + 32.0; - } - } - }; -// -} - -namespace Snippets8 -{ - // - public ref class Temperature - { - // Parses the temperature from a string in the form - // [ws][sign]digits['F|'C][ws] - public: - static Temperature^ Parse( String^ s, NumberStyles styles, IFormatProvider^ provider ) - { - Temperature^ temp = gcnew Temperature; - if ( s->TrimEnd(nullptr)->EndsWith( "'F" ) ) - { - temp->Value = Double::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ), styles, provider ); - } - else - if ( s->TrimEnd(nullptr)->EndsWith( "'C" ) ) - { - temp->Celsius = Double::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ), styles, provider ); - } - else - { - temp->Value = Double::Parse( s, styles, provider ); - } - - return temp; - } - - protected: - // The value holder - double m_value; - - public: - property double Value - { - double get() - { - return m_value; - } - void set( double value ) - { - m_value = value; - } - } - - property double Celsius - { - double get() - { - return (m_value - 32.0) / 1.8; - } - void set( double value ) - { - m_value = 1.8 * value + 32.0; - } - } - }; -// -} - -int main() -{ - Snippets::Launcher::Main(); -} diff --git a/snippets/cpp/VS_Snippets_CLR/ECMA-System.Object.GetType/CPP/gettype.cpp b/snippets/cpp/VS_Snippets_CLR/ECMA-System.Object.GetType/CPP/gettype.cpp deleted file mode 100644 index 6ee946709cf..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ECMA-System.Object.GetType/CPP/gettype.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// -using namespace System; - -public ref class MyBaseClass {}; - -public ref class MyDerivedClass: MyBaseClass{}; - -int main() -{ - MyBaseClass^ myBase = gcnew MyBaseClass; - MyDerivedClass^ myDerived = gcnew MyDerivedClass; - Object^ o = myDerived; - MyBaseClass^ b = myDerived; - Console::WriteLine( "mybase: Type is {0}", myBase->GetType() ); - Console::WriteLine( "myDerived: Type is {0}", myDerived->GetType() ); - Console::WriteLine( "object o = myDerived: Type is {0}", o->GetType() ); - Console::WriteLine( "MyBaseClass b = myDerived: Type is {0}", b->GetType() ); -} - -/* - -This code produces the following output. - -mybase: Type is MyBaseClass -myDerived: Type is MyDerivedClass -object o = myDerived: Type is MyDerivedClass -MyBaseClass b = myDerived: Type is MyDerivedClass - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/ECMA-System.Object.ReferenceEquals/CPP/referenceequals.cpp b/snippets/cpp/VS_Snippets_CLR/ECMA-System.Object.ReferenceEquals/CPP/referenceequals.cpp deleted file mode 100644 index 994eab40042..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ECMA-System.Object.ReferenceEquals/CPP/referenceequals.cpp +++ /dev/null @@ -1,24 +0,0 @@ - -// -using namespace System; -int main() -{ - Object^ o = nullptr; - Object^ p = nullptr; - Object^ q = gcnew Object; - Console::WriteLine( Object::ReferenceEquals( o, p ) ); - p = q; - Console::WriteLine( Object::ReferenceEquals( p, q ) ); - Console::WriteLine( Object::ReferenceEquals( o, p ) ); -} - -/* - -This code produces the following output. - -True -True -False - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/Environment.GetCommandLineArgs/CPP/getcommandlineargs.cpp b/snippets/cpp/VS_Snippets_CLR/Environment.GetCommandLineArgs/CPP/getcommandlineargs.cpp deleted file mode 100644 index 91579bc8326..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Environment.GetCommandLineArgs/CPP/getcommandlineargs.cpp +++ /dev/null @@ -1,20 +0,0 @@ - -// -using namespace System; - -int main() -{ - Console::WriteLine(); - - // Invoke this sample with an arbitrary set of command line arguments. - array^ arguments = Environment::GetCommandLineArgs(); - Console::WriteLine( "GetCommandLineArgs: {0}", String::Join( ", ", arguments ) ); -} -/* -This example produces output like the following: - - C:\>GetCommandLineArgs ARBITRARY TEXT - - GetCommandLineArgs: GetCommandLineArgs, ARBITRARY, TEXT -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/Environment.GetEnvironmentVariables/CPP/getenvironmentvariables.cpp b/snippets/cpp/VS_Snippets_CLR/Environment.GetEnvironmentVariables/CPP/getenvironmentvariables.cpp deleted file mode 100644 index e99e9275e62..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Environment.GetEnvironmentVariables/CPP/getenvironmentvariables.cpp +++ /dev/null @@ -1,16 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; - -int main() -{ - Console::WriteLine( "GetEnvironmentVariables: " ); - for each (DictionaryEntry^ de in Environment::GetEnvironmentVariables()) - Console::WriteLine( " {0} = {1}", de->Key, de->Value ); -} -// Output from the example is not shown, since it is: -// Lengthy. -// Specific to the machine on which the example is run. -// May reveal information that should remain secure. -// diff --git a/snippets/cpp/VS_Snippets_CLR/Environment.GetFolderPath/CPP/getfolderpath.cpp b/snippets/cpp/VS_Snippets_CLR/Environment.GetFolderPath/CPP/getfolderpath.cpp deleted file mode 100644 index 724d32024ff..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Environment.GetFolderPath/CPP/getfolderpath.cpp +++ /dev/null @@ -1,16 +0,0 @@ - -// -// Sample for the Environment::GetFolderPath method -using namespace System; -int main() -{ - Console::WriteLine(); - Console::WriteLine( "GetFolderPath: {0}", Environment::GetFolderPath( Environment::SpecialFolder::System ) ); -} - -/* -This example produces the following results: - -GetFolderPath: C:\WINNT\System32 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/Environment.GetLogicalDrives/CPP/getlogicaldrives.cpp b/snippets/cpp/VS_Snippets_CLR/Environment.GetLogicalDrives/CPP/getlogicaldrives.cpp deleted file mode 100644 index 214308f0a70..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Environment.GetLogicalDrives/CPP/getlogicaldrives.cpp +++ /dev/null @@ -1,17 +0,0 @@ - -// -// Sample for the Environment::GetLogicalDrives method -using namespace System; -int main() -{ - Console::WriteLine(); - array^drives = Environment::GetLogicalDrives(); - Console::WriteLine( "GetLogicalDrives: {0}", String::Join( ", ", drives ) ); -} - -/* -This example produces the following results: - -GetLogicalDrives: A:\, C:\, D:\ -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/Environment.MachineName/CPP/machinename.cpp b/snippets/cpp/VS_Snippets_CLR/Environment.MachineName/CPP/machinename.cpp deleted file mode 100644 index 344e571ae41..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Environment.MachineName/CPP/machinename.cpp +++ /dev/null @@ -1,19 +0,0 @@ - -// -// Sample for the Environment::MachineName property -using namespace System; -int main() -{ - Console::WriteLine(); - - // <-- Keep this information secure! --> - Console::WriteLine( "MachineName: {0}", Environment::MachineName ); -} - -/* -This example produces the following results: -(Any result that is lengthy, specific to the machine on which this sample was tested, or reveals information that should remain secure, has been omitted and marked S"!---OMITTED---!".) - -MachineName: !---OMITTED---! -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/Environment.NewLine/CPP/newline.cpp b/snippets/cpp/VS_Snippets_CLR/Environment.NewLine/CPP/newline.cpp deleted file mode 100644 index f1681245632..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Environment.NewLine/CPP/newline.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// -// Sample for the Environment::NewLine property -using namespace System; - -int main() -{ - Console::WriteLine(); - Console::WriteLine("NewLine: {0} first line {0} second line", Environment::NewLine); -} - -/* -This example produces the following results: - -NewLine: -first line -second line -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/Environment.StackTrace/CPP/stacktrace.cpp b/snippets/cpp/VS_Snippets_CLR/Environment.StackTrace/CPP/stacktrace.cpp deleted file mode 100644 index b6f0511a800..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Environment.StackTrace/CPP/stacktrace.cpp +++ /dev/null @@ -1,19 +0,0 @@ - -// -// Sample for the Environment::StackTrace property -using namespace System; -int main() -{ - Console::WriteLine(); - Console::WriteLine( "StackTrace: ' {0}'", Environment::StackTrace ); -} - -/* -This example produces the following results: - -StackTrace: ' at System::Environment::GetStackTrace(Exception e) -at System::Environment::GetStackTrace(Exception e) -at System::Environment::get_StackTrace() -at Sample::Main()' -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/Environment.SystemDirectory/CPP/systemdirectory.cpp b/snippets/cpp/VS_Snippets_CLR/Environment.SystemDirectory/CPP/systemdirectory.cpp deleted file mode 100644 index 687b4f85405..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Environment.SystemDirectory/CPP/systemdirectory.cpp +++ /dev/null @@ -1,18 +0,0 @@ - -// -// Sample for the Environment::SystemDirectory property -using namespace System; -int main() -{ - Console::WriteLine(); - - // <-- Keep this information secure! --> - Console::WriteLine( "SystemDirectory: {0}", Environment::SystemDirectory ); -} - -/* -This example produces the following results: - -SystemDirectory: C:\WINNT\System32 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/Environment.TickCount/CPP/tickcount.cpp b/snippets/cpp/VS_Snippets_CLR/Environment.TickCount/CPP/tickcount.cpp deleted file mode 100644 index 009bcb3a1d1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Environment.TickCount/CPP/tickcount.cpp +++ /dev/null @@ -1,20 +0,0 @@ - -// -// Sample for the Environment::TickCount property -// TickCount cycles between Int32::MinValue, which is a negative -// number, and Int32::MaxValue once every 49.8 days. This sample -// removes the sign bit to yield a nonnegative number that cycles -// between zero and Int32::MaxValue once every 24.9 days. -using namespace System; -int main() -{ - int result = Environment::TickCount & Int32::MaxValue; - Console::WriteLine( "TickCount: {0}", result ); -} - -/* -This example produces an output similar to the following: - -TickCount: 101931139 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/Environment.UserInteractive/CPP/userinteractive.cpp b/snippets/cpp/VS_Snippets_CLR/Environment.UserInteractive/CPP/userinteractive.cpp deleted file mode 100644 index b3fe458162d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Environment.UserInteractive/CPP/userinteractive.cpp +++ /dev/null @@ -1,16 +0,0 @@ - -// -// Sample for the Environment::UserInteractive property -using namespace System; -int main() -{ - Console::WriteLine(); - Console::WriteLine( "UserInteractive: {0}", Environment::UserInteractive ); -} - -/* -This example produces the following results: - -UserInteractive: True -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/Environment.UserName/CPP/username.cpp b/snippets/cpp/VS_Snippets_CLR/Environment.UserName/CPP/username.cpp deleted file mode 100644 index 9fd924b3c30..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Environment.UserName/CPP/username.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -// Sample for the Environment::UserName property -using namespace System; -int main() -{ - Console::WriteLine(); - - // <-- Keep this information secure! --> - Console::WriteLine( "UserName: {0}", Environment::UserName ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Environment.Version/CPP/version.cpp b/snippets/cpp/VS_Snippets_CLR/Environment.Version/CPP/version.cpp deleted file mode 100644 index cba784628bf..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Environment.Version/CPP/version.cpp +++ /dev/null @@ -1,17 +0,0 @@ - -// -// Sample for the Environment::Version property -using namespace System; -int main() -{ - Console::WriteLine(); - Console::WriteLine( "Version: {0}", Environment::Version ); -} - -/* -This example produces the following results: -(Any result that is lengthy, specific to the machine on which this sample was tested, or reveals information that should remain secure, has been omitted and marked S"!---OMITTED---!".) - -Version: !---OMITTED---! -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/Environment.WorkingSet/CPP/workingset.cpp b/snippets/cpp/VS_Snippets_CLR/Environment.WorkingSet/CPP/workingset.cpp deleted file mode 100644 index 10d59ac8fe5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Environment.WorkingSet/CPP/workingset.cpp +++ /dev/null @@ -1,15 +0,0 @@ - -// -// Sample for the Environment::WorkingSet property -using namespace System; -int main() -{ - Console::WriteLine( "WorkingSet: {0}", Environment::WorkingSet ); -} - -/* -This example produces the following results: - -WorkingSet: 5038080 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/ExToString/CPP/extostring.cpp b/snippets/cpp/VS_Snippets_CLR/ExToString/CPP/extostring.cpp deleted file mode 100644 index c94bc78e16b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ExToString/CPP/extostring.cpp +++ /dev/null @@ -1,34 +0,0 @@ - -// -using namespace System; - -public ref class TestClass{}; - -int main() -{ - TestClass^ test = gcnew TestClass; - array^ objectsToCompare = { test, test->ToString(), 123, - (123).ToString(), "some text", - "Some Text" }; - String^ s = "some text"; - for each (Object^ objectToCompare in objectsToCompare) { - try { - Int32 i = s->CompareTo(objectToCompare); - Console::WriteLine("Comparing '{0}' with '{1}': {2}", - s, objectToCompare, i); - } - catch (ArgumentException^ e) { - Console::WriteLine("Bad argument: {0} (type {1})", - objectToCompare, - objectToCompare->GetType()->Name); - } - } -} -// The example displays the following output: -// Bad argument: TestClass (type TestClass) -// Comparing 'some text' with 'TestClass': -1 -// Bad argument: 123 (type Int32) -// Comparing 'some text' with '123': 1 -// Comparing 'some text' with 'some text': 0 -// Comparing 'some text' with 'Some Text': -1 -// diff --git a/snippets/cpp/VS_Snippets_CLR/GCNotification/cpp/program.cpp b/snippets/cpp/VS_Snippets_CLR/GCNotification/cpp/program.cpp deleted file mode 100644 index 44aa0f37782..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/GCNotification/cpp/program.cpp +++ /dev/null @@ -1,242 +0,0 @@ -// -// -using namespace System; -using namespace System::Collections::Generic; -using namespace System::Threading; - -namespace GCNotify -{ - ref class Program - { - private: - // Variable for continual checking in the - // While loop in the WaitForFullGCProc method. - static bool checkForNotify = false; - - // Variable for suspending work - // (such servicing allocated server requests) - // after a notification is received and then - // resuming allocation after inducing a garbage collection. - static bool bAllocate = false; - - // Variable for ending the example. - static bool finalExit = false; - - // Collection for objects that - // simulate the server request workload. - static List^>^ load = gcnew List^>(); - - - public: - static void Main() - { - try - { - // Register for a notification. - GC::RegisterForFullGCNotification(10, 10); - Console::WriteLine("Registered for GC notification."); - - checkForNotify = true; - bAllocate = true; - - // Start a thread using WaitForFullGCProc. - Thread^ thWaitForFullGC = gcnew Thread(gcnew ThreadStart(&WaitForFullGCProc)); - thWaitForFullGC->Start(); - - // While the thread is checking for notifications in - // WaitForFullGCProc, create objects to simulate a server workload. - try - { - int lastCollCount = 0; - int newCollCount = 0; - - - while (true) - { - if (bAllocate) - { - load->Add(gcnew array(1000)); - newCollCount = GC::CollectionCount(2); - if (newCollCount != lastCollCount) - { - // Show collection count when it increases: - Console::WriteLine("Gen 2 collection count: {0}", GC::CollectionCount(2).ToString()); - lastCollCount = newCollCount; - } - - // For ending the example (arbitrary). - if (newCollCount == 500) - { - finalExit = true; - checkForNotify = false; - break; - } - } - } - - } - catch (OutOfMemoryException^) - { - Console::WriteLine("Out of memory."); - } - - - // - finalExit = true; - checkForNotify = false; - GC::CancelFullGCNotification(); - // - - } - catch (InvalidOperationException^ invalidOp) - { - - Console::WriteLine("GC Notifications are not supported while concurrent GC is enabled.\n" - + invalidOp->Message); - } - } - - // - public: - static void OnFullGCApproachNotify() - { - Console::WriteLine("Redirecting requests."); - - // Method that tells the request queuing - // server to not direct requests to this server. - RedirectRequests(); - - // Method that provides time to - // finish processing pending requests. - FinishExistingRequests(); - - // This is a good time to induce a GC collection - // because the runtime will induce a full GC soon. - // To be very careful, you can check precede with a - // check of the GC.GCCollectionCount to make sure - // a full GC did not already occur since last notified. - GC::Collect(); - Console::WriteLine("Induced a collection."); - - } - // - - - // - public: - static void OnFullGCCompleteEndNotify() - { - // Method that informs the request queuing server - // that this server is ready to accept requests again. - AcceptRequests(); - Console::WriteLine("Accepting requests again."); - } - // - - // - public: - static void WaitForFullGCProc() - { - while (true) - { - // CheckForNotify is set to true and false in Main. - while (checkForNotify) - { - // - // Check for a notification of an approaching collection. - GCNotificationStatus s = GC::WaitForFullGCApproach(); - if (s == GCNotificationStatus::Succeeded) - { - Console::WriteLine("GC Notifiction raised."); - OnFullGCApproachNotify(); - } - else if (s == GCNotificationStatus::Canceled) - { - Console::WriteLine("GC Notification cancelled."); - break; - } - else - { - // This can occur if a timeout period - // is specified for WaitForFullGCApproach(Timeout) - // or WaitForFullGCComplete(Timeout) - // and the time out period has elapsed. - Console::WriteLine("GC Notification not applicable."); - break; - } - // - - // - // Check for a notification of a completed collection. - s = GC::WaitForFullGCComplete(); - if (s == GCNotificationStatus::Succeeded) - { - Console::WriteLine("GC Notification raised."); - OnFullGCCompleteEndNotify(); - } - else if (s == GCNotificationStatus::Canceled) - { - Console::WriteLine("GC Notification cancelled."); - break; - } - else - { - // Could be a time out. - Console::WriteLine("GC Notification not applicable."); - break; - } - // - } - - - Thread::Sleep(500); - // FinalExit is set to true right before - // the main thread cancelled notification. - if (finalExit) - { - break; - } - } - } - // - - // - private: - static void RedirectRequests() - { - // Code that sends requests - // to other servers. - - // Suspend work. - bAllocate = false; - - } - - static void FinishExistingRequests() - { - // Code that waits a period of time - // for pending requests to finish. - - // Clear the simulated workload. - load->Clear(); - - } - - static void AcceptRequests() - { - // Code that resumes processing - // requests on this server. - - // Resume work. - bAllocate = true; - } - // - }; -} - -int main() -{ - GCNotify::Program::Main(); -} -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/ca1.cpp b/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/ca1.cpp deleted file mode 100644 index d3c27fc9117..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/ca1.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -[assembly:AssemblyTitle("CustAttrs1CPP")]; -[assembly:AssemblyDescription("GetCustomAttributes() Demo")]; -[assembly:AssemblyCompany("Microsoft")]; - -ref class Example -{}; - -static void main() -{ - Type^ clsType = Example::typeid; - - // Get the Assembly type to access its metadata. - Assembly^ assy = clsType->Assembly; - - // Iterate through the attributes for the assembly. - System::Collections::IEnumerator^ myEnum = Attribute::GetCustomAttributes( assy )->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Attribute^ attr = safe_cast(myEnum->Current); - - // Check for the AssemblyTitle attribute. - if ( attr->GetType() == AssemblyTitleAttribute::typeid ) - Console::WriteLine( "Assembly title is \"{0}\".", (dynamic_cast(attr))->Title ); - // Check for the AssemblyDescription attribute. - else - // Check for the AssemblyDescription attribute. - if ( attr->GetType() == AssemblyDescriptionAttribute::typeid ) - Console::WriteLine( "Assembly description is \"{0}\".", (dynamic_cast(attr))->Description ); - // Check for the AssemblyCompany attribute. - else if ( attr->GetType() == AssemblyCompanyAttribute::typeid ) - Console::WriteLine( "Assembly company is {0}.", (dynamic_cast(attr))->Company ); - } -} -// The example displays the following output: -// Assembly description is "GetCustomAttributes() Demo". -// Assembly company is Microsoft. -// Assembly title is "CustAttrs1CPP". -// diff --git a/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp b/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp deleted file mode 100644 index 1756e0d976f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp +++ /dev/null @@ -1,258 +0,0 @@ - - -// -using namespace System; -using namespace System::Reflection; -using namespace System::ComponentModel; - -// Assign some attributes to the module. -// Set the module's CLSCompliant attribute to false -// The CLSCompliant attribute is applicable for /target:module. -[module:Description("A sample description")]; -[module:CLSCompliant(false)]; -namespace CustAttrs2CS -{ - ref class DemoClass - { - public: - static void Main() - { - Type^ clsType = DemoClass::typeid; - - // Get the Module type to access its metadata. - Module^ module = clsType->Module; - - // Iterate through all the attributes for the module. - System::Collections::IEnumerator^ myEnum1 = Attribute::GetCustomAttributes( module )->GetEnumerator(); - while ( myEnum1->MoveNext() ) - { - Attribute^ attr = safe_cast(myEnum1->Current); - - // Check for the Description attribute. - if ( attr->GetType() == DescriptionAttribute::typeid ) - Console::WriteLine( "Module {0} has the description \"{1}\".", module->Name, (dynamic_cast(attr))->Description ); - // Check for the CLSCompliant attribute. - else - - // Check for the CLSCompliant attribute. - if ( attr->GetType() == CLSCompliantAttribute::typeid ) - Console::WriteLine( "Module {0} {1} CLSCompliant.", module->Name, (dynamic_cast(attr))->IsCompliant ? (String^)"is" : "is not" ); - } - } - }; -} - - -/* - * Output: - * Module CustAttrs2CS.exe is not CLSCompliant. - * Module CustAttrs2CS.exe has the description "A sample description". - */ -// -// -using namespace System; -using namespace System::Runtime::InteropServices; - -namespace CustAttrs3CS -{ - // Set a GUID and ProgId attribute for this class. - - [Guid("BF235B41-52D1-46CC-9C55-046793DB363F")] - [ProgId("CustAttrs3CS.ClassWithGuidAndProgId")] - public ref class ClassWithGuidAndProgId{}; - - ref class DemoClass - { - public: - static void Main() - { - // Get the Class type to access its metadata. - Type^ clsType = ClassWithGuidAndProgId::typeid; - - // Iterate through all the attributes for the class. - System::Collections::IEnumerator^ myEnum2 = Attribute::GetCustomAttributes( clsType )->GetEnumerator(); - while ( myEnum2->MoveNext() ) - { - Attribute^ attr = safe_cast(myEnum2->Current); - - // Check for the Guid attribute. - if ( attr->GetType() == GuidAttribute::typeid ) - { - // Display the GUID. - Console::WriteLine( "Class {0} has a GUID.", clsType->Name ); - Console::WriteLine( "GUID: {{0}}.", (dynamic_cast(attr))->Value ); - } - // Check for the ProgId attribute. - else - - // Check for the ProgId attribute. - if ( attr->GetType() == ProgIdAttribute::typeid ) - { - // Display the ProgId. - Console::WriteLine( "Class {0} has a ProgId.", clsType->Name ); - Console::WriteLine( "ProgId: \"{0}\".", (dynamic_cast(attr))->Value ); - } - } - } - }; -} - - -/* - * Output: - * Class ClassWithGuidAndProgId has a GUID. - * GUID: {BF235B41-52D1-46CC-9C55-046793DB363F}. - * Class ClassWithGuidAndProgId has a ProgId. - * ProgId: "CustAttrs3CS.ClassWithGuidAndProgId". - */ -// -// -using namespace System; -using namespace System::Reflection; -using namespace System::Security; -using namespace System::Runtime::InteropServices; - -namespace CustAttrs4CS -{ - // Create a class for Win32 imported unmanaged functions. - public ref class Win32 - { - public: - - [DllImport("user32.dll", CharSet = CharSet::Unicode)] - static int MessageBox( int hWnd, String^ text, String^ caption, UInt32 type ); - }; - - public ref class AClass - { - public: - - // Add some attributes to the Win32CallMethod. - - [Obsolete("This method is obsolete. Use managed MsgBox instead.")] - void Win32CallMethod() - { - Win32::MessageBox( 0, "This is an unmanaged call.", "Be Careful!", 0 ); - } - - }; - - ref class DemoClass - { - public: - static void Main() - { - // Get the Class type to access its metadata. - Type^ clsType = AClass::typeid; - - // Get the type information for the Win32CallMethod. - MethodInfo^ mInfo = clsType->GetMethod( "Win32CallMethod" ); - if ( mInfo != nullptr ) - { - // Iterate through all the attributes for the method. - System::Collections::IEnumerator^ myEnum3 = Attribute::GetCustomAttributes( mInfo )->GetEnumerator(); - while ( myEnum3->MoveNext() ) - { - Attribute^ attr = safe_cast(myEnum3->Current); - - // Check for the Obsolete attribute. - if ( attr->GetType() == ObsoleteAttribute::typeid ) - { - Console::WriteLine( "Method {0} is obsolete. " - "The message is:", mInfo->Name ); - Console::WriteLine( (dynamic_cast(attr))->Message ); - } - // Check for the SuppressUnmanagedCodeSecurity attribute. - else - - // Check for the SuppressUnmanagedCodeSecurity attribute. - if ( attr->GetType() == SuppressUnmanagedCodeSecurityAttribute::typeid ) - { - Console::WriteLine( "This method calls unmanaged code " - "with no security check." ); - Console::WriteLine( "Please do not use unless absolutely necessary." ); - AClass^ myCls = gcnew AClass; - myCls->Win32CallMethod(); - } - } - } - } - }; -} - - -/* - * Output: - * Method Win32CallMethod is obsolete. The message is: - * This method is obsolete. Use managed MsgBox instead. - * This method calls unmanaged code with no security check. - * Please do not use unless absolutely necessary. - */ -// -// -using namespace System; -using namespace System::Reflection; -using namespace System::ComponentModel; - -namespace CustAttrs5CS -{ - public ref class AClass - { - public: - void ParamArrayAndDesc( - // Add ParamArray and Description attributes. - [Description("This argument is a ParamArray")] - array^args ) - {} - }; - - ref class DemoClass - { - public: - static void Main() - { - // Get the Class type to access its metadata. - Type^ clsType = AClass::typeid; - - // Get the type information for the method. - MethodInfo^ mInfo = clsType->GetMethod( "ParamArrayAndDesc" ); - if ( mInfo != nullptr ) - { - // Get the parameter information. - array^pInfo = mInfo->GetParameters(); - if ( pInfo != nullptr ) - { - // Iterate through all the attributes for the parameter. - System::Collections::IEnumerator^ myEnum4 = Attribute::GetCustomAttributes( pInfo[ 0 ] )->GetEnumerator(); - while ( myEnum4->MoveNext() ) - { - Attribute^ attr = safe_cast(myEnum4->Current); - - // Check for the ParamArray attribute. - if ( attr->GetType() == ParamArrayAttribute::typeid ) - Console::WriteLine( "Parameter {0} for method {1} " - "has the ParamArray attribute.", pInfo[ 0 ]->Name, mInfo->Name ); - // Check for the Description attribute. - else - - // Check for the Description attribute. - if ( attr->GetType() == DescriptionAttribute::typeid ) - { - Console::WriteLine( "Parameter {0} for method {1} " - "has a description attribute.", pInfo[ 0 ]->Name, mInfo->Name ); - Console::WriteLine( "The description is: \"{0}\"", (dynamic_cast(attr))->Description ); - } - } - } - } - } - }; -} - -/* - * Output: - * Parameter args for method ParamArrayAndDesc has the ParamArray attribute. - * Parameter args for method ParamArrayAndDesc has a description attribute. - * The description is: "This argument is a ParamArray" - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/IComparable Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/IComparable Example/CPP/source.cpp deleted file mode 100644 index b421c5517db..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/IComparable Example/CPP/source.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// IComparableExample.cpp : main project file. - -// -using namespace System; -using namespace System::Collections; - -public ref class Temperature: public IComparable { - /// - /// IComparable.CompareTo implementation. - /// -protected: - // The value holder - Double m_value; - -public: - virtual Int32 CompareTo( Object^ obj ) { - - if (obj == nullptr) return 1; - - if ( obj->GetType() == Temperature::typeid ) { - Temperature^ temp = dynamic_cast(obj); - - return m_value.CompareTo( temp->m_value ); - } - throw gcnew ArgumentException( "object is not a Temperature" ); - } - - property Double Value { - Double get() { - return m_value; - } - void set( Double value ) { - m_value = value; - } - } - - property Double Celsius { - Double get() { - return (m_value - 32) / 1.8; - } - void set( Double value ) { - m_value = (value * 1.8) + 32; - } - } -}; - -int main() -{ - ArrayList^ temperatures = gcnew ArrayList; - // Initialize random number generator. - Random^ rnd = gcnew Random; - - // Generate 10 temperatures between 0 and 100 randomly. - for (int ctr = 1; ctr <= 10; ctr++) - { - int degrees = rnd->Next(0, 100); - Temperature^ temp = gcnew Temperature; - temp->Value = degrees; - temperatures->Add(temp); - } - - // Sort ArrayList. - temperatures->Sort(); - - for each (Temperature^ temp in temperatures) - Console::WriteLine(temp->Value); - return 0; -} -// The example displays the following output to the console (individual -// values may vary because they are randomly generated): -// 2 -// 7 -// 16 -// 17 -// 31 -// 37 -// 58 -// 66 -// 72 -// 95 -// diff --git a/snippets/cpp/VS_Snippets_CLR/IComparable`1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/IComparable`1 Example/CPP/source.cpp deleted file mode 100644 index 8c4f0f164e3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/IComparable`1 Example/CPP/source.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Collections::Generic; - -public ref class Temperature: public IComparable { - -protected: - // The underlying temperature value. - Double m_value; - -public: - // Implement the generic CompareTo method with the Temperature class - // as the Type parameter. - virtual Int32 CompareTo( Temperature^ other ) { - - // If other is not a valid object reference, this instance - // is greater. - if (other == nullptr) return 1; - - // The temperature comparison depends on the comparison of the - // the underlying Double values. - return m_value.CompareTo( other->m_value ); - } - - // Define the is greater than operator. - bool operator>= (Temperature^ other) - { - return CompareTo(other) >= 0; - } - - // Define the is less than operator. - bool operator< (Temperature^ other) - { - return CompareTo(other) < 0; - } - - // Define the is greater than or equal to operator. - bool operator> (Temperature^ other) - { - return CompareTo(other) > 0; - } - - // Define the is less than or equal to operator. - bool operator<= (Temperature^ other) - { - return CompareTo(other) <= 0; - } - - property Double Celsius { - Double get() { - return m_value + 273.15; - } - } - - property Double Kelvin { - Double get() { - return m_value; - } - void set( Double value ) { - if (value < 0) - throw gcnew ArgumentException("Temperature cannot be less than absolute zero."); - else - m_value = value; - } - } - - Temperature(Double kelvins) { - this->Kelvin = kelvins; - } -}; - -int main() { - SortedList^ temps = - gcnew SortedList(); - - // Add entries to the sorted list, out of order. - temps->Add(gcnew Temperature(2017.15), "Boiling point of Lead"); - temps->Add(gcnew Temperature(0), "Absolute zero"); - temps->Add(gcnew Temperature(273.15), "Freezing point of water"); - temps->Add(gcnew Temperature(5100.15), "Boiling point of Carbon"); - temps->Add(gcnew Temperature(373.15), "Boiling point of water"); - temps->Add(gcnew Temperature(600.65), "Melting point of Lead"); - - for each( KeyValuePair^ kvp in temps ) - { - Console::WriteLine("{0} is {1} degrees Celsius.", kvp->Value, kvp->Key->Celsius); - } -} -/* The example displays the following output: - Absolute zero is 273.15 degrees Celsius. - Freezing point of water is 546.3 degrees Celsius. - Boiling point of water is 646.3 degrees Celsius. - Melting point of Lead is 873.8 degrees Celsius. - Boiling point of Lead is 2290.3 degrees Celsius. - Boiling point of Carbon is 5373.3 degrees Celsius. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/IO.File.GetAccessControl-SetAccessControl/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/IO.File.GetAccessControl-SetAccessControl/cpp/sample.cpp deleted file mode 100644 index 5bd01722472..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/IO.File.GetAccessControl-SetAccessControl/cpp/sample.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Security::AccessControl; - -// Adds an ACL entry on the specified file for the specified account. - -void AddFileSecurity(String^ fileName, String^ account, - FileSystemRights rights, AccessControlType controlType) -{ - // Get a FileSecurity object that represents the - // current security settings. - FileSecurity^ fSecurity = File::GetAccessControl(fileName); - - // Add the FileSystemAccessRule to the security settings. - fSecurity->AddAccessRule(gcnew FileSystemAccessRule - (account,rights, controlType)); - - // Set the new access settings. - File::SetAccessControl(fileName, fSecurity); -} - -// Removes an ACL entry on the specified file for the specified account. - -void RemoveFileSecurity(String^ fileName, String^ account, - FileSystemRights rights, AccessControlType controlType) -{ - - // Get a FileSecurity object that represents the - // current security settings. - FileSecurity^ fSecurity = File::GetAccessControl(fileName); - - // Remove the FileSystemAccessRule from the security settings. - fSecurity->RemoveAccessRule(gcnew FileSystemAccessRule - (account,rights, controlType)); - - // Set the new access settings. - File::SetAccessControl(fileName, fSecurity); -} - -int main() -{ - try - { - String^ fileName = "test.xml"; - - Console::WriteLine("Adding access control entry for " + fileName); - - // Add the access control entry to the file. - AddFileSecurity(fileName, "MYDOMAIN\\MyAccount", - FileSystemRights::ReadData, AccessControlType::Allow); - - Console::WriteLine("Removing access control entry from " + fileName); - - // Remove the access control entry from the file. - RemoveFileSecurity(fileName, "MYDOMAIN\\MyAccount", - FileSystemRights::ReadData, AccessControlType::Allow); - - Console::WriteLine("Done."); - } - catch (Exception^ ex) - { - Console::WriteLine(ex->Message); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/ImprovedInteropSnippets/CPP/codefile1.cpp b/snippets/cpp/VS_Snippets_CLR/ImprovedInteropSnippets/CPP/codefile1.cpp deleted file mode 100644 index f485421aac8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ImprovedInteropSnippets/CPP/codefile1.cpp +++ /dev/null @@ -1,14 +0,0 @@ - -//System::Runtime::InteropServices::IDispatchImplAttribute* -//System::Runtime::InteropServices::IDispatchImplType* -// -using namespace System; -using namespace System::Runtime::InteropServices; - -// by default all classes in this assembly will use COM implementaion -// // But this class will use runtime implementaion - -[assembly:IDispatchImpl(IDispatchImplType::CompatibleImpl)]; -[IDispatchImpl(IDispatchImplType::InternalImpl)] -ref class MyClass{}; -// diff --git a/snippets/cpp/VS_Snippets_CLR/InnerEx/CPP/innerex.cpp b/snippets/cpp/VS_Snippets_CLR/InnerEx/CPP/innerex.cpp deleted file mode 100644 index b75ca626687..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/InnerEx/CPP/innerex.cpp +++ /dev/null @@ -1,53 +0,0 @@ - -// -using namespace System; - -public ref class AppException: public Exception -{ -public: - AppException(String^ message ) : Exception(message) - {} - - AppException(String^ message, Exception^ inner) : Exception(message, inner) - {} -}; - -public ref class Example -{ -public: - void ThrowInner() - { - throw gcnew AppException("Exception in ThrowInner method."); - } - - void CatchInner() - { - try { - this->ThrowInner(); - } - catch (AppException^ e) { - throw gcnew AppException("Error in CatchInner caused by calling the ThrowInner method.", e); - } - } -}; - -int main() -{ - Example^ ex = gcnew Example(); - try { - ex->CatchInner(); - } - catch (AppException^ e) { - Console::WriteLine("In catch block of Main method."); - Console::WriteLine("Caught: {0}", e->Message); - if (e->InnerException != nullptr) - Console::WriteLine("Inner exception: {0}", e->InnerException); - } -} -// The example displays the following output: -// In catch block of Main method. -// Caught: Error in CatchInner caused by calling the ThrowInner method. -// Inner exception: AppException: Exception in ThrowInner method. -// at Example.ThrowInner() -// at Example.CatchInner() -// diff --git a/snippets/cpp/VS_Snippets_CLR/Int16_Equals/CPP/int16_equals.cpp b/snippets/cpp/VS_Snippets_CLR/Int16_Equals/CPP/int16_equals.cpp deleted file mode 100644 index 0d107fe1e0e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Int16_Equals/CPP/int16_equals.cpp +++ /dev/null @@ -1,357 +0,0 @@ - -// System::Int16::Equals(Object) -/* -The following program demonstrates the 'Equals(Object)' method -of struct 'Int16'. This compares an instance of 'Int16' with the -passed in Object* and returns true if they are equal. -*/ -using namespace System; -int main() -{ - try - { - - // - Int16 myVariable1 = 20; - Int16 myVariable2 = 20; - - // Get and display the declaring type. - Console::WriteLine( "\nType of 'myVariable1' is '{0}' and value is : {1}", myVariable1.GetType(), myVariable1 ); - Console::WriteLine( "Type of 'myVariable2' is '{0}' and value is : {1}", myVariable2.GetType(), myVariable2 ); - - // Compare 'myVariable1' instance with 'myVariable2' Object. - if ( myVariable1.Equals( myVariable2 ) ) - Console::WriteLine( "\nStructures 'myVariable1' and 'myVariable2' are equal" ); - else - Console::WriteLine( "\nStructures 'myVariable1' and 'myVariable2' are not equal" ); - - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - } - -} - -/* expected return values: -20'F --6'C -20'F -0 -72'F --52 -*/ -/* -namespace Snippets2 { - // - - public __gc class Temperature { - // The value holder - protected: - short m_value; - - public: - __property static short get_MinValue() { - return Int16.MinValue; - } - - __property static short get_MaxValue() { - return Int16.MaxValue; - } - - __property short get_Value(){ - return m_value; - } - __property void set_Value( short value){ - m_value = value; - } - - __property short get_Celsius(){ - return (short)((m_value-32)/2); - } - - __property void set_Celsius( short value){ - m_value = (short)(value*2+32); - } - } - // -} - -namespace Snippets3 { - // - public __gc class Temperature : IComparable { - /// - /// IComparable.CompareTo implementation. - /// - // The value holder - protected: - short m_value; - - public: - Int32 CompareTo(Object* obj) { - if(obj->GetType() == __typeof(Temperature)) { - Temperature temp = dynamic_cast(obj); - return m_value.CompareTo(temp.m_value); - } - - throw new ArgumentException("object is not a Temperature"); - } - - __property short get_Value() { - return m_value; - } - - __property void set_Value( short value) { - m_value = value; - } - - __property short get_Celsius() { - return (short)((m_value-32)/2); - } - - __property void set_Celsius( Int32 value) { - m_value = (short)(value*2+32); - } - } - // -} - -namespace Snippets4 { - // - public __gc class Temperature : IFormattable { - /// - /// IFormattable.ToString implementation. - /// - // The value holder - protected: - short m_value; - - public: - String* ToString(String* format, IFormatProvider provider) { - if( format != NULL ) { - if( format->Equals("F") ) { - return String::Format("{0}'F", this->Value->ToString()); - } - if( format->Equals("C") ) { - return String::Format("{0}'C", this->Celsius->ToString()); - } - } - - return m_value->ToString(format, provider); - } - - __property short get_Value() { - return m_value; - } - - __property void set_Value( short value) { - m_value = value; - } - - __property short get_Celsius() { - return (short)((m_value-32)/2); - } - - __property void set_Celsius( short value) { - m_value = (short)(value*2+32); - } - } - // -} -namespace Snippets5 { - // - public __gc class Temperature { - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - // The value holder - protected: - short m_value; - - public: - static Temperature* Parse(String* s) { - Temperature* temp = new Temperature(); - - if( s->TrimEnd(NULL)->EndsWith("'F") ) { - temp->Value = Int16::Parse( s->Remove(s->LastIndexOf('\''), 2) ); - } - else { - if( s->TrimEnd(NULL)->EndsWith("'C") ) { - temp->Celsius = Int16::Parse( s->Remove(s->LastIndexOf('\''), 2) ); - } - else { - temp->Value = Int16::Parse(s); - } - } - return temp; - } - - __property short get_Value() { - return m_value; - } - - __property void set_Value( short value) { - m_value = value; - } - - __property short get_Celsius() { - return (short)((m_value-32)/2); - } - - __property void set_Celsius( short value) { - m_value = (short)(value*2+32); - } - } - } - // -} -namespace Snippets6 { - // - public class Temperature { - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - - // The value holder - protected: - short m_value; - - public: - static Temperature* Parse(String* s, IFormatProvider provider) { - Temperature* temp = new Temperature(); - - if( s->TrimEnd(NULL)->EndsWith("'F") ) { - temp->Value = Int16::Parse( s->Remove(s->LastIndexOf('\''), 2), provider); - } - else { - if( s->TrimEnd(NULL)->EndsWith("'C") ) { - temp->Celsius = Int16::Parse( s->Remove(s->LastIndexOf('\''), 2), provider); - } - else { - temp->Value = Int16::Parse(s, provider); - } - } - - return temp; - } - - __property short get_Value() { - return m_value; - } - - __property void set_Value( short value) { - m_value = value; - } - - __property short get_Celsius() { - return (short)((m_value-32)/2); - } - - __property void set_Celsius( short value) { - m_value = (short)(value*2+32); - } - } - // -} -namespace Snippets7 { - // - public class Temperature { - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - - // The value holder - protected: - short m_value; - - public: - static Temperature* Parse(String* s, NumberStyles styles) { - Temperature* temp = new Temperature(); - - if( s->TrimEnd(NULL)->EndsWith("'F") ) { - temp->Value = Int16::Parse( s->Remove(s->LastIndexOf('\''), 2), styles); - } - else { - if( s->TrimEnd(NULL)->EndsWith("'C") ) { - temp->Celsius = Int16::Parse( s->Remove(s->LastIndexOf('\''), 2), styles); - } - else { - temp->Value = Int16::Parse(s, styles); - } - } - - return temp; - } - - __property short get_Value() { - return m_value; - } - - __property void set_Value( short value) { - m_value = value; - } - - __property short get_Celsius() { - return (short)((m_value-32)/2); - } - - __property void set_Celsius( short value) { - m_value = (short)(value*2+32); - } - } - // -} -namespace Snippets8 { - // - public class Temperature { - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - - // The value holder - protected: - short m_value; - - public: - static Temperature* Parse(String* s, NumberStyles styles, IFormatProvider* provider) { - Temperature* temp = new Temperature(); - - if( s->TrimEnd(NULL)->EndsWith("'F") ) { - temp->Value = Int16::Parse( s->Remove(s->LastIndexOf('\''), 2), styles, provider); - } - else { - if( s->TrimEnd(NULL)->EndsWith("'C") ) { - temp->Celsius = Int16::Parse( s->Remove(s->LastIndexOf('\''), 2), styles, provider); - } - else { - temp->Value = Int16::Parse(s, styles, provider); - } - } - - return temp; - } - - __property short get_Value() { - return m_value; - } - - __property void set_Value( short value) { - m_value = value; - } - - __property short get_Celsius() { - return (short)((m_value-32)/2); - } - - __property void set_Celsius( short value) { - m_value = (short)(value*2+32); - } - } - // -} -*/ diff --git a/snippets/cpp/VS_Snippets_CLR/Int32_Equals/CPP/int32_equals.cpp b/snippets/cpp/VS_Snippets_CLR/Int32_Equals/CPP/int32_equals.cpp deleted file mode 100644 index a5199f2b75d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Int32_Equals/CPP/int32_equals.cpp +++ /dev/null @@ -1,357 +0,0 @@ - -// System::Int32::Equals(Object) -/* -The following program demonstrates the 'Equals(Object)' method -of struct 'Int32'. This compares an instance of 'Int32' with the -passed in object and returns true if they are equal. -*/ -using namespace System; -int main() -{ - try - { - - // - Int32 myVariable1 = 60; - Int32 myVariable2 = 60; - - // Get and display the declaring type. - Console::WriteLine( "\nType of 'myVariable1' is '{0}' and value is : {1}", myVariable1.GetType(), myVariable1 ); - Console::WriteLine( "Type of 'myVariable2' is '{0}' and value is : {1}", myVariable2.GetType(), myVariable2 ); - - // Compare 'myVariable1' instance with 'myVariable2' Object. - if ( myVariable1.Equals( myVariable2 ) ) - Console::WriteLine( "\nStructures 'myVariable1' and 'myVariable2' are equal" ); - else - Console::WriteLine( "\nStructures 'myVariable1' and 'myVariable2' are not equal" ); - - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - } - -} - -/* expected return values: -20'F --6'C -20'F -0 -72'F --52 -*/ -/* -namespace Snippets2 { - // - - public __gc class Temperature { - // The value holder - protected: - short m_value; - - public: - __property static short get_MinValue() { - return Int32.MinValue; - } - - __property static short get_MaxValue() { - return Int32.MaxValue; - } - - __property short get_Value(){ - return m_value; - } - __property void set_Value( short value){ - m_value = value; - } - - __property short get_Celsius(){ - return (short)((m_value-32)/2); - } - - __property void set_Celsius( short value){ - m_value = (short)(value*2+32); - } - } - // -} - -namespace Snippets3 { - // - public __gc class Temperature : IComparable { - /// - /// IComparable.CompareTo implementation. - /// - // The value holder - protected: - short m_value; - - public: - Int32 CompareTo(Object* obj) { - if(obj->GetType() == __typeof(Temperature)) { - Temperature temp = dynamic_cast(obj); - return m_value.CompareTo(temp.m_value); - } - - throw new ArgumentException("object is not a Temperature"); - } - - __property short get_Value() { - return m_value; - } - - __property void set_Value( short value) { - m_value = value; - } - - __property short get_Celsius() { - return (short)((m_value-32)/2); - } - - __property void set_Celsius( Int32 value) { - m_value = (short)(value*2+32); - } - } - // -} - -namespace Snippets4 { - // - public __gc class Temperature : IFormattable { - /// - /// IFormattable.ToString implementation. - /// - // The value holder - protected: - short m_value; - - public: - String* ToString(String* format, IFormatProvider provider) { - if( format != NULL ) { - if( format->Equals("F") ) { - return String::Format("{0}'F", this->Value->ToString()); - } - if( format->Equals("C") ) { - return String::Format("{0}'C", this->Celsius->ToString()); - } - } - - return m_value->ToString(format, provider); - } - - __property short get_Value() { - return m_value; - } - - __property void set_Value( short value) { - m_value = value; - } - - __property short get_Celsius() { - return (short)((m_value-32)/2); - } - - __property void set_Celsius( short value) { - m_value = (short)(value*2+32); - } - } - // -} -namespace Snippets5 { - // - public __gc class Temperature { - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - // The value holder - protected: - short m_value; - - public: - static Temperature* Parse(String* s) { - Temperature* temp = new Temperature(); - - if( s->TrimEnd(NULL)->EndsWith("'F") ) { - temp->Value = Int32::Parse( s->Remove(s->LastIndexOf('\''), 2) ); - } - else { - if( s->TrimEnd(NULL)->EndsWith("'C") ) { - temp->Celsius = Int32::Parse( s->Remove(s->LastIndexOf('\''), 2) ); - } - else { - temp->Value = Int32::Parse(s); - } - } - return temp; - } - - __property short get_Value() { - return m_value; - } - - __property void set_Value( short value) { - m_value = value; - } - - __property short get_Celsius() { - return (short)((m_value-32)/2); - } - - __property void set_Celsius( short value) { - m_value = (short)(value*2+32); - } - } - } - // -} -namespace Snippets6 { - // - public class Temperature { - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - - // The value holder - protected: - short m_value; - - public: - static Temperature* Parse(String* s, IFormatProvider provider) { - Temperature* temp = new Temperature(); - - if( s->TrimEnd(NULL)->EndsWith("'F") ) { - temp->Value = Int32::Parse( s->Remove(s->LastIndexOf('\''), 2), provider); - } - else { - if( s->TrimEnd(NULL)->EndsWith("'C") ) { - temp->Celsius = Int32::Parse( s->Remove(s->LastIndexOf('\''), 2), provider); - } - else { - temp->Value = Int32::Parse(s, provider); - } - } - - return temp; - } - - __property short get_Value() { - return m_value; - } - - __property void set_Value( short value) { - m_value = value; - } - - __property short get_Celsius() { - return (short)((m_value-32)/2); - } - - __property void set_Celsius( short value) { - m_value = (short)(value*2+32); - } - } - // -} -namespace Snippets7 { - // - public class Temperature { - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - - // The value holder - protected: - short m_value; - - public: - static Temperature* Parse(String* s, NumberStyles styles) { - Temperature* temp = new Temperature(); - - if( s->TrimEnd(NULL)->EndsWith("'F") ) { - temp->Value = Int32::Parse( s->Remove(s->LastIndexOf('\''), 2), styles); - } - else { - if( s->TrimEnd(NULL)->EndsWith("'C") ) { - temp->Celsius = Int32::Parse( s->Remove(s->LastIndexOf('\''), 2), styles); - } - else { - temp->Value = Int32::Parse(s, styles); - } - } - - return temp; - } - - __property short get_Value() { - return m_value; - } - - __property void set_Value( short value) { - m_value = value; - } - - __property short get_Celsius() { - return (short)((m_value-32)/2); - } - - __property void set_Celsius( short value) { - m_value = (short)(value*2+32); - } - } - // -} -namespace Snippets8 { - // - public class Temperature { - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - - // The value holder - protected: - short m_value; - - public: - static Temperature* Parse(String* s, NumberStyles styles, IFormatProvider* provider) { - Temperature* temp = new Temperature(); - - if( s->TrimEnd(NULL)->EndsWith("'F") ) { - temp->Value = Int32::Parse( s->Remove(s->LastIndexOf('\''), 2), styles, provider); - } - else { - if( s->TrimEnd(NULL)->EndsWith("'C") ) { - temp->Celsius = Int32::Parse( s->Remove(s->LastIndexOf('\''), 2), styles, provider); - } - else { - temp->Value = Int32::Parse(s, styles, provider); - } - } - - return temp; - } - - __property short get_Value() { - return m_value; - } - - __property void set_Value( short value) { - m_value = value; - } - - __property short get_Celsius() { - return (short)((m_value-32)/2); - } - - __property void set_Celsius( short value) { - m_value = (short)(value*2+32); - } - } - // -} -*/ diff --git a/snippets/cpp/VS_Snippets_CLR/Int64_Equals/CPP/int64_equals.cpp b/snippets/cpp/VS_Snippets_CLR/Int64_Equals/CPP/int64_equals.cpp deleted file mode 100644 index b4f54b5d004..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Int64_Equals/CPP/int64_equals.cpp +++ /dev/null @@ -1,357 +0,0 @@ - -// System::Int64::Equals(Object) -/* -The following program demonstrates the 'Equals(Object)' method -of struct 'Int64'. This compares an instance of 'Int64' with the -passed in Object and returns true if they are equal. -*/ -using namespace System; -int main() -{ - try - { - - // - Int64 myVariable1 = 80; - Int64 myVariable2 = 80; - - // Get and display the declaring type. - Console::WriteLine( "\nType of 'myVariable1' is ' {0}' and value is : {1}", myVariable1.GetType(), myVariable1 ); - Console::WriteLine( "Type of 'myVariable2' is ' {0}' and value is : {1}", myVariable2.GetType(), myVariable2 ); - - // Compare 'myVariable1' instance with 'myVariable2' Object. - if ( myVariable1.Equals( myVariable2 ) ) - Console::WriteLine( "\nStructures 'myVariable1' and 'myVariable2' are equal" ); - else - Console::WriteLine( "\nStructures 'myVariable1' and 'myVariable2' are not equal" ); - - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - } - -} - -/* expected return values: -20'F --6'C -20'F -0 -72'F --52 -*/ -/* -namespace Snippets2 { - // - - public __gc class Temperature { - // The value holder - protected: - short m_value; - - public: - __property static short get_MinValue() { - return Int64.MinValue; - } - - __property static short get_MaxValue() { - return Int64.MaxValue; - } - - __property short get_Value(){ - return m_value; - } - __property void set_Value( short value){ - m_value = value; - } - - __property short get_Celsius(){ - return (short)((m_value-32)/2); - } - - __property void set_Celsius( short value){ - m_value = (short)(value*2+32); - } - } - // -} - -namespace Snippets3 { - // - public __gc class Temperature : IComparable { - /// - /// IComparable.CompareTo implementation. - /// - // The value holder - protected: - short m_value; - - public: - Int64 CompareTo(Object* obj) { - if(obj->GetType() == __typeof(Temperature)) { - Temperature temp = dynamic_cast(obj); - return m_value.CompareTo(temp.m_value); - } - - throw new ArgumentException("object is not a Temperature"); - } - - __property short get_Value() { - return m_value; - } - - __property void set_Value( short value) { - m_value = value; - } - - __property short get_Celsius() { - return (short)((m_value-32)/2); - } - - __property void set_Celsius( Int64 value) { - m_value = (short)(value*2+32); - } - } - // -} - -namespace Snippets4 { - // - public __gc class Temperature : IFormattable { - /// - /// IFormattable.ToString implementation. - /// - // The value holder - protected: - short m_value; - - public: - String* ToString(String* format, IFormatProvider provider) { - if( format != NULL ) { - if( format->Equals("F") ) { - return String::Format("{0}'F", this->Value->ToString()); - } - if( format->Equals("C") ) { - return String::Format("{0}'C", this->Celsius->ToString()); - } - } - - return m_value->ToString(format, provider); - } - - __property short get_Value() { - return m_value; - } - - __property void set_Value( short value) { - m_value = value; - } - - __property short get_Celsius() { - return (short)((m_value-32)/2); - } - - __property void set_Celsius( short value) { - m_value = (short)(value*2+32); - } - } - // -} -namespace Snippets5 { - // - public __gc class Temperature { - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - // The value holder - protected: - short m_value; - - public: - static Temperature* Parse(String* s) { - Temperature* temp = new Temperature(); - - if( s->TrimEnd(NULL)->EndsWith("'F") ) { - temp->Value = Int64::Parse( s->Remove(s->LastIndexOf('\''), 2) ); - } - else { - if( s->TrimEnd(NULL)->EndsWith("'C") ) { - temp->Celsius = Int64::Parse( s->Remove(s->LastIndexOf('\''), 2) ); - } - else { - temp->Value = Int64::Parse(s); - } - } - return temp; - } - - __property short get_Value() { - return m_value; - } - - __property void set_Value( short value) { - m_value = value; - } - - __property short get_Celsius() { - return (short)((m_value-32)/2); - } - - __property void set_Celsius( short value) { - m_value = (short)(value*2+32); - } - } - } - // -} -namespace Snippets6 { - // - public class Temperature { - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - - // The value holder - protected: - short m_value; - - public: - static Temperature* Parse(String* s, IFormatProvider provider) { - Temperature* temp = new Temperature(); - - if( s->TrimEnd(NULL)->EndsWith("'F") ) { - temp->Value = Int64::Parse( s->Remove(s->LastIndexOf('\''), 2), provider); - } - else { - if( s->TrimEnd(NULL)->EndsWith("'C") ) { - temp->Celsius = Int64::Parse( s->Remove(s->LastIndexOf('\''), 2), provider); - } - else { - temp->Value = Int64::Parse(s, provider); - } - } - - return temp; - } - - __property short get_Value() { - return m_value; - } - - __property void set_Value( short value) { - m_value = value; - } - - __property short get_Celsius() { - return (short)((m_value-32)/2); - } - - __property void set_Celsius( short value) { - m_value = (short)(value*2+32); - } - } - // -} -namespace Snippets7 { - // - public class Temperature { - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - - // The value holder - protected: - short m_value; - - public: - static Temperature* Parse(String* s, NumberStyles styles) { - Temperature* temp = new Temperature(); - - if( s->TrimEnd(NULL)->EndsWith("'F") ) { - temp->Value = Int64::Parse( s->Remove(s->LastIndexOf('\''), 2), styles); - } - else { - if( s->TrimEnd(NULL)->EndsWith("'C") ) { - temp->Celsius = Int64::Parse( s->Remove(s->LastIndexOf('\''), 2), styles); - } - else { - temp->Value = Int64::Parse(s, styles); - } - } - - return temp; - } - - __property short get_Value() { - return m_value; - } - - __property void set_Value( short value) { - m_value = value; - } - - __property short get_Celsius() { - return (short)((m_value-32)/2); - } - - __property void set_Celsius( short value) { - m_value = (short)(value*2+32); - } - } - // -} -namespace Snippets8 { - // - public class Temperature { - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - - // The value holder - protected: - short m_value; - - public: - static Temperature* Parse(String* s, NumberStyles styles, IFormatProvider* provider) { - Temperature* temp = new Temperature(); - - if( s->TrimEnd(NULL)->EndsWith("'F") ) { - temp->Value = Int64::Parse( s->Remove(s->LastIndexOf('\''), 2), styles, provider); - } - else { - if( s->TrimEnd(NULL)->EndsWith("'C") ) { - temp->Celsius = Int64::Parse( s->Remove(s->LastIndexOf('\''), 2), styles, provider); - } - else { - temp->Value = Int64::Parse(s, styles, provider); - } - } - - return temp; - } - - __property short get_Value() { - return m_value; - } - - __property void set_Value( short value) { - m_value = value; - } - - __property short get_Celsius() { - return (short)((m_value-32)/2); - } - - __property void set_Celsius( short value) { - m_value = (short)(value*2+32); - } - } - // -} -*/ diff --git a/snippets/cpp/VS_Snippets_CLR/InvokeMem/CPP/invokemem.cpp b/snippets/cpp/VS_Snippets_CLR/InvokeMem/CPP/invokemem.cpp deleted file mode 100644 index ce2f1b81b12..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/InvokeMem/CPP/invokemem.cpp +++ /dev/null @@ -1,90 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -// This sample class has a field, constructor, method, and property. -ref class MyType -{ -private: - Int32 myField; - -public: - MyType( interior_ptr x ) - { - *x *= 5; - } - - virtual String^ ToString() override - { - return myField.ToString(); - } - - property Int32 MyProp - { - Int32 get() - { - return myField; - } - - void set( Int32 value ) - { - if ( value < 1 ) - throw gcnew ArgumentOutOfRangeException( "value",value,"value must be > 0" ); - - myField = value; - } - } -}; - -int main() -{ - Type^ t = MyType::typeid; - - // Create an instance of a type. - array^args = {8}; - Console::WriteLine( "The value of x before the constructor is called is {0}.", args[ 0 ] ); - Object^ obj = t->InvokeMember( nullptr, static_cast(BindingFlags::DeclaredOnly | BindingFlags::Public | BindingFlags::NonPublic | BindingFlags::Instance | BindingFlags::CreateInstance), nullptr, nullptr, args ); - Console::WriteLine( "Type: {0}", obj->GetType() ); - Console::WriteLine( "The value of x after the constructor returns is {0}.", args[ 0 ] ); - - // Read and write to a field. - array^obj5 = {5}; - t->InvokeMember( "myField", static_cast(BindingFlags::DeclaredOnly | BindingFlags::Public | BindingFlags::NonPublic | BindingFlags::Instance | BindingFlags::SetField), nullptr, obj, obj5 ); - Int32 v = safe_cast(t->InvokeMember( "myField", static_cast(BindingFlags::DeclaredOnly | BindingFlags::Public | BindingFlags::NonPublic | BindingFlags::Instance | BindingFlags::GetField), nullptr, obj, nullptr )); - Console::WriteLine( "myField: {0}", v ); - - // Call a method. - String^ s = safe_cast(t->InvokeMember( "ToString", static_cast(BindingFlags::DeclaredOnly | BindingFlags::Public | BindingFlags::NonPublic | BindingFlags::Instance | BindingFlags::InvokeMethod), nullptr, obj, nullptr )); - Console::WriteLine( "ToString: {0}", s ); - - // Read and write a property. First, attempt to assign an - // invalid value; then assign a valid value; finally, get - // the value. - try - { - // Assign the value zero to MyProp. The Property Set - // throws an exception, because zero is an invalid value. - // InvokeMember catches the exception, and throws - // TargetInvocationException. To discover the real cause - // you must catch TargetInvocationException and examine - // the inner exception. - array^obj0 = {(int^)0}; - t->InvokeMember( "MyProp", static_cast(BindingFlags::DeclaredOnly | BindingFlags::Public | BindingFlags::NonPublic | BindingFlags::Instance | BindingFlags::SetProperty), nullptr, obj, obj0 ); - } - catch ( TargetInvocationException^ e ) - { - // If the property assignment failed for some unexpected - // reason, rethrow the TargetInvocationException. - if ( e->InnerException->GetType() != ArgumentOutOfRangeException::typeid ) - throw; - - Console::WriteLine( "An invalid value was assigned to MyProp." ); - } - - array^obj2 = {2}; - t->InvokeMember( "MyProp", static_cast(BindingFlags::DeclaredOnly | BindingFlags::Public | BindingFlags::NonPublic | BindingFlags::Instance | BindingFlags::SetProperty), nullptr, obj, obj2 ); - v = safe_cast(t->InvokeMember( "MyProp", static_cast(BindingFlags::DeclaredOnly | BindingFlags::Public | BindingFlags::NonPublic | BindingFlags::Instance | BindingFlags::GetProperty), nullptr, obj, nullptr )); - Console::WriteLine( "MyProp: {0}", v ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/IsDefaultAttribute/CPP/defattr.cpp b/snippets/cpp/VS_Snippets_CLR/IsDefaultAttribute/CPP/defattr.cpp deleted file mode 100644 index bbdb493fd1b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/IsDefaultAttribute/CPP/defattr.cpp +++ /dev/null @@ -1,85 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -// An enumeration of animals. Start at 1 (0 = uninitialized). -public enum class Animal -{ - // Pets. - Dog = 1, - Cat, Bird -}; - - -// A custom attribute to allow a target to have a pet. -public ref class AnimalTypeAttribute: public Attribute -{ -public: - - // The constructor is called when the attribute is set. - AnimalTypeAttribute( Animal pet ) - { - thePet = pet; - } - - // Provide a default constructor and make Dog the default. - AnimalTypeAttribute() - { - thePet = Animal::Dog; - } - -protected: - - // Keep a variable internally ... - Animal thePet; - -public: - - property Animal Pet - { - // .. and show a copy to the outside world. - Animal get() - { - return thePet; - } - void set( Animal value ) - { - thePet = value; - } - - } - - // Override IsDefaultAttribute to return the correct response. - virtual bool IsDefaultAttribute() override - { - return thePet == Animal::Dog; - } -}; - -public ref class TestClass -{ -public: - - // Use the default constructor. - - [AnimalType] - void Method1(){} -}; - -int main() -{ - // Get the class type to access its metadata. - Type^ clsType = TestClass::typeid; - - // Get type information for the method. - MethodInfo^ mInfo = clsType->GetMethod( "Method1" ); - - // Get the AnimalType attribute for the method. - AnimalTypeAttribute^ atAttr = dynamic_cast(Attribute::GetCustomAttribute( mInfo, AnimalTypeAttribute::typeid )); - - // Check to see if the default attribute is applied. - Console::WriteLine( "The attribute {0} for method {1} in class {2}", atAttr->Pet, mInfo->Name, clsType->Name ); - Console::WriteLine( "{0} the default for the AnimalType attribute.", atAttr->IsDefaultAttribute() ? (String^)"is" : "is not" ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp b/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp deleted file mode 100644 index cf2f401b63a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp +++ /dev/null @@ -1,276 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -// Add an AssemblyDescription attribute -[assembly:AssemblyDescription("A sample description")]; -namespace IsDef1CS -{ - ref class DemoClass - { - public: - static void Main() - { - - // Get the class type to access its metadata. - Type^ clsType = DemoClass::typeid; - - // Get the assembly object. - Assembly^ assy = clsType->Assembly; - - // Store the assembly's name. - String^ assyName = assy->GetName()->Name; - - //Type assyType = assy.GetType(); - // See if the Assembly Description is defined. - bool isdef = Attribute::IsDefined( assy, AssemblyDescriptionAttribute::typeid ); - if ( isdef ) - { - - // Affirm that the attribute is defined. - Console::WriteLine( "The AssemblyDescription attribute " - "is defined for assembly {0}.", assyName ); - - // Get the description attribute itself. - AssemblyDescriptionAttribute^ adAttr = dynamic_cast(Attribute::GetCustomAttribute( assy, AssemblyDescriptionAttribute::typeid )); - - // Display the description. - if ( adAttr != nullptr ) - Console::WriteLine( "The description is \"{0}\".", adAttr->Description ); - else - Console::WriteLine( "The description could not " - "be retrieved." ); - } - else - Console::WriteLine( "The AssemblyDescription attribute is not " - "defined for assembly {0}.", assyName ); - } - - }; - -} - - -/* - * Output: - * The AssemblyDescription attributeis defined for assembly IsDef1CS. - * The description is "A sample description". - */ -// -// -using namespace System; -using namespace System::Diagnostics; - -// Add the Debuggable attribute to the module. -[module:Debuggable(true,false)]; -namespace IsDef2CS -{ - ref class DemoClass - { - public: - static void Main() - { - - // Get the class type to access its metadata. - Type^ clsType = DemoClass::typeid; - - // See if the Debuggable attribute is defined for this module. - bool isDef = Attribute::IsDefined( clsType->Module, DebuggableAttribute::typeid ); - - // Display the result. - Console::WriteLine( "The Debuggable attribute {0} " - "defined for Module {1}.", isDef ? (String^)"is" : "is not", clsType->Module->Name ); - - // If the attribute is defined, display the JIT settings. - if ( isDef ) - { - - // Retrieve the attribute itself. - DebuggableAttribute^ dbgAttr = dynamic_cast(Attribute::GetCustomAttribute( clsType->Module, DebuggableAttribute::typeid )); - if ( dbgAttr != nullptr ) - { - Console::WriteLine( "JITTrackingEnabled is {0}.", dbgAttr->IsJITTrackingEnabled ); - Console::WriteLine( "JITOptimizerDisabled is {0}.", dbgAttr->IsJITOptimizerDisabled ); - } - else - Console::WriteLine( "The Debuggable attribute " - "could not be retrieved." ); - } - } - - }; - -} - - -/* - * Output: - * The Debuggable attribute is defined for Module IsDef2CS.exe. - * JITTrackingEnabled is True. - * JITOptimizerDisabled is False. - */ -// -// -using namespace System; -using namespace System::Reflection; -using namespace System::Runtime::InteropServices; - -namespace IsDef3CS -{ - - // Assign a Guid attribute to a class. - - [Guid("BF235B41-52D1-46cc-9C55-046793DB363F")] - public ref class TestClass{}; - - ref class DemoClass - { - public: - static void Main() - { - - // Get the class type to access its metadata. - Type^ clsType = TestClass::typeid; - - // See if the Guid attribute is defined for the class. - bool isDef = Attribute::IsDefined( clsType, GuidAttribute::typeid ); - - // Display the result. - Console::WriteLine( "The Guid attribute {0} defined for class {1}.", isDef ? (String^)"is" : "is not", clsType->Name ); - - // If it's defined, display the GUID. - if ( isDef ) - { - GuidAttribute^ guidAttr = dynamic_cast(Attribute::GetCustomAttribute( clsType, GuidAttribute::typeid )); - if ( guidAttr != nullptr ) - Console::WriteLine( "GUID: {{0}}.", guidAttr->Value ); - else - Console::WriteLine( "The Guid attribute could " - "not be retrieved." ); - } - } - - }; - -} - - -/* - * Output: - * The Guid attribute is defined for class TestClass. - * GUID: {BF235B41-52D1-46cc-9C55-046793DB363F}. - */ -// -// -using namespace System; -using namespace System::Reflection; - -namespace IsDef4CS -{ - public ref class TestClass - { - public: - - // Assign the Obsolete attribute to a method. - - [Obsolete("This method is obsolete. Use Method2 instead.")] - void Method1(){} - - void Method2(){} - - }; - - ref class DemoClass - { - public: - static void Main() - { - - // Get the class type to access its metadata. - Type^ clsType = TestClass::typeid; - - // Get the MethodInfo object for Method1. - MethodInfo^ mInfo = clsType->GetMethod( "Method1" ); - - // See if the Obsolete attribute is defined for this method. - bool isDef = Attribute::IsDefined( mInfo, ObsoleteAttribute::typeid ); - - // Display the result. - Console::WriteLine( "The Obsolete Attribute {0} defined for {1} of class {2}.", isDef ? (String^)"is" : "is not", mInfo->Name, clsType->Name ); - - // If it's defined, display the attribute's message. - if ( isDef ) - { - ObsoleteAttribute^ obsAttr = dynamic_cast(Attribute::GetCustomAttribute( mInfo, ObsoleteAttribute::typeid )); - if ( obsAttr != nullptr ) - Console::WriteLine( "The message is: \"{0}\".", obsAttr->Message ); - else - Console::WriteLine( "The message could not be retrieved." ); - } - } - - }; - -} - - -/* - * Output: - * The Obsolete Attribute is defined for Method1 of class TestClass. - * The message is: "This method is obsolete. Use Method2 instead.". - */ -// -// -using namespace System; -using namespace System::Reflection; - -namespace IsDef5CS -{ - public ref class TestClass - { - public: - - // Assign a ParamArray attribute to the parameter using the keyword. - void Method1(... array^args ){} - - }; - - ref class DemoClass - { - public: - static void Main() - { - - // Get the class type to access its metadata. - Type^ clsType = TestClass::typeid; - - // Get the MethodInfo object for Method1. - MethodInfo^ mInfo = clsType->GetMethod( "Method1" ); - - // Get the ParameterInfo array for the method parameters. - array^pInfo = mInfo->GetParameters(); - if ( pInfo != nullptr ) - { - - // See if the ParamArray attribute is defined. - bool isDef = Attribute::IsDefined( pInfo[ 0 ], ParamArrayAttribute::typeid ); - - // Display the result. - Console::WriteLine( "The ParamArray attribute {0} defined for " - "parameter {1} of method {2}.", isDef ? (String^)"is" : "is not", pInfo[ 0 ]->Name, mInfo->Name ); - } - else - Console::WriteLine( "The parameters information could " - "not be retrieved for method {0}.", mInfo->Name ); - } - - }; - -} - -/* - * Output: - * The ParamArray attribute is defined for parameter args of method Method1. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/MathSample/CPP/mathsample.cpp b/snippets/cpp/VS_Snippets_CLR/MathSample/CPP/mathsample.cpp deleted file mode 100644 index b71de67675c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/MathSample/CPP/mathsample.cpp +++ /dev/null @@ -1,88 +0,0 @@ - - -// -/// -/// The following class represents simple functionality of the trapezoid. -/// -using namespace System; - -public ref class MathTrapezoidSample -{ -private: - double m_longBase; - double m_shortBase; - double m_leftLeg; - double m_rightLeg; - -public: - MathTrapezoidSample( double longbase, double shortbase, double leftLeg, double rightLeg ) - { - m_longBase = Math::Abs( longbase ); - m_shortBase = Math::Abs( shortbase ); - m_leftLeg = Math::Abs( leftLeg ); - m_rightLeg = Math::Abs( rightLeg ); - } - - -private: - double GetRightSmallBase() - { - return (Math::Pow( m_rightLeg, 2.0 ) - Math::Pow( m_leftLeg, 2.0 ) + Math::Pow( m_longBase, 2.0 ) + Math::Pow( m_shortBase, 2.0 ) - 2 * m_shortBase * m_longBase) / (2 * (m_longBase - m_shortBase)); - } - - -public: - double GetHeight() - { - double x = GetRightSmallBase(); - return Math::Sqrt( Math::Pow( m_rightLeg, 2.0 ) - Math::Pow( x, 2.0 ) ); - } - - double GetSquare() - { - return GetHeight() * m_longBase / 2.0; - } - - double GetLeftBaseRadianAngle() - { - double sinX = GetHeight() / m_leftLeg; - return Math::Round( Math::Asin( sinX ), 2 ); - } - - double GetRightBaseRadianAngle() - { - double x = GetRightSmallBase(); - double cosX = (Math::Pow( m_rightLeg, 2.0 ) + Math::Pow( x, 2.0 ) - Math::Pow( GetHeight(), 2.0 )) / (2 * x * m_rightLeg); - return Math::Round( Math::Acos( cosX ), 2 ); - } - - double GetLeftBaseDegreeAngle() - { - double x = GetLeftBaseRadianAngle() * 180 / Math::PI; - return Math::Round( x, 2 ); - } - - double GetRightBaseDegreeAngle() - { - double x = GetRightBaseRadianAngle() * 180 / Math::PI; - return Math::Round( x, 2 ); - } - -}; - -int main() -{ - MathTrapezoidSample^ trpz = gcnew MathTrapezoidSample( 20.0,10.0,8.0,6.0 ); - Console::WriteLine( "The trapezoid's bases are 20.0 and 10.0, the trapezoid's legs are 8.0 and 6.0" ); - double h = trpz->GetHeight(); - Console::WriteLine( "Trapezoid height is: {0}", h.ToString() ); - double dxR = trpz->GetLeftBaseRadianAngle(); - Console::WriteLine( "Trapezoid left base angle is: {0} Radians", dxR.ToString() ); - double dyR = trpz->GetRightBaseRadianAngle(); - Console::WriteLine( "Trapezoid right base angle is: {0} Radians", dyR.ToString() ); - double dxD = trpz->GetLeftBaseDegreeAngle(); - Console::WriteLine( "Trapezoid left base angle is: {0} Degrees", dxD.ToString() ); - double dyD = trpz->GetRightBaseDegreeAngle(); - Console::WriteLine( "Trapezoid right base angle is: {0} Degrees", dyD.ToString() ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/MissingMethodException/cpp/MissingMethodException.cpp b/snippets/cpp/VS_Snippets_CLR/MissingMethodException/cpp/MissingMethodException.cpp deleted file mode 100644 index 5f170354fb3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/MissingMethodException/cpp/MissingMethodException.cpp +++ /dev/null @@ -1,72 +0,0 @@ -//Types:System.MissingMethodException -//Types:System.MissingMemberException -//Types:System.MissingFieldException -// -using namespace System; -using namespace System::Reflection; - -ref class App -{ -}; - -int main() -{ - // - try - { - // Attempt to call a static DoSomething method defined in the App class. - // However, because the App class does not define this method, - // a MissingMethodException is thrown. - App::typeid->InvokeMember("DoSomething", BindingFlags::Static | - BindingFlags::InvokeMethod, nullptr, nullptr, nullptr); - } - catch (MissingMethodException^ ex) - { - // Show the user that the DoSomething method cannot be called. - Console::WriteLine("Unable to call the DoSomething method: {0}", - ex->Message); - } - // - - // - try - { - // Attempt to access a static AField field defined in the App class. - // However, because the App class does not define this field, - // a MissingFieldException is thrown. - App::typeid->InvokeMember("AField", BindingFlags::Static | - BindingFlags::SetField, nullptr, nullptr, gcnew array{5}); - } - catch (MissingFieldException^ ex) - { - // Show the user that the AField field cannot be accessed. - Console::WriteLine("Unable to access the AField field: {0}", - ex->Message); - } - // - - // - try - { - // Attempt to access a static AnotherField field defined in the App class. - // However, because the App class does not define this field, - // a MissingFieldException is thrown. - App::typeid->InvokeMember("AnotherField", BindingFlags::Static | - BindingFlags::GetField, nullptr, nullptr, nullptr); - } - catch (MissingMemberException^ ex) - { - // Notice that this code is catching MissingMemberException which is the - // base class of MissingMethodException and MissingFieldException. - // Show the user that the AnotherField field cannot be accessed. - Console::WriteLine("Unable to access the AnotherField field: {0}", - ex->Message); - } - // -} -// This code produces the following output. -// -// Unable to call the DoSomething method: Method 'App.DoSomething' not found. -// Unable to access the AField field: Field 'App.AField' not found. -// Unable to access the AnotherField field: Field 'App.AnotherField' not found. -// diff --git a/snippets/cpp/VS_Snippets_CLR/Multicast Delegate Introduction/CPP/delegatestring.cpp b/snippets/cpp/VS_Snippets_CLR/Multicast Delegate Introduction/CPP/delegatestring.cpp deleted file mode 100644 index 0017618eb8d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Multicast Delegate Introduction/CPP/delegatestring.cpp +++ /dev/null @@ -1,149 +0,0 @@ -// -using namespace System; -using namespace System::Collections::Generic; - -ref class StringContainer -{ -private: - // A generic list object that holds the strings. - List^ container = gcnew List; - -public: - // Define a delegate to handle string display. - delegate void CheckAndDisplayDelegate(String^ str); - - // A method that adds more strings to the collection. - void AddString(String^ str) - { - container->Add(str); - } - - // Iterate through the strings and invoke the method(s) that the delegate points to. - void DisplayAllQualified(CheckAndDisplayDelegate^ displayDelegate) - { - for each (String^ str in container) - displayDelegate(str); -// System::Collections::IEnumerator^ myEnum = container->GetEnumerator(); -// while ( myEnum->MoveNext() ) -// { -// String^ str = safe_cast(myEnum->Current); -// displayDelegate(str); -// } - } -}; - -//end of class StringContainer -// This class contains a few sample methods -ref class StringFuncs -{ -public: - - // This method prints a String* that it is passed if the String* starts with a vowel - static void ConStart(String^ str) - { - if ( !(str[ 0 ] == 'a' || str[ 0 ] == 'e' || str[ 0 ] == 'i' || str[ 0 ] == 'o' || str[ 0 ] == 'u') ) - Console::WriteLine( str ); - } - - // This method prints a String* that it is passed if the String* starts with a consonant - static void VowelStart( String^ str ) - { - if ( (str[ 0 ] == 'a' || str[ 0 ] == 'e' || str[ 0 ] == 'i' || str[ 0 ] == 'o' || str[ 0 ] == 'u') ) - Console::WriteLine( str ); - } -}; - -// This function demonstrates using Delegates, including using the Remove and -// Combine methods to create and modify delegate combinations. -int main() -{ - // Declare the StringContainer class and add some strings - StringContainer^ container = gcnew StringContainer; - container->AddString( "This" ); - container->AddString( "is" ); - container->AddString( "a" ); - container->AddString( "multicast" ); - container->AddString( "delegate" ); - container->AddString( "example" ); - -// RETURN HERE. - // Create two delegates individually using different methods - StringContainer::CheckAndDisplayDelegate^ conStart = gcnew StringContainer::CheckAndDisplayDelegate( StringFuncs::ConStart ); - StringContainer::CheckAndDisplayDelegate^ vowelStart = gcnew StringContainer::CheckAndDisplayDelegate( StringFuncs::VowelStart ); - - // Get the list of all delegates assigned to this MulticastDelegate instance. - array^ delegateList = conStart->GetInvocationList(); - Console::WriteLine("conStart contains {0} delegate(s).", delegateList->Length); - delegateList = vowelStart->GetInvocationList(); - Console::WriteLine("vowelStart contains {0} delegate(s).\n", delegateList->Length ); - - // Determine whether the delegates are System::Multicast delegates - if ( dynamic_cast(conStart) && dynamic_cast(vowelStart) ) - { - Console::WriteLine("conStart and vowelStart are derived from MulticastDelegate.\n"); - } - - // Execute the two delegates. - Console::WriteLine("Executing the conStart delegate:" ); - container->DisplayAllQualified(conStart); - Console::WriteLine(); - Console::WriteLine("Executing the vowelStart delegate:" ); - container->DisplayAllQualified(vowelStart); - - // Create a new MulticastDelegate and call Combine to add two delegates. - StringContainer::CheckAndDisplayDelegate^ multipleDelegates = - dynamic_cast(Delegate::Combine(conStart, vowelStart)); - - // How many delegates does multipleDelegates contain? - delegateList = multipleDelegates->GetInvocationList(); - Console::WriteLine("\nmultipleDelegates contains {0} delegates.\n", - delegateList->Length ); - - // // Pass this multicast delegate to DisplayAllQualified. - Console::WriteLine("Executing the multipleDelegate delegate."); - container->DisplayAllQualified(multipleDelegates); - // Call remove and combine to change the contained delegates. - multipleDelegates = dynamic_cast - (Delegate::Remove(multipleDelegates, vowelStart)); - multipleDelegates = dynamic_cast - (Delegate::Combine(multipleDelegates, conStart)); - - // Pass multipleDelegates to DisplayAllQualified again. - Console::WriteLine("\nExecuting the multipleDelegate delegate with two conStart delegates:"); - container->DisplayAllQualified(multipleDelegates); -} -// The example displays the following output: -// conStart contains 1 delegate(s). -// vowelStart contains 1 delegate(s). -// -// conStart and vowelStart are derived from MulticastDelegate. -// -// Executing the conStart delegate: -// This -// multicast -// delegate -// -// Executing the vowelStart delegate: -// is -// a -// example -// -// -// multipleDelegates contains 2 delegates. -// -// Executing the multipleDelegate delegate. -// This -// is -// a -// multicast -// delegate -// example -// -// Executing the multipleDelegate delegate with two conStart delegates: -// This -// This -// multicast -// multicast -// delegate -// delegate -// diff --git a/snippets/cpp/VS_Snippets_CLR/ObjDispEx/CPP/objdispexc.cpp b/snippets/cpp/VS_Snippets_CLR/ObjDispEx/CPP/objdispexc.cpp deleted file mode 100644 index 90c4a5a1302..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ObjDispEx/CPP/objdispexc.cpp +++ /dev/null @@ -1,20 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - MemoryStream^ ms = gcnew MemoryStream( 16 ); - ms->Close(); - try - { - ms->ReadByte(); - } - catch ( ObjectDisposedException^ e ) - { - Console::WriteLine( "Caught: {0}", e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/ObjectX/cpp/ObjectX.cpp b/snippets/cpp/VS_Snippets_CLR/ObjectX/cpp/ObjectX.cpp deleted file mode 100644 index d13e56d248d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ObjectX/cpp/ObjectX.cpp +++ /dev/null @@ -1,107 +0,0 @@ -//Types:System.Object -// -using namespace System; - -// The Point class is derived from System.Object. -ref class Point -{ -public: - int x; -public: - int y; - -public: - Point(int x, int y) - { - this->x = x; - this->y = y; - } - - // -public: - virtual bool Equals(Object^ obj) override - { - // If this and obj do not refer to the same type, - // then they are not equal. - if (obj->GetType() != this->GetType()) - { - return false; - } - - // Return true if x and y fields match. - Point^ other = (Point^) obj; - return (this->x == other->x) && (this->y == other->y); - } - // - - // - // Return the XOR of the x and y fields. -public: - virtual int GetHashCode() override - { - return x ^ y; - } - // - - // - // Return the point's value as a string. -public: - virtual String^ ToString() override - { - return String::Format("({0}, {1})", x, y); - } - // - - // - // Return a copy of this point object by making a simple - // field copy. -public: - Point^ Copy() - { - return (Point^) this->MemberwiseClone(); - } - // -}; - -int main() -{ - // Construct a Point object. - Point^ p1 = gcnew Point(1, 2); - - // Make another Point object that is a copy of the first. - Point^ p2 = p1->Copy(); - - // Make another variable that references the first - // Point object. - Point^ p3 = p1; - - // - // The line below displays false because p1 and - // p2 refer to two different objects. - Console::WriteLine( - Object::ReferenceEquals(p1, p2)); - // - - // - // The line below displays true because p1 and p2 refer - // to two different objects that have the same value. - Console::WriteLine(Object::Equals(p1, p2)); - // - - // The line below displays true because p1 and - // p3 refer to one object. - Console::WriteLine(Object::ReferenceEquals(p1, p3)); - - // - // The line below displays: p1's value is: (1, 2) - Console::WriteLine("p1's value is: {0}", p1->ToString()); - // -} - -// This code produces the following output. -// -// False -// True -// True -// p1's value is: (1, 2) -// diff --git a/snippets/cpp/VS_Snippets_CLR/OperatingSystem.ServicePack/CPP/sp.cpp b/snippets/cpp/VS_Snippets_CLR/OperatingSystem.ServicePack/CPP/sp.cpp deleted file mode 100644 index c2c7e1cf179..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/OperatingSystem.ServicePack/CPP/sp.cpp +++ /dev/null @@ -1,18 +0,0 @@ - -// -// This example demonstrates the OperatingSystem.ServicePack property. -using namespace System; -int main() -{ - OperatingSystem^ os = Environment::OSVersion; - String^ sp = os->ServicePack; - Console::WriteLine( "Service pack version = \"{0}\"", sp ); -} - -/* -This example produces the following results: - -Service pack version = "Service Pack 1" - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/OperatingSystem.VersionString/CPP/osvs.cpp b/snippets/cpp/VS_Snippets_CLR/OperatingSystem.VersionString/CPP/osvs.cpp deleted file mode 100644 index 6c87d9dff1f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/OperatingSystem.VersionString/CPP/osvs.cpp +++ /dev/null @@ -1,20 +0,0 @@ - -// -// This example demonstrates the VersionString property. -using namespace System; -int main() -{ - OperatingSystem^ os = Environment::OSVersion; - - // Display the value of OperatingSystem.VersionString. By default, this is - // the same value as OperatingSystem.ToString. - Console::WriteLine( L"This operating system is {0}", os->VersionString ); - return 0; -} - -/* -This example produces the following results: - -This operating system is Microsoft Windows NT 5.1.2600.0 Service Pack 1 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/StringCompareOrdinal/CPP/stringcompareordinal.cpp b/snippets/cpp/VS_Snippets_CLR/StringCompareOrdinal/CPP/stringcompareordinal.cpp deleted file mode 100644 index 6541e6b0a6e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/StringCompareOrdinal/CPP/stringcompareordinal.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// -using namespace System; -using namespace System::Globalization; -int main() -{ - String^ strLow = "abc"; - String^ strCap = "ABC"; - String^ result = "equal to "; - int x = 0; - int pos = 1; - - // The Unicode codepoint for 'b' is greater than the codepoint for 'B'. - x = String::CompareOrdinal( strLow, pos, strCap, pos, 1 ); - if ( x < 0 ) - result = "less than"; - - if ( x > 0 ) - result = "greater than"; - - Console::WriteLine( "CompareOrdinal(\"{0}\"[{2}], \"{1}\"[{2}]):", strLow, strCap, pos ); - Console::WriteLine( " '{0}' is {1} '{2}'", strLow[ pos ], result, strCap[ pos ] ); - - // In U.S. English culture, 'b' is linguistically less than 'B'. - x = String::Compare( strLow, pos, strCap, pos, 1, false, gcnew CultureInfo( "en-US" ) ); - if ( x < 0 ) - result = "less than"; - else - if ( x > 0 ) - result = "greater than"; - - Console::WriteLine( "Compare(\"{0}\"[{2}], \"{1}\"[{2}]):", strLow, strCap, pos ); - Console::WriteLine( " '{0}' is {1} '{2}'", strLow[ pos ], result, strCap[ pos ] ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/StringCompareTo/CPP/stringcompareto.cpp b/snippets/cpp/VS_Snippets_CLR/StringCompareTo/CPP/stringcompareto.cpp deleted file mode 100644 index 389943d7364..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/StringCompareTo/CPP/stringcompareto.cpp +++ /dev/null @@ -1,40 +0,0 @@ - -// -using namespace System; - -String^ CompareStrings(String^ str1, String^ str2) -{ - // compare the values, using the CompareTo method on the first string - int cmpVal = str1->CompareTo(str2); - if (cmpVal == 0) - // the values are the same - return "The strings occur in the same position in the sort order."; - else if (cmpVal < 0) - return "The first string precedes the second in the sort order."; - else - return "The first string follows the second in the sort order."; -} - -int main() -{ - String^ strFirst = "Goodbye"; - String^ strSecond = "Hello"; - String^ strThird = "a small String*"; - String^ strFourth = "goodbye"; - - // Compare a string to itself. - Console::WriteLine(CompareStrings(strFirst, strFirst)); - Console::WriteLine(CompareStrings(strFirst, strSecond)); - Console::WriteLine(CompareStrings(strFirst, strThird)); - - // Compare a string to another string that varies only by case. - Console::WriteLine(CompareStrings(strFirst, strFourth)); - Console::WriteLine(CompareStrings(strFourth, strFirst)); -} -// The example displays the following output: -// The strings occur in the same position in the sort order. -// The first string precedes the second in the sort order. -// The first string follows the second in the sort order. -// The first string follows the second in the sort order. -// The first string precedes the second in the sort order. -// diff --git a/snippets/cpp/VS_Snippets_CLR/T.CompareTo/CPP/cat.cpp b/snippets/cpp/VS_Snippets_CLR/T.CompareTo/CPP/cat.cpp deleted file mode 100644 index 10d4eb14002..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/T.CompareTo/CPP/cat.cpp +++ /dev/null @@ -1,134 +0,0 @@ - -// -// This example demonstrates the two versions of the -// CompareTo method for several base types. -// The general version takes a parameter of type Object, while the specific -// version takes a type-specific parameter, such as Boolean, Int32, or Double. -using namespace System; - -void Show( String^ caption, Object^ var1, Object^ var2, int resultGeneric, int resultNonGeneric ) -{ - String^ relation; - Console::Write( caption ); - if ( resultGeneric == resultNonGeneric ) - { - if ( resultGeneric < 0 ) - relation = "less than"; - else - if ( resultGeneric > 0 ) - relation = "greater than"; - else - relation = "equal to"; - Console::WriteLine( "{0} is {1} {2}", var1, relation, var2 ); - } - // The following condition will never occur because the generic and non-generic - // CompareTo methods are equivalent. - else - { - Console::WriteLine( "Generic CompareTo = {0}; non-generic CompareTo = {1}", resultGeneric, resultNonGeneric ); - } -} - -int main() -{ - String^ nl = Environment::NewLine; - String^ msg = "{0}The following is the result of using the generic and non-generic{0}" - "versions of the CompareTo method for several base types:{0}"; - Object^ obj; // An Object used to insure CompareTo(Object) is called. - - DateTime now = DateTime::Now; - - // Time span = 11 days, 22 hours, 33 minutes, 44 seconds - TimeSpan tsX = TimeSpan(11,22,33,44); - - // Version = 1.2.333.4 - Version^ versX = gcnew Version( "1.2.333.4" ); - - // Guid = CA761232-ED42-11CE-BACD-00AA0057B223 - Guid guidX = Guid( "{CA761232-ED42-11CE-BACD-00AA0057B223}"); - Boolean a1 = true,a2 = true; - Byte b1 = 1,b2 = 1; - Int16 c1 = -2,c2 = 2; - Int32 d1 = 3,d2 = 3; - Int64 e1 = 4,e2 = -4; - Decimal f1 = Decimal(-5.5), f2 = Decimal(5.5); - Single g1 = 6.6f,g2 = 6.6f; - Double h1 = 7.7,h2 = -7.7; - Char i1 = 'A',i2 = 'A'; - String^ j1 = "abc", ^j2 = "abc"; - DateTime k1 = now,k2 = now; - TimeSpan l1 = tsX,l2 = tsX; - Version^ m1 = versX, ^m2 = gcnew Version( "2.0" ); - Guid n1 = guidX,n2 = guidX; - - // The following types are not CLS-compliant. - SByte w1 = 8,w2 = 8; - UInt16 x1 = 9,x2 = 9; - UInt32 y1 = 10,y2 = 10; - UInt64 z1 = 11,z2 = 11; - - // - Console::WriteLine( msg, nl ); - try - { - Show( "Boolean: ", a1, a2, a1.CompareTo( a2 ), a1.CompareTo( a2 ) ); - Show( "Byte: ", b1, b2, b1.CompareTo( b2 ), b1.CompareTo( b2 ) ); - Show( "Int16: ", c1, c2, c1.CompareTo( c2 ), c1.CompareTo( c2 ) ); - Show( "Int32: ", d1, d2, d1.CompareTo( d2 ), d1.CompareTo( d2 ) ); - Show( "Int64: ", e1, e2, e1.CompareTo( e2 ), e1.CompareTo( e2 ) ); - Show( "Decimal: ", f1, f2, f1.CompareTo( f2 ), f1.CompareTo( f2 ) ); - Show( "Single: ", g1, g2, g1.CompareTo( g2 ), g1.CompareTo( g2 ) ); - Show( "Double: ", h1, h2, h1.CompareTo( h2 ), h1.CompareTo( h2 ) ); - Show( "Char: ", i1, i2, i1.CompareTo( i2 ), i1.CompareTo( i2 ) ); - - // Use an anonymous object to hide the String object. - obj = j2; - Show( "String: ", j1, j2, j1->CompareTo( j2 ), j1->CompareTo( obj ) ); - Show( "DateTime:", k1, k2, k1.CompareTo( k2 ), k1.CompareTo( k2 ) ); - Show( "TimeSpan: ", l1, l2, l1.CompareTo( l2 ), l1.CompareTo( l2 ) ); - - // Use an anonymous object to hide the Version object. - obj = m2; - Show( "Version: ", m1, m2, m1->CompareTo( m2 ), m1->CompareTo( obj ) ); - Show( "Guid: ", n1, n2, n1.CompareTo( n2 ), n1.CompareTo( n2 ) ); - - // - Console::WriteLine( "{0}The following types are not CLS-compliant:", nl ); - Show( "SByte: ", w1, w2, w1.CompareTo( w2 ), w1.CompareTo( w2 ) ); - Show( "UInt16: ", x1, x2, x1.CompareTo( x2 ), x1.CompareTo( x2 ) ); - Show( "UInt32: ", y1, y2, y1.CompareTo( y2 ), y1.CompareTo( y2 ) ); - Show( "UInt64: ", z1, z2, z1.CompareTo( z2 ), z1.CompareTo( z2 ) ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e ); - } - -} -// This example displays the following output: -// -// The following is the result of using the generic and non-generic versions of the -// CompareTo method for several base types: -// -// Boolean: True is equal to True -// Byte: 1 is equal to 1 -// Int16: -2 is less than 2 -// Int32: 3 is equal to 3 -// Int64: 4 is greater than -4 -// Decimal: -5.5 is less than 5.5 -// Single: 6.6 is equal to 6.6 -// Double: 7.7 is greater than -7.7 -// Char: A is equal to A -// String: abc is equal to abc -// DateTime: 12/1/2003 5:37:46 PM is equal to 12/1/2003 5:37:46 PM -// TimeSpan: 11.22:33:44 is equal to 11.22:33:44 -// Version: 1.2.333.4 is less than 2.0 -// Guid: ca761232-ed42-11ce-bacd-00aa0057b223 is equal to ca761232-ed42-11ce-bacd-00 -// aa0057b223 -// -// The following types are not CLS-compliant: -// SByte: 8 is equal to 8 -// UInt16: 9 is equal to 9 -// UInt32: 10 is equal to 10 -// UInt64: 11 is equal to 11 -// diff --git a/snippets/cpp/VS_Snippets_CLR/T.TryParse/CPP/tp.cpp b/snippets/cpp/VS_Snippets_CLR/T.TryParse/CPP/tp.cpp deleted file mode 100644 index cc253499947..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/T.TryParse/CPP/tp.cpp +++ /dev/null @@ -1,181 +0,0 @@ -// -// This example demonstrates overloads of the TryParse method for -// several base types, and the TryParseExact method for DateTime. -// In most cases, this example uses the most complex overload; that is, the overload -// with the most parameters for a particular type. If a complex overload specifies -// null (Nothing in Visual Basic) for the IFormatProvider parameter, formatting -// information is obtained from the culture associated with the current thread. -// If a complex overload specifies the style parameter, the parameter value is -// the default value used by the equivalent simple overload. -using namespace System; -using namespace System::Globalization; - -static void Show( bool parseResult, String^ typeName, String^ parseValue ) -{ - String^ msgSuccess = L"Parse for {0} = {1}"; - String^ msgFailure = L"** Parse for {0} failed. Invalid input."; - - // - if ( parseResult ) - Console::WriteLine( msgSuccess, typeName, parseValue ); - else - Console::WriteLine( msgFailure, typeName ); -} - -void main() -{ - bool result; - CultureInfo^ ci; - String^ nl = Environment::NewLine; - String^ msg1 = L"This example demonstrates overloads of the TryParse method for{0}" - L"several base types, as well as the TryParseExact method for DateTime.{0}"; - String^ msg2 = L"Non-numeric types:{0}"; - String^ msg3 = L"{0}Numeric types:{0}"; - String^ msg4 = L"{0}The following types are not CLS-compliant:{0}"; - - // Non-numeric types. - Boolean booleanVal; - Char charVal; - DateTime datetimeVal; - - // Numeric types. - Byte byteVal; - Int16 int16Val; - Int32 int32Val; - Int64 int64Val; - Decimal decimalVal; - Single singleVal; - Double doubleVal; - - // The following types are not CLS-compliant. - SByte sbyteVal; - UInt16 uint16Val; - UInt32 uint32Val; - UInt64 uint64Val; - - // - Console::WriteLine( msg1, nl ); - - // Non-numeric types: - Console::WriteLine( msg2, nl ); - - // DateTime - // TryParse: - // Assume current culture is en-US, and dates of the form: MMDDYYYY. - result = DateTime::TryParse( L"7/4/2004 12:34:56", datetimeVal ); - Show( result, L"DateTime #1", datetimeVal.ToString() ); - - // Use fr-FR culture, and dates of the form: DDMMYYYY. - ci = gcnew CultureInfo( L"fr-FR" ); - result = DateTime::TryParse( L"4/7/2004 12:34:56", ci, DateTimeStyles::None, datetimeVal ); - Show( result, L"DateTime #2", datetimeVal.ToString() ); - - // TryParseExact: - // Use fr-FR culture. The format, "G", is short date and long time. - result = DateTime::TryParseExact( L"04/07/2004 12:34:56", L"G", ci, DateTimeStyles::None, datetimeVal ); - Show( result, L"DateTime #3", datetimeVal.ToString() ); - - // Assume en-US culture. - array^dateFormats = {L"f",L"F",L"g",L"G"}; - result = DateTime::TryParseExact( L"7/4/2004 12:34:56 PM", dateFormats, nullptr, DateTimeStyles::None, datetimeVal ); - Show( result, L"DateTime #4", datetimeVal.ToString() ); - Console::WriteLine(); - - // Boolean - result = Boolean::TryParse( L"true", booleanVal ); - Show( result, L"Boolean", booleanVal.ToString() ); - - // Char - result = Char::TryParse( L"A", charVal ); - Show( result, L"Char", charVal.ToString() ); - - // Numeric types: - Console::WriteLine( msg3, nl ); - - // Byte - result = Byte::TryParse( L"1", NumberStyles::Integer, nullptr, byteVal ); - Show( result, L"Byte", byteVal.ToString() ); - - // Int16 - result = Int16::TryParse( L"-2", NumberStyles::Integer, nullptr, int16Val ); - Show( result, L"Int16", int16Val.ToString() ); - - // Int32 - result = Int32::TryParse( L"3", NumberStyles::Integer, nullptr, int32Val ); - Show( result, L"Int32", int32Val.ToString() ); - - // Int64 - result = Int64::TryParse( L"4", NumberStyles::Integer, nullptr, int64Val ); - Show( result, L"Int64", int64Val.ToString() ); - - // Decimal - result = Decimal::TryParse( L"-5.5", NumberStyles::Number, nullptr, decimalVal ); - Show( result, L"Decimal", decimalVal.ToString() ); - - // Single - result = Single::TryParse( L"6.6", static_cast((NumberStyles::Float | NumberStyles::AllowThousands)), nullptr, singleVal ); - Show( result, L"Single", singleVal.ToString() ); - - // Double - result = Double::TryParse( L"-7", static_cast(NumberStyles::Float | NumberStyles::AllowThousands), nullptr, doubleVal ); - Show( result, L"Double", doubleVal.ToString() ); - - // Use the simple Double.TryParse overload, but specify an invalid value. - result = Double::TryParse( L"abc", doubleVal ); - Show( result, L"Double #2", doubleVal.ToString() ); - - // - Console::WriteLine( msg4, nl ); - - // SByte - result = SByte::TryParse( L"-8", NumberStyles::Integer, nullptr, sbyteVal ); - Show( result, L"SByte", sbyteVal.ToString() ); - - // UInt16 - result = UInt16::TryParse( L"9", NumberStyles::Integer, nullptr, uint16Val ); - Show( result, L"UInt16", uint16Val.ToString() ); - - // UInt32 - result = UInt32::TryParse( L"10", NumberStyles::Integer, nullptr, uint32Val ); - Show( result, L"UInt32", uint32Val.ToString() ); - - // UInt64 - result = UInt64::TryParse( L"11", NumberStyles::Integer, nullptr, uint64Val ); - Show( result, L"UInt64", uint64Val.ToString() ); -} - -/* -This example produces the following results: - -This example demonstrates overloads of the TryParse method for -several base types, as well as the TryParseExact method for DateTime. - -Non-numeric types: - -Parse for DateTime #1 = 7/4/2004 12:34:56 PM -Parse for DateTime #2 = 7/4/2004 12:34:56 PM -Parse for DateTime #3 = 7/4/2004 12:34:56 PM -Parse for DateTime #4 = 7/4/2004 12:34:56 PM - -Parse for Boolean = True -Parse for Char = A - -Numeric types: - -Parse for Byte = 1 -Parse for Int16 = -2 -Parse for Int32 = 3 -Parse for Int64 = 4 -Parse for Decimal = -5.5 -Parse for Single = 6.6 -Parse for Double = -7 -** Parse for Double #2 failed. Invalid input. - -The following types are not CLS-compliant: - -Parse for SByte = -8 -Parse for UInt16 = 9 -Parse for UInt32 = 10 -Parse for UInt64 = 11 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/TestBaseType/CPP/testbasetype.cpp b/snippets/cpp/VS_Snippets_CLR/TestBaseType/CPP/testbasetype.cpp deleted file mode 100644 index e6f659eaf11..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/TestBaseType/CPP/testbasetype.cpp +++ /dev/null @@ -1,10 +0,0 @@ - -// -using namespace System; -void main() -{ - Type^ t = int::typeid; - Console::WriteLine( "{0} inherits from {1}.", t, t->BaseType ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/TestFullName/CPP/TestFullName.cpp b/snippets/cpp/VS_Snippets_CLR/TestFullName/CPP/TestFullName.cpp deleted file mode 100644 index 9faf8c82ca5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/TestFullName/CPP/TestFullName.cpp +++ /dev/null @@ -1,14 +0,0 @@ - -// -using namespace System; -int main() -{ - Type^ t = Array::typeid; - Console::WriteLine( "The full name of the Array type is {0}.", t->FullName ); -} - -/* This example produces the following output: - -The full name of the Array type is System.Array. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/TestGetElementType/CPP/TestGetElementType.cpp b/snippets/cpp/VS_Snippets_CLR/TestGetElementType/CPP/TestGetElementType.cpp deleted file mode 100644 index 801fb6bb503..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/TestGetElementType/CPP/TestGetElementType.cpp +++ /dev/null @@ -1,23 +0,0 @@ - -// -using namespace System; -public ref class TestGetElementType{}; - -int main() -{ - array^array = {1,2,3}; - Type^ t = array->GetType(); - Type^ t2 = t->GetElementType(); - Console::WriteLine( "The element type of {0} is {1}.", array, t2 ); - TestGetElementType^ newMe = gcnew TestGetElementType; - t = newMe->GetType(); - t2 = t->GetElementType(); - Console::WriteLine( "The element type of {0} is {1}.", newMe, t2 == nullptr ? "null" : t2->ToString() ); -} - -/* This code produces the following output: - -The element type of System.Int32[] is System.Int32. -The element type of TestGetElementType is null. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/TestIsAssignableFrom/cpp/testisassignablefrom.cpp b/snippets/cpp/VS_Snippets_CLR/TestIsAssignableFrom/cpp/testisassignablefrom.cpp deleted file mode 100644 index aea549667ea..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/TestIsAssignableFrom/cpp/testisassignablefrom.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// -using namespace System; -using namespace System::Collections::Generic; - -ref class Room -{ -}; - -ref class Kitchen : Room -{ -}; - -ref class Bedroom : Room -{ -}; - -ref class Guestroom : Bedroom -{ -}; - -ref class MasterBedroom : Bedroom -{ -}; - -ref class Program -{ -public: - static void Main() - { - // Demonstrate classes: - Console::WriteLine("Defined Classes:"); - Room^ room1 = gcnew Room(); - Kitchen^ kitchen1 = gcnew Kitchen(); - Bedroom^ bedroom1 = gcnew Bedroom(); - Guestroom^ guestroom1 = gcnew Guestroom(); - MasterBedroom^ masterbedroom1 = gcnew MasterBedroom(); - - Type^ room1Type = room1->GetType(); - Type^ kitchen1Type = kitchen1->GetType(); - Type^ bedroom1Type = bedroom1->GetType(); - Type^ guestroom1Type = guestroom1->GetType(); - Type^ masterbedroom1Type = masterbedroom1->GetType(); - - Console::WriteLine("room assignable from kitchen: {0}", room1Type->IsAssignableFrom(kitchen1Type)); - Console::WriteLine("bedroom assignable from guestroom: {0}", bedroom1Type->IsAssignableFrom(guestroom1Type)); - Console::WriteLine("kitchen assignable from masterbedroom: {0}", kitchen1Type->IsAssignableFrom(masterbedroom1Type)); - - // Demonstrate arrays: - Console::WriteLine(); - Console::WriteLine("Integer arrays:"); - array^ array2 = gcnew array(2); - array^ array10 = gcnew array(10); - array^ array22 = gcnew array(2, 2); - array^ array24 = gcnew array(2, 4); - - Type^ array2Type = array2->GetType(); - Type^ array10Type = array10->GetType(); - Type^ array22Type = array22->GetType(); - Type^ array24Type = array24->GetType(); - - Console::WriteLine("Int32[2] assignable from Int32[10]: {0}", array2Type->IsAssignableFrom(array10Type)); - Console::WriteLine("Int32[2] assignable from Int32[2,4]: {0}", array2Type->IsAssignableFrom(array24Type)); - Console::WriteLine("Int32[2,4] assignable from Int32[2,2]: {0}", array24Type->IsAssignableFrom(array22Type)); - - // Demonstrate generics: - Console::WriteLine(); - Console::WriteLine("Generics:"); - - // Note that "int?[]" is the same as "Nullable[]" - //int?[] arrayNull = new int?[10]; - array^ arrayNull = gcnew array(10); - List^ genIntList = gcnew List(); - List^ genTList = gcnew List(); - - Type^ arrayNullType = arrayNull->GetType(); - Type^ genIntListType = genIntList->GetType(); - Type^ genTListType = genTList->GetType(); - - Console::WriteLine("Int32[10] assignable from Nullable[10]: {0}", array10Type->IsAssignableFrom(arrayNullType)); - Console::WriteLine("List assignable from List: {0}", genIntListType->IsAssignableFrom(genTListType)); - Console::WriteLine("List assignable from List: {0}", genTListType->IsAssignableFrom(genIntListType)); - - Console::ReadLine(); - } -}; - -int main() -{ - Program::Main(); -} - -//This code example produces the following output: -// -// Defined Classes: -// room assignable from kitchen: True -// bedroom assignable from guestroom: True -//kitchen assignable from masterbedroom: False -// -// Integer arrays: -// Int32[2] assignable from Int32[10]: True -// Int32[2] assignable from Int32[2,4]: False -// Int32[2,4] assignable from Int32[2,2]: True -// -// Generics: -// Int32[10] assignable from Nullable[10]: False -// List assignable from List: False -// List assignable from List: False -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/TestIsEnum/CPP/TestIsEnum.cpp b/snippets/cpp/VS_Snippets_CLR/TestIsEnum/CPP/TestIsEnum.cpp deleted file mode 100644 index 9c1f8344454..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/TestIsEnum/CPP/TestIsEnum.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -enum class Color -{ Red, Blue, Green }; - -int main() -{ - Type^ colorType = Color::typeid; - Type^ enumType = Enum::typeid; - Console::WriteLine( "Is Color an enum? {0}.", colorType->IsEnum ); - Console::WriteLine( "Is Color a value type? {0}.", colorType->IsValueType ); - Console::WriteLine( "Is Enum an enum Type? {0}.", enumType->IsEnum ); - Console::WriteLine( "Is Enum a value type? {0}.", enumType->IsValueType ); -} -// The example displays the following output: -// Is Color an enum? True. -// Is Color a value type? True. -// Is Enum an enum type? False. -// Is Enum a value type? False. -// diff --git a/snippets/cpp/VS_Snippets_CLR/TestIsInstanceOfType/CPP/testisinstanceoftype.cpp b/snippets/cpp/VS_Snippets_CLR/TestIsInstanceOfType/CPP/testisinstanceoftype.cpp deleted file mode 100644 index b2152ac3fa7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/TestIsInstanceOfType/CPP/testisinstanceoftype.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -// -using namespace System; - -public interface class IExample{}; - -public ref class BaseClass: IExample{}; - -public ref class DerivedClass: BaseClass{}; - -void main() -{ - Type^ interfaceType = IExample::typeid; - BaseClass^ base1 = gcnew BaseClass; - Type^ base1Type = base1->GetType(); - BaseClass^ derived1 = gcnew DerivedClass; - Type^ derived1Type = derived1->GetType(); - array^ arr = gcnew array(11); - Type^ arrayType = Array::typeid; - - Console::WriteLine("Is Int32[] an instance of the Array class? {0}.", - arrayType->IsInstanceOfType( arr ) ); - Console::WriteLine("Is myclass an instance of BaseClass? {0}.", - base1Type->IsInstanceOfType( base1 ) ); - Console::WriteLine("Is myderivedclass an instance of BaseClass? {0}.", - base1Type->IsInstanceOfType( derived1 ) ); - Console::WriteLine("Is myclass an instance of IExample? {0}.", - interfaceType->IsInstanceOfType( base1 ) ); - Console::WriteLine("Is myderivedclass an instance of IExample? {0}.", - interfaceType->IsInstanceOfType( derived1 ) ); -} -// The example displays the following output: -// Is int[] an instance of the Array class? True. -// Is base1 an instance of BaseClass? True. -// Is derived1 an instance of BaseClass? True. -// Is base1 an instance of IExample? True. -// Is derived1 an instance of IExample? True. -// diff --git a/snippets/cpp/VS_Snippets_CLR/TimeoutException.class/cpp/to.cpp b/snippets/cpp/VS_Snippets_CLR/TimeoutException.class/cpp/to.cpp deleted file mode 100644 index 29339b956eb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/TimeoutException.class/cpp/to.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// -// This example demonstrates the use of the TimeoutException -// exception in conjunction with the SerialPort class. - -#using - -using namespace System; -using namespace System::IO::Ports; - -int main() -{ - String^ input; - try - { - // Set the COM1 serial port to speed = 4800 baud, parity = odd, - // data bits = 8, stop bits = 1. - SerialPort^ port = gcnew SerialPort("COM1", - 4800, Parity::Odd, 8, StopBits::One); - // Timeout after 2 seconds. - port->ReadTimeout = 2000; - port->Open(); - - // Read until either the default newline termination string - // is detected or the read operation times out. - input = port->ReadLine(); - - port->Close(); - - // Echo the input. - Console::WriteLine(input); - } - - // Only catch timeout exceptions. - catch (TimeoutException^ ex) - { - Console::WriteLine(ex); - } -}; -/* -This example produces the following results: - -(Data received at the serial port is echoed to the console if the -read operation completes successfully before the specified timeout period -expires. Otherwise, a timeout exception like the following is thrown.) - -System.TimeoutException: The operation has timed-out. -at System.IO.Ports.SerialStream.ReadByte(Int32 timeout) -at System.IO.Ports.SerialPort.ReadOneChar(Int32 timeout) -at System.IO.Ports.SerialPort.ReadTo(String value) -at System.IO.Ports.SerialPort.ReadLine() -at Sample.Main() -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type.IsPublic/CPP/type_ispublic.cpp b/snippets/cpp/VS_Snippets_CLR/Type.IsPublic/CPP/type_ispublic.cpp deleted file mode 100644 index 813adf57610..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type.IsPublic/CPP/type_ispublic.cpp +++ /dev/null @@ -1,20 +0,0 @@ - -// -using namespace System; - -// Declare MyTestClass as public. -public ref class TestClass{}; - -int main() -{ - TestClass^ testClassInstance = gcnew TestClass; - - // Get the type of myTestClassInstance. - Type^ testType = testClassInstance->GetType(); - - // Get the IsPublic property of the myTestClassInstance. - bool isPublic = testType->IsPublic; - Console::WriteLine( "Is {0} public? {1}", testType->FullName, isPublic); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type.StructLayoutAttribute/CPP/Type.StructLayoutAttribute.cpp b/snippets/cpp/VS_Snippets_CLR/Type.StructLayoutAttribute/CPP/Type.StructLayoutAttribute.cpp deleted file mode 100644 index 3f49f739983..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type.StructLayoutAttribute/CPP/Type.StructLayoutAttribute.cpp +++ /dev/null @@ -1,40 +0,0 @@ - -// -using namespace System; -using namespace System::Runtime::InteropServices; -value struct Test1 -{ -public: - Byte B1; - short S; - Byte B2; -}; - - -[StructLayout(LayoutKind::Explicit,Pack=1)] -value struct Test2 -{ -public: - - [FieldOffset(0)] - Byte B1; - - [FieldOffset(1)] - short S; - - [FieldOffset(3)] - Byte B2; -}; - -static void DisplayLayoutAttribute( StructLayoutAttribute^ sla ) -{ - Console::WriteLine( L"\r\nCharSet: {0}\r\n Pack: {1}\r\n Size: {2}\r\n Value: {3}", sla->CharSet, sla->Pack, sla->Size, sla->Value ); -} - -int main() -{ - DisplayLayoutAttribute( Test1::typeid->StructLayoutAttribute ); - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/TypeLoadException_Constructor2/CPP/typeloadexception_constructor2.cpp b/snippets/cpp/VS_Snippets_CLR/TypeLoadException_Constructor2/CPP/typeloadexception_constructor2.cpp deleted file mode 100644 index cb8e0c58917..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/TypeLoadException_Constructor2/CPP/typeloadexception_constructor2.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -using namespace System; - -class TypeLoadExceptionDemoClass -{ - public: - static bool GenerateException() - { - // Throw a TypeLoadException with a custom message. - throw gcnew TypeLoadException("This is a custom TypeLoadException error message."); - } -}; - -int main() -{ - try { - // Call a method that throws an exception. - TypeLoadExceptionDemoClass::GenerateException(); - } - catch ( TypeLoadException^ e ) { - Console::WriteLine("TypeLoadException:\n {0}", e->Message); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: \n\tError Message = {0}", e->Message ); - } - -} -// The example displays the following output: -// TypeLoadException: -// This is a custom TypeLoadException error message. -// diff --git a/snippets/cpp/VS_Snippets_CLR/TypeLoadException_Constructor3/CPP/typeloadexception_constructor3.cpp b/snippets/cpp/VS_Snippets_CLR/TypeLoadException_Constructor3/CPP/typeloadexception_constructor3.cpp deleted file mode 100644 index 649e2fc5034..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/TypeLoadException_Constructor3/CPP/typeloadexception_constructor3.cpp +++ /dev/null @@ -1,56 +0,0 @@ - -// System::TypeLoadException::TypeLoadException -/* This program demonstrates the 'TypeLoadException(String*, Exception)' - constructor of 'TypeLoadException' class. It attempts to call a - non-existent method located in NonExistentDLL.dll, which will - throw an exception. A new exception is thrown with this exception - as an inner exception. -*/ -// -using namespace System; -using namespace System::Runtime::InteropServices; -ref class TypeLoadExceptionDemoClass -{ -public: - - // A call to this method will raise a TypeLoadException. - - [DllImport("NonExistentDLL.DLL",EntryPoint="MethodNotExists")] - static void NonExistentMethod(); - static void GenerateException() - { - try - { - NonExistentMethod(); - } - catch ( TypeLoadException^ e ) - { - - // Rethrow exception with the exception as inner exception - throw gcnew TypeLoadException( "This exception was raised due to a call to an invalid method.",e ); - } - - } - -}; - -int main() -{ - Console::WriteLine( "Calling a method in a non-existent DLL which triggers a TypeLoadException." ); - try - { - TypeLoadExceptionDemoClass::GenerateException(); - } - catch ( TypeLoadException^ e ) - { - Console::WriteLine( "TypeLoadException: \n\tError Message = {0}", e->Message ); - Console::WriteLine( "TypeLoadException: \n\tInnerException Message = {0}", e->InnerException->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: \n\tError Message = {0}", e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/TypeLoadException_GetObjectData/CPP/typeloadexception_getobjectdata.cpp b/snippets/cpp/VS_Snippets_CLR/TypeLoadException_GetObjectData/CPP/typeloadexception_getobjectdata.cpp deleted file mode 100644 index 6b8fd92068e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/TypeLoadException_GetObjectData/CPP/typeloadexception_getobjectdata.cpp +++ /dev/null @@ -1,112 +0,0 @@ - - -// System::TypeLoadException::GetObjectData -// System::TypeLoadException -/* This program demonstrates the 'GetObjectData' method and the - protected constructor TypeLoadException(SerializationInfo, StreamingContext) - of 'TypeLoadException' class. It generates an exception and - serializes the exception data to a file and then reconstitutes the - exception. -*/ -// -// -#using - -using namespace System; -using namespace System::Reflection; -using namespace System::Runtime::Serialization; -using namespace System::Runtime::Serialization::Formatters::Soap; -using namespace System::IO; - -// This class overrides the GetObjectData method and initializes -// its data with current time. - -[Serializable] -public ref class MyTypeLoadExceptionChild: public TypeLoadException -{ -public: - System::DateTime ErrorDateTime; - MyTypeLoadExceptionChild() - { - ErrorDateTime = DateTime::Now; - } - - MyTypeLoadExceptionChild( DateTime myDateTime ) - { - ErrorDateTime = myDateTime; - } - - -protected: - MyTypeLoadExceptionChild( SerializationInfo^ sInfo, StreamingContext * sContext ) - { - - // Reconstitute the deserialized information into the instance. - ErrorDateTime = sInfo->GetDateTime( "ErrorDate" ); - } - - -public: - void GetObjectData( SerializationInfo^ sInfo, StreamingContext * sContext ) - { - - // Add a value to the Serialization information. - sInfo->AddValue( "ErrorDate", ErrorDateTime ); - } - -}; - -int main() -{ - - // Load the mscorlib assembly and get a reference to it. - // You must supply the fully qualified assembly name for mscorlib.dll here. - Assembly^ myAssembly = Assembly::Load( "Assembly text name, Version, Culture, PublicKeyToken" ); - try - { - Console::WriteLine( "Attempting to load a type not present in the assembly 'mscorlib'" ); - - // This loading of invalid type raises a TypeLoadException - Type^ myType = myAssembly->GetType( "System::NonExistentType", true ); - } - catch ( TypeLoadException^ ) - { - - // Serialize the exception to disk and reconstitute it back again. - try - { - System::DateTime ErrorDatetime = DateTime::Now; - Console::WriteLine( "A TypeLoadException has been raised." ); - - // Create MyTypeLoadException instance with current time. - MyTypeLoadExceptionChild^ myTypeLoadExceptionChild = gcnew MyTypeLoadExceptionChild( ErrorDatetime ); - IFormatter^ myFormatter = gcnew SoapFormatter; - Stream^ myFileStream = gcnew FileStream( "typeload.xml",FileMode::Create,FileAccess::Write,FileShare::None ); - Console::WriteLine( "Serializing the TypeLoadException with DateTime as {0}", ErrorDatetime ); - - // Serialize the MyTypeLoadException instance to a file. - myFormatter->Serialize( myFileStream, myTypeLoadExceptionChild ); - myFileStream->Close(); - Console::WriteLine( "Deserializing the Exception." ); - myFileStream = gcnew FileStream( "typeload.xml",FileMode::Open,FileAccess::Read,FileShare::None ); - - // Deserialize and reconstitute the instance from file. - myTypeLoadExceptionChild = safe_cast(myFormatter->Deserialize( myFileStream )); - myFileStream->Close(); - Console::WriteLine( "Deserialized exception has ErrorDateTime = {0}", myTypeLoadExceptionChild->ErrorDateTime ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - } - - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - } - -} - -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/TypeLoadException_TypeName/CPP/typeloadexception_typename.cpp b/snippets/cpp/VS_Snippets_CLR/TypeLoadException_TypeName/CPP/typeloadexception_typename.cpp deleted file mode 100644 index 102cf32f110..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/TypeLoadException_TypeName/CPP/typeloadexception_typename.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// System::TypeLoadException::TypeName;System::TypeLoadException::Message - -/* This program demonstrates the 'TypeName' and 'Message' properties - of the 'TypeLoadException' class. It attempts to load a - non-existent type from the mscorlib assembly which throws an - exception. This exception is caught and the TypeName and Message - values are displayed. -*/ - -using namespace System; -using namespace System::Reflection; - -int main() -{ - // - // - // Load the mscorlib assembly and get a reference to it. - // You must supply the fully qualified assembly name for mscorlib.dll here. - Assembly^ myAssembly = Assembly::Load( "Assembly text name, Version, Culture, PublicKeyToken" ); - try - { - Console::WriteLine( "This program throws an exception upon successful run." ); - - // Attempt to load a non-existent type from an assembly. - Type^ myType = myAssembly->GetType( "System.NonExistentType", true ); - } - catch ( TypeLoadException^ e ) - { - // Display the name of the Type that was not found. - Console::WriteLine( "TypeLoadException: \n\tError loading the type '{0}' from the assembly 'mscorlib'", e->TypeName ); - Console::WriteLine( "\tError Message = {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: Error Message = {0}", e->Message ); - } - // - // -} diff --git a/snippets/cpp/VS_Snippets_CLR/Type_Assembly/CPP/type_assembly.cpp b/snippets/cpp/VS_Snippets_CLR/Type_Assembly/CPP/type_assembly.cpp deleted file mode 100644 index 4ae236700c1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_Assembly/CPP/type_assembly.cpp +++ /dev/null @@ -1,20 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -int main() -{ - Type^ objType = System::Array::typeid; - - // Print the full assembly name. - Console::WriteLine( "Full assembly name: {0}.", objType->Assembly->FullName ); - - // Print the qualified assembly name. - Console::WriteLine( "Qualified assembly name: {0}.", objType->AssemblyQualifiedName ); -} -// The example displays the following output if run under the .NET Framework 4.5: -// Full assembly name: -// mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. -// Qualified assembly name: -// System.Array, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_DefaultBinder/CPP/type_defaultbinder.cpp b/snippets/cpp/VS_Snippets_CLR/Type_DefaultBinder/CPP/type_defaultbinder.cpp deleted file mode 100644 index f9301b87911..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_DefaultBinder/CPP/type_defaultbinder.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -ref class MyClass -{ -public: - void HelloWorld() - { - Console::WriteLine( "Hello World" ); - } - -}; - -int main() -{ - try - { - Binder^ defaultBinder = Type::DefaultBinder; - MyClass^ myClass = gcnew MyClass; - - // Invoke the HelloWorld method of MyClass. - myClass->GetType()->InvokeMember( "HelloWorld", BindingFlags::InvokeMethod, defaultBinder, myClass, nullptr ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_FilterAttribute/CPP/type_filterattribute.cpp b/snippets/cpp/VS_Snippets_CLR/Type_FilterAttribute/CPP/type_filterattribute.cpp deleted file mode 100644 index bcb5e2a58a1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_FilterAttribute/CPP/type_filterattribute.cpp +++ /dev/null @@ -1,36 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -using namespace System::Reflection; -using namespace System::Security; -int main() -{ - try - { - MemberFilter^ myFilter = Type::FilterAttribute; - Type^ myType = System::String::typeid; - array^myMemberInfoArray = myType->FindMembers( static_cast(MemberTypes::Constructor | MemberTypes::Method), static_cast(BindingFlags::Public | BindingFlags::Static | BindingFlags::Instance), myFilter, MethodAttributes::SpecialName ); - IEnumerator^ myEnum = myMemberInfoArray->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - MemberInfo^ myMemberinfo = safe_cast(myEnum->Current); - Console::Write( "\n {0}", myMemberinfo->Name ); - Console::Write( " is a {0}", myMemberinfo->MemberType ); - } - } - catch ( ArgumentNullException^ e ) - { - Console::Write( "ArgumentNullException : {0}", e->Message ); - } - catch ( SecurityException^ e ) - { - Console::Write( "SecurityException : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::Write( "Exception : {0}", e->Message ); - } - -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_FilterNameIgnoreCase/CPP/type_filternameignorecase.cpp b/snippets/cpp/VS_Snippets_CLR/Type_FilterNameIgnoreCase/CPP/type_filternameignorecase.cpp deleted file mode 100644 index 38bf38a1528..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_FilterNameIgnoreCase/CPP/type_filternameignorecase.cpp +++ /dev/null @@ -1,36 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -using namespace System::Reflection; -using namespace System::Security; -int main() -{ - try - { - MemberFilter^ myFilter = Type::FilterNameIgnoreCase; - Type^ myType = System::String::typeid; - array^myMemberinfo1 = myType->FindMembers( static_cast(MemberTypes::Constructor | MemberTypes::Method), static_cast(BindingFlags::Public | BindingFlags::Static | BindingFlags::Instance), myFilter, "C*" ); - IEnumerator^ myEnum = myMemberinfo1->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - MemberInfo^ myMemberinfo2 = safe_cast(myEnum->Current); - Console::Write( "\n {0}", myMemberinfo2->Name ); - MemberTypes Mymembertypes = myMemberinfo2->MemberType; - Console::WriteLine( " is a {0}", Mymembertypes ); - } - } - catch ( ArgumentNullException^ e ) - { - Console::Write( "ArgumentNullException : {0}", e->Message ); - } - catch ( SecurityException^ e ) - { - Console::Write( "SecurityException : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::Write( "Exception : {0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_FindInterfaces/CPP/type_findinterfaces.cpp b/snippets/cpp/VS_Snippets_CLR/Type_FindInterfaces/CPP/type_findinterfaces.cpp deleted file mode 100644 index 12d2c367f57..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_FindInterfaces/CPP/type_findinterfaces.cpp +++ /dev/null @@ -1,69 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Reflection; -public ref class MyFindInterfacesSample -{ -public: - static bool MyInterfaceFilter(Type^ typeObj, Object^ criteriaObj) - { - if(typeObj->ToString()->Equals(criteriaObj->ToString())) - return true; - else - return false; - } -}; - -int main() -{ - try - { - XmlDocument^ myXMLDoc = gcnew XmlDocument; - myXMLDoc->LoadXml("" - + "Pride And Prejudice "); - Type^ myType = myXMLDoc->GetType(); - - // Specify the TypeFilter delegate that compares the interfaces - // against filter criteria. - TypeFilter^ myFilter = gcnew TypeFilter( - MyFindInterfacesSample::MyInterfaceFilter); - array^myInterfaceList = {"System.Collections.IEnumerable", - "System.Collections.ICollection"}; - for(int index = 0; index < myInterfaceList->Length; index++) - { - array^myInterfaces = myType->FindInterfaces( - myFilter, myInterfaceList[index]); - if(myInterfaces->Length > 0) - { - Console::WriteLine("\n{0} implements the interface {1}.", - myType, myInterfaceList[index]); - for(int j = 0; j < myInterfaces->Length; j++) - Console::WriteLine("Interfaces supported: {0}.", - myInterfaces[j]); - } - else - Console::WriteLine( - "\n{0} does not implement the interface {1}.", - myType, myInterfaceList[index]); - - } - } - catch(ArgumentNullException^ e) - { - Console::WriteLine("ArgumentNullException: {0}", e->Message); - } - catch(TargetInvocationException^ e) - { - Console::WriteLine("TargetInvocationException: {0}", e->Message); - } - catch(Exception^ e) - { - Console::WriteLine("Exception: {0}", e->Message); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_FindMembers/CPP/type_findmembers.cpp b/snippets/cpp/VS_Snippets_CLR/Type_FindMembers/CPP/type_findmembers.cpp deleted file mode 100644 index 759df40e831..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_FindMembers/CPP/type_findmembers.cpp +++ /dev/null @@ -1,48 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -ref class MyFindMembersClass -{ -public: - static void Test() - { - Object^ objTest = gcnew Object; - Type^ objType = objTest->GetType(); - array^arrayMemberInfo; - try - { - - //Find all static or public methods in the Object class that match the specified name. - arrayMemberInfo = objType->FindMembers( MemberTypes::Method, static_cast(BindingFlags::Public | BindingFlags::Static | BindingFlags::Instance), gcnew MemberFilter( DelegateToSearchCriteria ), "ReferenceEquals" ); - for ( int index = 0; index < arrayMemberInfo->Length; index++ ) - Console::WriteLine( "Result of FindMembers -\t {0}", String::Concat( arrayMemberInfo[ index ], "\n" ) ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e ); - } - - } - - static bool DelegateToSearchCriteria( MemberInfo^ objMemberInfo, Object^ objSearch ) - { - - // Compare the name of the member function with the filter criteria. - if ( objMemberInfo->Name->Equals( objSearch->ToString() ) ) - return true; - else - return false; - } - -}; - -int main() -{ - MyFindMembersClass::Test(); -} -/* The example produces the following output: - -Result of FindMembers - Boolean ReferenceEquals(System.Object, System.Object) -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetArrayRank/CPP/type_getarrayrank.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetArrayRank/CPP/type_getarrayrank.cpp deleted file mode 100644 index 0917b237224..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetArrayRank/CPP/type_getarrayrank.cpp +++ /dev/null @@ -1,27 +0,0 @@ - -// -using namespace System; -int main() -{ - try - { - array^myArray = gcnew array(3,4,5); - Type^ myType = myArray->GetType(); - Console::WriteLine( "myArray has {0} dimensions.", myType->GetArrayRank() ); - } - catch ( NotSupportedException^ e ) - { - Console::WriteLine( "NotSupportedException raised." ); - Console::WriteLine( "Source: {0}", e->Source ); - Console::WriteLine( "Message: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception raised." ); - Console::WriteLine( "Source: {0}", e->Source ); - Console::WriteLine( "Message: {0}", e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetConstructor/CPP/type_getconstructor.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetConstructor/CPP/type_getconstructor.cpp deleted file mode 100644 index b0cdfecb09c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetConstructor/CPP/type_getconstructor.cpp +++ /dev/null @@ -1,42 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -using namespace System::Security; -public ref class MyClass1 -{ -public: - MyClass1(){} - - MyClass1( int i ){} - -}; - -int main() -{ - try - { - Type^ myType = MyClass1::typeid; - array^types = gcnew array(1); - types[ 0 ] = int::typeid; - - // Get the constructor that takes an integer as a parameter. - ConstructorInfo^ constructorInfoObj = myType->GetConstructor( types ); - if ( constructorInfoObj != nullptr ) - { - Console::WriteLine( "The constructor of MyClass1 that takes an integer as a parameter is: " ); - Console::WriteLine( constructorInfoObj ); - } - else - { - Console::WriteLine( "The constructor of MyClass1 that takes an integer as a parameter is not available." ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception caught." ); - Console::WriteLine( "Source: {0}", e->Source ); - Console::WriteLine( "Message: {0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetConstructor2/CPP/type_getconstructor2.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetConstructor2/CPP/type_getconstructor2.cpp deleted file mode 100644 index 66f4064a45d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetConstructor2/CPP/type_getconstructor2.cpp +++ /dev/null @@ -1,50 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -using namespace System::Security; -public ref class MyClass1 -{ -public: - MyClass1( int i ){} - -}; - -int main() -{ - try - { - Type^ myType = MyClass1::typeid; - array^types = gcnew array(1); - types[ 0 ] = int::typeid; - - // Get the constructor that is public and takes an integer parameter. - ConstructorInfo^ constructorInfoObj = myType->GetConstructor( static_cast(BindingFlags::Instance | BindingFlags::Public), nullptr, types, nullptr ); - if ( constructorInfoObj != nullptr ) - { - Console::WriteLine( "The constructor of MyClass1 that is public and takes an integer as a parameter is:" ); - Console::WriteLine( constructorInfoObj ); - } - else - { - Console::WriteLine( "The constructor of the MyClass1 that is public and takes an integer as a parameter is not available." ); - } - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNullException: {0}", e->Message ); - } - catch ( ArgumentException^ e ) - { - Console::WriteLine( "ArgumentException: {0}", e->Message ); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetEvent/CPP/type_getevent.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetEvent/CPP/type_getevent.cpp deleted file mode 100644 index f6faf3d5c38..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetEvent/CPP/type_getevent.cpp +++ /dev/null @@ -1,41 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Reflection; -using namespace System::Security; - -int main() -{ - try - { - Type^ myType = System::Windows::Forms::Button::typeid; - EventInfo^ myEvent = myType->GetEvent( "Click" ); - if ( myEvent != nullptr ) - { - Console::WriteLine( "Looking for the Click event in the Button class." ); - Console::WriteLine( myEvent ); - } - else - Console::WriteLine( "The Click event is not available in the Button class." ); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "An exception occurred." ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "An exception occurred." ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The following exception was raised : {0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetField/CPP/type_getfield.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetField/CPP/type_getfield.cpp deleted file mode 100644 index 1921939e115..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetField/CPP/type_getfield.cpp +++ /dev/null @@ -1,97 +0,0 @@ - -// -// -using namespace System; -using namespace System::Reflection; -using namespace System::Security; -public ref class MyFieldClassA -{ -public: - String^ field; - MyFieldClassA() - { - field = "A Field"; - } - - - property String^ Field - { - String^ get() - { - return field; - } - - void set( String^ value ) - { - if ( field != value ) - { - field = value; - } - } - - } - -}; - -public ref class MyFieldClassB -{ -public: - String^ field; - MyFieldClassB() - { - field = "B Field"; - } - - - property String^ Field - { - String^ get() - { - return field; - } - - void set( String^ value ) - { - if ( field != value ) - { - field = value; - } - } - - } - -}; - -int main() -{ - try - { - MyFieldClassB^ myFieldObjectB = gcnew MyFieldClassB; - MyFieldClassA^ myFieldObjectA = gcnew MyFieldClassA; - Type^ myTypeA = Type::GetType( "MyFieldClassA" ); - FieldInfo^ myFieldInfo = myTypeA->GetField( "field" ); - Type^ myTypeB = Type::GetType( "MyFieldClassB" ); - FieldInfo^ myFieldInfo1 = myTypeB->GetField( "field", static_cast(BindingFlags::Public | BindingFlags::Instance) ); - Console::WriteLine( "The value of the field is : {0} ", myFieldInfo->GetValue( myFieldObjectA ) ); - Console::WriteLine( "The value of the field is : {0} ", myFieldInfo1->GetValue( myFieldObjectB ) ); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "Exception Raised!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "Exception Raised!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception Raised!" ); - Console::WriteLine( "Message : {0}", e->Message ); - } - -} - -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetHashCode_GetFields/CPP/type_gethashcode_getfields.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetHashCode_GetFields/CPP/type_gethashcode_getfields.cpp deleted file mode 100644 index 38a4f53dbdb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetHashCode_GetFields/CPP/type_gethashcode_getfields.cpp +++ /dev/null @@ -1,49 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Security; -using namespace System::Reflection; - -int main() -{ - Type^ myType = System::Net::IPAddress::typeid; - array^myFields = myType->GetFields( static_cast(BindingFlags::Static | BindingFlags::NonPublic) ); - Console::WriteLine( "\nThe IPAddress class has the following nonpublic fields: " ); - System::Collections::IEnumerator^ myEnum = myFields->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - FieldInfo^ myField = safe_cast(myEnum->Current); - Console::WriteLine( myField ); - } - - Type^ myType1 = System::Net::IPAddress::typeid; - array^myFields1 = myType1->GetFields(); - Console::WriteLine( "\nThe IPAddress class has the following public fields: " ); - System::Collections::IEnumerator^ myEnum2 = myFields1->GetEnumerator(); - while ( myEnum2->MoveNext() ) - { - FieldInfo^ myField = safe_cast(myEnum2->Current); - Console::WriteLine( myField ); - } - - try - { - Console::WriteLine( "The HashCode of the System::Windows::Forms::Button type is: {0}", System::Windows::Forms::Button::typeid->GetHashCode() ); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "An exception occurred." ); - Console::WriteLine( "Message: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "An exception occurred." ); - Console::WriteLine( "Message: {0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetInterface/CPP/type_getinterface.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetInterface/CPP/type_getinterface.cpp deleted file mode 100644 index 6bd012509e3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetInterface/CPP/type_getinterface.cpp +++ /dev/null @@ -1,52 +0,0 @@ - -/* -System::Type::GetInterface(String) -System::Type::GetInterface(String, bool) -System::Type::GetInterfaceMap - -The following program get the type of Hashtable class and searches for the interface -with the specified name. Then prints the method name of that interface. -*/ -using namespace System; -using namespace System::Reflection; -using namespace System::Collections; - -// -// -// -int main() -{ - Hashtable^ hashtableObj = gcnew Hashtable; - Type^ objType = hashtableObj->GetType(); - array^arrayMemberInfo; - array^arrayMethodInfo; - try - { - // Get the methods implemented in 'IDeserializationCallback' interface. - arrayMethodInfo = objType->GetInterface( "IDeserializationCallback" )->GetMethods(); - Console::WriteLine( "\nMethods of 'IDeserializationCallback' Interface :" ); - for ( int index = 0; index < arrayMethodInfo->Length; index++ ) - Console::WriteLine( arrayMethodInfo[ index ] ); - - // Get FullName for interface by using Ignore case search. - Console::WriteLine( "\nMethods of 'IEnumerable' Interface" ); - arrayMethodInfo = objType->GetInterface( "ienumerable", true )->GetMethods(); - for ( int index = 0; index < arrayMethodInfo->Length; index++ ) - Console::WriteLine( arrayMethodInfo[ index ] ); - - //Get the Interface methods for 'IDictionary*' interface - InterfaceMapping interfaceMappingObj; - interfaceMappingObj = objType->GetInterfaceMap( IDictionary::typeid ); - arrayMemberInfo = interfaceMappingObj.InterfaceMethods; - Console::WriteLine( "\nHashtable class Implements the following IDictionary Interface methods :" ); - for ( int index = 0; index < arrayMemberInfo->Length; index++ ) - Console::WriteLine( arrayMemberInfo[ index ] ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e ); - } -} -// -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetInterfaces1/CPP/type_getinterfaces1.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetInterfaces1/CPP/type_getinterfaces1.cpp deleted file mode 100644 index d6ba8989b72..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetInterfaces1/CPP/type_getinterfaces1.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// -using namespace System; -using namespace System::Collections::Generic; - -void main() -{ - Console::WriteLine("\r\nInterfaces implemented by Dictionary:\r\n"); - - for each (Type^ tinterface in Dictionary::typeid->GetInterfaces()) - { - Console::WriteLine(tinterface->ToString()); - } - - //Console::ReadLine() // Uncomment this line for Visual Studio. -} - -/* This example produces output similar to the following: - -Interfaces implemented by Dictionary: - -System.Collections.Generic.IDictionary`2[System.Int32,System.String] -System.Collections.Generic.ICollection`1[System.Collections.Generic.KeyValuePair`2[System.Int32,System.String]] -System.Collections.Generic.IEnumerable`1[System.Collections.Generic.KeyValuePair`2[System.Int32,System.String]] -System.Collection.IEnumerable -System.Collection.IDictionary -System.Collection.ICollection -System.Runtime.Serialization.ISerializable -System.Runtime.Serialization.IDeserializationCallback - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetMember/CPP/type_getmember.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetMember/CPP/type_getmember.cpp deleted file mode 100644 index 509f20ff956..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetMember/CPP/type_getmember.cpp +++ /dev/null @@ -1,100 +0,0 @@ - -// -using namespace System; -using namespace System::Security; -using namespace System::Reflection; - -// forward declarations: -void GetMemberInfo(); -void GetPublicStaticMemberInfo(); -void GetPublicInstanceMethodMemberInfo(); -int main() -{ - try - { - GetMemberInfo(); - GetPublicStaticMemberInfo(); - GetPublicInstanceMethodMemberInfo(); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNullException occurred." ); - Console::WriteLine( "Source: {0}", e->Source ); - Console::WriteLine( "Message: {0}", e->Message ); - } - catch ( NotSupportedException^ e ) - { - Console::WriteLine( "NotSupportedException occurred." ); - Console::WriteLine( "Source: {0}", e->Source ); - Console::WriteLine( "Message: {0}", e->Message ); - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException occurred." ); - Console::WriteLine( "Source: {0}", e->Source ); - Console::WriteLine( "Message: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception occurred." ); - Console::WriteLine( "Source: {0}", e->Source ); - Console::WriteLine( "Message: {0}", e->Message ); - } - -} - -void GetMemberInfo() -{ - String^ myString = "GetMember_String"; - Type^ myType = myString->GetType(); - - // Get the members for myString starting with the letter C. - array^myMembers = myType->GetMember( "C*" ); - if ( myMembers->Length > 0 ) - { - Console::WriteLine( "\nThe member(s) starting with the letter C for type {0}:", myType ); - for ( int index = 0; index < myMembers->Length; index++ ) - Console::WriteLine( "Member {0}: {1}", index + 1, myMembers[ index ] ); - } - else - Console::WriteLine( "No members match the search criteria." ); -} -// - -// -void GetPublicStaticMemberInfo() -{ - String^ myString = "GetMember_String_BindingFlag"; - Type^ myType = myString->GetType(); - - // Get the public static members for the class myString starting with the letter C - array^myMembers = myType->GetMember( "C*", static_cast(BindingFlags::Public | BindingFlags::Static) ); - if ( myMembers->Length > 0 ) - { - Console::WriteLine( "\nThe public static member(s) starting with the letter C for type {0}:", myType ); - for ( int index = 0; index < myMembers->Length; index++ ) - Console::WriteLine( "Member {0}: {1}", index + 1, myMembers[ index ] ); - } - else - Console::WriteLine( "No members match the search criteria." ); -} -// - -// -void GetPublicInstanceMethodMemberInfo() -{ - String^ myString = "GetMember_String_MemberType_BindingFlag"; - Type^ myType = myString->GetType(); - - // Get the public instance methods for myString starting with the letter C. - array^myMembers = myType->GetMember( "C*", MemberTypes::Method, static_cast(BindingFlags::Public | BindingFlags::Instance) ); - if ( myMembers->Length > 0 ) - { - Console::WriteLine( "\nThe public instance method(s) starting with the letter C for type {0}:", myType ); - for ( int index = 0; index < myMembers->Length; index++ ) - Console::WriteLine( "Member {0}: {1}", index + 1, myMembers[ index ] ); - } - else - Console::WriteLine( "No members match the search criteria." ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetMembers1/CPP/type_getmembers1.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetMembers1/CPP/type_getmembers1.cpp deleted file mode 100644 index f80aa9bb4c3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetMembers1/CPP/type_getmembers1.cpp +++ /dev/null @@ -1,52 +0,0 @@ - -// System::Type::GetMembers() -/* -This program demonstrates GetMembers() method of System::Type Class. -Get the members (properties, methods, fields, events, and so on) -of the class 'MyClass' and displays the same to the console. -*/ -using namespace System; -using namespace System::Reflection; -using namespace System::Security; - -// -ref class MyClass -{ -public: - int myInt; - String^ myString; - MyClass(){} - - void Myfunction(){} - -}; - -int main() -{ - try - { - MyClass^ myObject = gcnew MyClass; - array^myMemberInfo; - - // Get the type of 'MyClass'. - Type^ myType = myObject->GetType(); - - // Get the information related to all public members of 'MyClass'. - myMemberInfo = myType->GetMembers(); - Console::WriteLine( "\nThe members of class '{0}' are :\n", myType ); - for ( int i = 0; i < myMemberInfo->Length; i++ ) - { - - // Display name and type of the concerned member. - Console::WriteLine( "'{0}' is a {1}", myMemberInfo[ i ]->Name, myMemberInfo[ i ]->MemberType ); - - } - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetMembers2/CPP/type_getmembers2.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetMembers2/CPP/type_getmembers2.cpp deleted file mode 100644 index 41bb6aea10f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetMembers2/CPP/type_getmembers2.cpp +++ /dev/null @@ -1,66 +0,0 @@ - -// System::Type::GetMembers(BindingFlags) -/* -This program demonstrates 'GetMembers(BindingFlags)' method of -System::Type Class. This will get all the public instance members -declared or inherited by this type and displays the members to -the console. -*/ -using namespace System; -using namespace System::Reflection; -using namespace System::Security; - -// -ref class MyClass -{ -public: - int * myInt; - String^ myString; - MyClass(){} - - void Myfunction(){} - -}; - -int main() -{ - try - { - MyClass^ MyObject = gcnew MyClass; - array^myMemberInfo; - - // Get the type of the class 'MyClass'. - Type^ myType = MyObject->GetType(); - - // Get the public instance members of the class 'MyClass'. - myMemberInfo = myType->GetMembers( static_cast(BindingFlags::Public | BindingFlags::Instance) ); - Console::WriteLine( "\nThe public instance members of class '{0}' are : \n", myType ); - for ( int i = 0; i < myMemberInfo->Length; i++ ) - { - - // Display name and type of the member of 'MyClass'. - Console::WriteLine( "'{0}' is a {1}", myMemberInfo[ i ]->Name, myMemberInfo[ i ]->MemberType ); - - } - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException : {0}", e->Message ); - } - - - //Output: - //The public instance members of class 'MyClass' are : - - //'Myfunction' is a Method - //'ToString' is a Method - //'Equals' is a Method - //'GetHashCode' is a Method - //'GetType' is a Method - //'.ctor' is a Constructor - //'myInt' is a Field - //'myString' is a Field - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetMethod1/CPP/type_getmethod1.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetMethod1/CPP/type_getmethod1.cpp deleted file mode 100644 index baf1615c7c0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetMethod1/CPP/type_getmethod1.cpp +++ /dev/null @@ -1,24 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -public ref class Program -{ - - public: - - // Method to get: - void MethodA() { } - - }; - - int main() - { - - // Get MethodA() - MethodInfo^ mInfo = Program::typeid->GetMethod("MethodA"); - Console::WriteLine("Found method: {0}", mInfo ); - - } -// - diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetMethod2/CPP/type_getmethod2.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetMethod2/CPP/type_getmethod2.cpp deleted file mode 100644 index b4f0669dc23..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetMethod2/CPP/type_getmethod2.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -public ref class Program -{ - - public: - - // Method to get: - void MethodA() { } - - }; - - int main() - { - - // Get MethodA() - MethodInfo^ mInfo = Program::typeid->GetMethod("MethodA", - static_cast(BindingFlags::Public | BindingFlags::Instance)); - Console::WriteLine("Found method: {0}", mInfo ); - - } -// - diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetMethod3/CPP/type_getmethod3.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetMethod3/CPP/type_getmethod3.cpp deleted file mode 100644 index 635d6dcd96c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetMethod3/CPP/type_getmethod3.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -public ref class Program -{ - -public: - // Methods to get: - - void MethodA(int i, int j) { } - - void MethodA(array^ iarry) { } - - void MethodA(double *ip) { } - - // Method that takes a managed reference paramter. - void MethodA(int% r) {} -}; - -int main() -{ - MethodInfo^ mInfo; - - - // Get MethodA(int i, int j) - mInfo = Program::typeid->GetMethod("MethodA", - BindingFlags::Public | BindingFlags::Instance, - nullptr, - CallingConventions::Any, - gcnew array {int::typeid, int::typeid}, - nullptr); - Console::WriteLine("Found method: {0}", mInfo ); - - // Get MethodA(array^ iarry) - mInfo = Program::typeid->GetMethod("MethodA", - BindingFlags::Public | BindingFlags::Instance, - nullptr, - CallingConventions::Any, - gcnew array {int::typeid->MakeArrayType()}, - nullptr); - Console::WriteLine("Found method: {0}", mInfo ); - - // Get MethodA(double *ip) - mInfo = Program::typeid->GetMethod("MethodA", - BindingFlags::Public | BindingFlags::Instance, - nullptr, - CallingConventions::Any, - gcnew array {double::typeid->MakePointerType()}, - nullptr); - Console::WriteLine("Found method: {0}", mInfo ); - - // Get MethodA(int% r) - mInfo = Program::typeid->GetMethod("MethodA", - BindingFlags::Public | BindingFlags::Instance, - nullptr, - CallingConventions::Any, - gcnew array {int::typeid->MakeByRefType()}, - nullptr); - Console::WriteLine("Found method: {0}", mInfo ); - -} -// - diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetMethod4/CPP/type_getmethod4.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetMethod4/CPP/type_getmethod4.cpp deleted file mode 100644 index 5e67e5d4695..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetMethod4/CPP/type_getmethod4.cpp +++ /dev/null @@ -1,47 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -public ref class Program -{ - -public: - // Methods to get: - - void MethodA(int i, int j) { } - - void MethodA(array^ iarry) { } - - void MethodA(double *ip) { } - - // Method that takes a managed reference parameter. - void MethodA(int% r) {} -}; - -int main() -{ - MethodInfo^ mInfo; - - - // Get MethodA(int i, int j) - mInfo = Program::typeid->GetMethod("MethodA", gcnew array {int::typeid,int::typeid}); - Console::WriteLine("Found method: {0}", mInfo ); - - // Get MethodA(array^ iarry) - mInfo = Program::typeid->GetMethod("MethodA", gcnew array {int::typeid->MakeArrayType()}); - Console::WriteLine("Found method: {0}", mInfo ); - - // Get MethodA(double *ip) - mInfo = Program::typeid->GetMethod("MethodA", gcnew array {double::typeid->MakePointerType()}); - Console::WriteLine("Found method: {0}", mInfo ); - - // Get MethodA(int% r) - mInfo = Program::typeid->GetMethod("MethodA", gcnew array {int::typeid->MakeByRefType()}); - // Display the method information. - Console::WriteLine("Found method: {0}", mInfo ); - -} -// - - diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetMethod5/CPP/type_getmethod5.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetMethod5/CPP/type_getmethod5.cpp deleted file mode 100644 index 8fb1d143de6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetMethod5/CPP/type_getmethod5.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -public ref class Program -{ - -public: - // Methods to get: - - void MethodA(int i, int j) { } - - void MethodA(array^ iarry) { } - - void MethodA(double *ip) { } - - // Method that takes a managed reference parameter. - void MethodA(int% r) {} -}; - -int main() -{ - MethodInfo^ mInfo; - - - // Get MethodA(int i, int j) - mInfo = Program::typeid->GetMethod("MethodA", - static_cast(BindingFlags::Public | BindingFlags::Instance), - nullptr, - gcnew array {int::typeid, int::typeid}, - nullptr); - Console::WriteLine("Found method: {0}", mInfo ); - - // Get MethodA(array^ iarry) - mInfo = Program::typeid->GetMethod("MethodA", - static_cast(BindingFlags::Public | BindingFlags::Instance), - nullptr, - gcnew array {int::typeid->MakeArrayType()}, - nullptr); - Console::WriteLine("Found method: {0}", mInfo ); - - // Get MethodA(double *ip) - mInfo = Program::typeid->GetMethod("MethodA", - static_cast(BindingFlags::Public | BindingFlags::Instance), - nullptr, - gcnew array {double::typeid->MakePointerType()}, - nullptr); - Console::WriteLine("Found method: {0}", mInfo ); - - // Get MethodA(int% r) - mInfo = Program::typeid->GetMethod("MethodA", - static_cast(BindingFlags::Public | BindingFlags::Instance), - nullptr, - gcnew array {int::typeid->MakeByRefType()}, - nullptr); - Console::WriteLine("Found method: {0}", mInfo ); -} -// - diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetMethods2/CPP/type_getmethods2.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetMethods2/CPP/type_getmethods2.cpp deleted file mode 100644 index c249289de27..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetMethods2/CPP/type_getmethods2.cpp +++ /dev/null @@ -1,54 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -using namespace System::Reflection::Emit; - -// Create a class having two public methods and one protected method. -public ref class MyTypeClass -{ -public: - void MyMethods(){} - - int MyMethods1() - { - return 3; - } - - -protected: - String^ MyMethods2() - { - return "hello"; - } -}; - -void DisplayMethodInfo( array^myArrayMethodInfo ) -{ - // Display information for all methods. - for ( int i = 0; i < myArrayMethodInfo->Length; i++ ) - { - MethodInfo^ myMethodInfo = dynamic_cast(myArrayMethodInfo[ i ]); - Console::WriteLine( "\nThe name of the method is {0}.", myMethodInfo->Name ); - } -} - -int main() -{ - Type^ myType = MyTypeClass::typeid; - - // Get the public methods. - array^myArrayMethodInfo = myType->GetMethods( static_cast(BindingFlags::Public | BindingFlags::Instance | BindingFlags::DeclaredOnly) ); - Console::WriteLine( "\nThe number of public methods is {0}->", myArrayMethodInfo->Length ); - - // Display all the methods. - DisplayMethodInfo( myArrayMethodInfo ); - - // Get the nonpublic methods. - array^myArrayMethodInfo1 = myType->GetMethods( static_cast(BindingFlags::NonPublic | BindingFlags::Instance | BindingFlags::DeclaredOnly) ); - Console::WriteLine( "\nThe number of protected methods is {0}->", myArrayMethodInfo1->Length ); - - // Display information for all methods. - DisplayMethodInfo( myArrayMethodInfo1 ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetNestedClassesAbs/CPP/type_getnestedclassesabs.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetNestedClassesAbs/CPP/type_getnestedclassesabs.cpp deleted file mode 100644 index 8c37fe7a44c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetNestedClassesAbs/CPP/type_getnestedclassesabs.cpp +++ /dev/null @@ -1,56 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -// Create a class with two nested public classes and two nested protected classes. -public ref class MyTypeClass -{ - public: - ref class Myclass1{}; - - public: - ref class Myclass2{}; - - protected: - ref class MyClass3{}; - - protected: - ref class MyClass4{}; -}; - -void DisplayTypeInfo(array^ myArrayType) -{ - // Display the information for all the nested classes. - for each (Type^ t in myArrayType) - Console::WriteLine( "The name of the nested class is {0}.", t->FullName); -} - -int main() -{ - Type^ myType = MyTypeClass::typeid; - - // Get the public nested classes. - array^myTypeArray = myType->GetNestedTypes( static_cast(BindingFlags::Public)); - Console::WriteLine( "The number of nested public classes is {0}.", myTypeArray->Length ); - - // Display all the public nested classes. - DisplayTypeInfo( myTypeArray ); - Console::WriteLine(); - - // Get the nonpublic nested classes. - array^myTypeArray1 = myType->GetNestedTypes( static_cast(BindingFlags::NonPublic)); - Console::WriteLine( "The number of nested protected classes is {0}.", myTypeArray1->Length ); - - // Display all the nonpublic nested classes. - DisplayTypeInfo( myTypeArray1 ); -} -// The example displays the following output: -// The number of public nested classes is 2. -// The name of the nested class is MyTypeClass+Myclass1. -// The name of the nested class is MyTypeClass+Myclass2. -// -// The number of protected nested classes is 2. -// The name of the nested class is MyTypeClass+MyClass3. -// The name of the nested class is MyTypeClass+MyClass4. -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetNestedTypes/CPP/type_getnestedtypes.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetNestedTypes/CPP/type_getnestedtypes.cpp deleted file mode 100644 index 53d43153bd8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetNestedTypes/CPP/type_getnestedtypes.cpp +++ /dev/null @@ -1,43 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -public ref class MyClass -{ -public: - ref class NestClass - { - public: - static int myPublicInt = 0; - }; - - ref struct NestStruct - { - public: - static int myPublicInt = 0; - }; -}; - -int main() -{ - try - { - // Get the Type object corresponding to MyClass. - Type^ myType = MyClass::typeid; - - // Get an array of nested type objects in MyClass. - array^nestType = myType->GetNestedTypes(); - Console::WriteLine( "The number of nested types is {0}.", nestType->Length ); - System::Collections::IEnumerator^ myEnum = nestType->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Type^ t = safe_cast(myEnum->Current); - Console::WriteLine( "Nested type is {0}.", t ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Error {0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetProperties2/CPP/type_getproperties2.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetProperties2/CPP/type_getproperties2.cpp deleted file mode 100644 index 9be794b12cf..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetProperties2/CPP/type_getproperties2.cpp +++ /dev/null @@ -1,153 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -// Create a class having three properties. -public ref class PropertyClass -{ - -public: - property String^ Property1 - { - String^ get() - { - return "hello"; - } - } - - property String^ Property2 - { - String^ get() - { - return "hello"; - } - } - -protected: - property String^ Property3 - { - String^ get() - { - return "hello"; - } - } - -private: - property int Property4 - { - int get() - { - return 32; - } - } - -internal: - property String^ Property5 - { - String^ get() - { - return "value"; - } - } - -public protected: - property String^ Property6 - { - String^ get() - { - return "value"; - } - } -}; - -String^ GetVisibility(MethodInfo^ accessor) -{ - if (accessor->IsPublic) - return "Public"; - else if (accessor->IsPrivate) - return "Private"; - else if (accessor->IsFamily) - return "Protected"; - else if (accessor->IsAssembly) - return "Internal/Friend"; - else - return "Protected Internal/Friend"; -} - -void DisplayPropertyInfo(array^ propInfos ) -{ - // Display information for all properties. - for each(PropertyInfo^ propInfo in propInfos) { - bool readable = propInfo->CanRead; - bool writable = propInfo->CanWrite; - - Console::WriteLine(" Property name: {0}", propInfo->Name); - Console::WriteLine(" Property type: {0}", propInfo->PropertyType); - Console::WriteLine(" Read-Write: {0}", readable && writable); - if (readable) { - MethodInfo^ getAccessor = propInfo->GetMethod; - Console::WriteLine(" Visibility: {0}", - GetVisibility(getAccessor)); - } - if (writable) { - MethodInfo^ setAccessor = propInfo->SetMethod; - Console::WriteLine(" Visibility: {0}", - GetVisibility(setAccessor)); - } - Console::WriteLine(); - } -} - -void main() -{ - Type^ myType = PropertyClass::typeid; - - // Get the public properties. - array^propInfos = myType->GetProperties( static_cast(BindingFlags::Public | BindingFlags::Instance) ); - Console::WriteLine("The number of public properties: {0}.\n", - propInfos->Length); - // Display the public properties. - DisplayPropertyInfo( propInfos ); - - // Get the non-public properties. - array^propInfos1 = myType->GetProperties( static_cast(BindingFlags::NonPublic | BindingFlags::Instance) ); - Console::WriteLine("The number of non-public properties: {0}.\n", - propInfos1->Length); - // Display all the non-public properties. - DisplayPropertyInfo(propInfos1); -} -// The example displays the following output: -// The number of public properties: 2. -// -// Property name: Property2 -// Property type: System.String -// Read-Write: False -// Visibility: Public -// -// Property name: Property1 -// Property type: System.String -// Read-Write: False -// Visibility: Public -// -// The number of non-public properties: 4. -// -// Property name: Property6 -// Property type: System.String -// Read-Write: False -// Visibility: Protected Internal/Friend -// -// Property name: Property5 -// Property type: System.String -// Read-Write: False -// Visibility: Internal/Friend -// -// Property name: Property4 -// Property type: System.Int32 -// Read-Write: False -// Visibility: Private -// -// Property name: Property3 -// Property type: System.String -// Read-Write: False -// Visibility: Protected -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetProperty1/CPP/type_getproperty1.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetProperty1/CPP/type_getproperty1.cpp deleted file mode 100644 index 8ae8ea145d3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetProperty1/CPP/type_getproperty1.cpp +++ /dev/null @@ -1,45 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -ref class MyClass -{ -private: - int myProperty; - -public: - - property int MyProperty - { - // Declare MyProperty. - int get() - { - return myProperty; - } - - void set( int value ) - { - myProperty = value; - } - } -}; - -int main() -{ - try - { - // Get the Type object corresponding to MyClass. - Type^ myType = MyClass::typeid; - - // Get the PropertyInfo object by passing the property name. - PropertyInfo^ myPropInfo = myType->GetProperty( "MyProperty" ); - - // Display the property name. - Console::WriteLine( "The {0} property exists in MyClass.", myPropInfo->Name ); - } - catch ( NullReferenceException^ e ) - { - Console::WriteLine( "The property does not exist in MyClass. {0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetProperty2/CPP/type_getproperty2.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetProperty2/CPP/type_getproperty2.cpp deleted file mode 100644 index 9301970d3b4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetProperty2/CPP/type_getproperty2.cpp +++ /dev/null @@ -1,45 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -ref class MyClass -{ -private: - int myProperty; - -public: - - property int MyProperty - { - // Declare MyProperty. - int get() - { - return myProperty; - } - - void set( int value ) - { - myProperty = value; - } - } -}; - -int main() -{ - try - { - // Get Type object of MyClass. - Type^ myType = MyClass::typeid; - - // Get the PropertyInfo by passing the property name and specifying the BindingFlags. - PropertyInfo^ myPropInfo = myType->GetProperty( "MyProperty", static_cast(BindingFlags::Public | BindingFlags::Instance) ); - - // Display Name property to console. - Console::WriteLine( "{0} is a property of MyClass.", myPropInfo->Name ); - } - catch ( NullReferenceException^ e ) - { - Console::WriteLine( "MyProperty does not exist in MyClass. {0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetProperty3/CPP/type_getproperty3.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetProperty3/CPP/type_getproperty3.cpp deleted file mode 100644 index 8b7ac89dba4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetProperty3/CPP/type_getproperty3.cpp +++ /dev/null @@ -1,58 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -ref class MyClass1 -{ -private: - array^myArray; - -public: - - property int Item [int, int] - { - - // Declare an indexer. - int get( int i, int j ) - { - return myArray[ i,j ]; - } - - void set( int i, int j, int value ) - { - myArray[ i,j ] = value; - } - - } - -}; - -int main() -{ - try - { - - // Get the Type object. - Type^ myType = MyClass1::typeid; - array^myTypeArr = gcnew array(2); - - // Create an instance of a Type array. - myTypeArr->SetValue( int::typeid, 0 ); - myTypeArr->SetValue( int::typeid, 1 ); - - // Get the PropertyInfo object for the indexed property Item, which has two integer parameters. - PropertyInfo^ myPropInfo = myType->GetProperty( "Item", myTypeArr ); - - // Display the property. - Console::WriteLine( "The {0} property exists in MyClass1.", myPropInfo ); - } - catch ( NullReferenceException^ e ) - { - Console::WriteLine( "An exception occurred." ); - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetProperty5/CPP/type_getproperty2.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetProperty5/CPP/type_getproperty2.cpp deleted file mode 100644 index 905e696e9f8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetProperty5/CPP/type_getproperty2.cpp +++ /dev/null @@ -1,53 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -public ref class MyPropertyClass -{ -private: - array^ myPropertyArray; - -public: - - property int Item [int, int] - { - // Declare an indexer. - int get( int i, int j ) - { - return myPropertyArray[ i,j ]; - } - - void set( int i, int j, int value ) - { - myPropertyArray[ i,j ] = value; - } - - } - -}; - -int main() -{ - try - { - Type^ myType = MyPropertyClass::typeid; - array^myTypeArray = gcnew array(2); - - // Create an instance of the Type array representing the number, order - // and type of the parameters for the property. - myTypeArray->SetValue( int::typeid, 0 ); - myTypeArray->SetValue( int::typeid, 1 ); - - // Search for the indexed property whose parameters match the - // specified argument types and modifiers. - PropertyInfo^ myPropertyInfo = myType->GetProperty( "Item", int::typeid, myTypeArray, nullptr ); - Console::WriteLine( "{0}.{1} has a property type of {2}", myType->FullName, myPropertyInfo->Name, myPropertyInfo->PropertyType ); - } - catch ( Exception^ ex ) - { - Console::WriteLine( "An exception occurred {0}", ex->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetProperty_Types/CPP/type_getproperty_types.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetProperty_Types/CPP/type_getproperty_types.cpp deleted file mode 100644 index 406346579d0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetProperty_Types/CPP/type_getproperty_types.cpp +++ /dev/null @@ -1,55 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -ref class MyClass1 -{ -private: - String^ myMessage; - -public: - - property String^ MyProperty1 - { - String^ get() - { - return myMessage; - } - - void set( String^ value ) - { - myMessage = value; - } - } -}; - -int main() -{ - try - { - Type^ myType = MyClass1::typeid; - - // Get the PropertyInfo Object* representing MyProperty1. - PropertyInfo^ myStringProperties1 = myType->GetProperty( "MyProperty1", String::typeid ); - Console::WriteLine( "The name of the first property of MyClass1 is {0}.", myStringProperties1->Name ); - Console::WriteLine( "The type of the first property of MyClass1 is {0}.", myStringProperties1->PropertyType ); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNullException : {0}", e->Message ); - } - catch ( AmbiguousMatchException^ e ) - { - Console::WriteLine( "AmbiguousMatchException : {0}", e->Message ); - } - catch ( NullReferenceException^ e ) - { - Console::WriteLine( "Source : {0}", e->Source ); - Console::WriteLine( "Message : {0}", e->Message ); - } - //Output: - //The name of the first property of MyClass1 is MyProperty1. - //The type of the first property of MyClass1 is System.String. - -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetType/CPP/type_gettype.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetType/CPP/type_gettype.cpp deleted file mode 100644 index eb10775df99..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetType/CPP/type_gettype.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -// -using namespace System; - -int main() -{ - try { - // Get the type of a specified class. - Type^ myType1 = Type::GetType( "System.Int32" ); - Console::WriteLine( "The full name is {0}.\n", myType1->FullName ); - } - catch ( TypeLoadException^ e ) { - Console::WriteLine("{0}: Unable to load type System.Int32", - e->GetType()->Name); - } - - try { - // Since NoneSuch does not exist in this assembly, GetType throws a TypeLoadException. - Type^ myType2 = Type::GetType( "NoneSuch", true ); - Console::WriteLine( "The full name is {0}.", myType2->FullName ); - } - catch ( TypeLoadException^ e ) { - Console::WriteLine("{0}: Unable to load type NoneSuch", - e->GetType()->Name); - } - -} -// The example displays the following output: -// The full name is System.Int32. -// -// TypeLoadException: Unable to load type NoneSuch -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetTypeCode/CPP/type_gettypecode.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetTypeCode/CPP/type_gettypecode.cpp deleted file mode 100644 index 4eedf13f6b4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetTypeCode/CPP/type_gettypecode.cpp +++ /dev/null @@ -1,72 +0,0 @@ - -// System::Type::GetTypeCode() -// System::Type::GetProperties() -// System::Type::GetTypeArray() -// System::Type::GetType(String, Boolean, Boolean) -/* The following example demonstrates the 'GetTypeCode()', 'GetProperties()', 'GetTypeArray()', -'GetType(String, Boolean, Boolean)' methods of 'Type' class. -An object of 'Type' corresponding to 'System::Int32 is obtained '. Properties of 'System::Type' -is retrieved into 'PropertyInfo' array and displayed. Array of 'Type' objects is created -which represents the type specified by an arbitary set of objects. When 'Type' object is -attempted to create for 'sYSTem.iNT32', an exception is thrown when case-sensitive search -is done. -*/ -using namespace System; -using namespace System::Reflection; -int main() -{ - // - // Create an object of 'Type' class. - Type^ myType1 = Type::GetType( "System.Int32" ); - - // Get the 'TypeCode' of the 'Type' class object created above. - TypeCode myTypeCode = Type::GetTypeCode( myType1 ); - Console::WriteLine( "TypeCode is: {0}", myTypeCode ); - // - - // - array^myPropertyInfo; - - // Get the properties of 'Type' class object. - myPropertyInfo = Type::GetType( "System.Type" )->GetProperties(); - Console::WriteLine( "Properties of System.Type are:" ); - for ( int i = 0; i < myPropertyInfo->Length; i++ ) - { - Console::WriteLine( myPropertyInfo[ i ] ); - - } - // - - // - array^myObject = gcnew array(3); - myObject[ 0 ] = 66; - myObject[ 1 ] = "puri"; - myObject[ 2 ] = 33.33; - - // Get the array of 'Type' class objects. - array^myTypeArray = Type::GetTypeArray( myObject ); - Console::WriteLine( "Full names of the 'Type' objects in the array are:" ); - for ( int h = 0; h < myTypeArray->Length; h++ ) - { - Console::WriteLine( myTypeArray[ h ]->FullName ); - - } - // - - // - try - { - // Throws 'TypeLoadException' because of case-sensitive search. - Type^ myType2 = Type::GetType( "sYSTem.iNT32", true, false ); - Console::WriteLine( myType2->FullName ); - } - catch ( TypeLoadException^ e ) - { - Console::WriteLine( e->Message ); - } - // - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } -} diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetTypeFromHandle/CPP/type_gettypefromhandle.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetTypeFromHandle/CPP/type_gettypefromhandle.cpp deleted file mode 100644 index 3bdbda50535..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetTypeFromHandle/CPP/type_gettypefromhandle.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// System::Type::GetTypeFromHandle(RuntimeTypeHandle) - -/* -The following example demonstrates the 'GetTypeFromHandle(RuntimeTypeHandle)' method -of the 'Type' Class. -It defines an empty class 'Myclass1' and obtains an object of 'Myclass1'. Then the runtime handle of -the object is obtained and passed as an argument to 'GetTypeFromHandle(RuntimeTypeHandle)'method. That -returns the type referenced by the specified type handle. -*/ - -using namespace System; -using namespace System::Reflection; -public ref class MyClass1{}; - -int main() -{ - // - MyClass1^ myClass1 = gcnew MyClass1; - // Get the type referenced by the specified type handle. - Type^ myClass1Type = Type::GetTypeFromHandle( Type::GetTypeHandle( myClass1 ) ); - Console::WriteLine( "The Names of the Attributes : {0}", myClass1Type->Attributes ); - // -} diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetTypeFromProgID2/CPP/type_gettypefromprogid2.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetTypeFromProgID2/CPP/type_gettypefromprogid2.cpp deleted file mode 100644 index f5e69fb913a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetTypeFromProgID2/CPP/type_gettypefromprogid2.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -// -using namespace System; -int main() -{ - try - { - - // Use the ProgID HKEY_CLASSES_ROOT\DirControl.DirList.1. - String^ myString1 = "DIRECT.ddPalette.3"; - - // Use a nonexistent ProgID WrongProgID. - String^ myString2 = "WrongProgID"; - - // Make a call to the method to get the type information of the given ProgID. - Type^ myType1 = Type::GetTypeFromProgID( myString1, true ); - Console::WriteLine( "GUID for ProgID DirControl.DirList.1 is {0}.", myType1->GUID ); - - // Throw an exception because the ProgID is invalid and the throwOnError - // parameter is set to True. - Type^ myType2 = Type::GetTypeFromProgID( myString2, true ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "An exception occurred." ); - Console::WriteLine( "Source: {0}", e->Source ); - Console::WriteLine( "Message: {0}", e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetTypeFromProgID3/CPP/Type_GetTypeFromProgID3.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetTypeFromProgID3/CPP/Type_GetTypeFromProgID3.cpp deleted file mode 100644 index 1e6853e4688..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetTypeFromProgID3/CPP/Type_GetTypeFromProgID3.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -// -using namespace System; -int main() -{ - try - { - - // Use the ProgID localhost\HKEY_CLASSES_ROOT\DirControl::DirList.1. - String^ theProgramID = "DirControl.DirList.1"; - - // Use the server name localhost. - String^ theServer = "localhost"; - - // Make a call to the method to get the type information for the given ProgID. - Type^ myType = Type::GetTypeFromProgID( theProgramID, theServer ); - if ( myType == nullptr ) - { - throw gcnew Exception( "Invalid ProgID or Server." ); - } - Console::WriteLine( "GUID for ProgID DirControl.DirList.1 is {0}.", myType->GUID ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "An exception occurred." ); - Console::WriteLine( "Source: {0}", e->Source ); - Console::WriteLine( "Message: {0}", e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetTypeFromProgID4/CPP/Type_GetTypeFromProgID4.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetTypeFromProgID4/CPP/Type_GetTypeFromProgID4.cpp deleted file mode 100644 index 706229d1e8d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetTypeFromProgID4/CPP/Type_GetTypeFromProgID4.cpp +++ /dev/null @@ -1,35 +0,0 @@ - -// -using namespace System; -int main() -{ - try - { - - // Use server localhost. - String^ theServer = "localhost"; - - // Use ProgID HKEY_CLASSES_ROOT\DirControl.DirList.1. - String^ myString1 = "DirControl.DirList.1"; - - // Use a wrong ProgID WrongProgID. - String^ myString2 = "WrongProgID"; - - // Make a call to the method to get the type information for the given ProgID. - Type^ myType1 = Type::GetTypeFromProgID( myString1, theServer, true ); - Console::WriteLine( "GUID for ProgID DirControl.DirList.1 is {0}.", myType1->GUID ); - - // Throw an exception because the ProgID is invalid and the throwOnError - // parameter is set to True. - Type^ myType2 = Type::GetTypeFromProgID( myString2, theServer, true ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "An exception occurred. The ProgID is wrong." ); - Console::WriteLine( "Source: {0}", e->Source ); - Console::WriteLine( "Message: {0}", e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_GetTypeHandle/CPP/Type_GetTypeHandle.cpp b/snippets/cpp/VS_Snippets_CLR/Type_GetTypeHandle/CPP/Type_GetTypeHandle.cpp deleted file mode 100644 index fe262565879..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_GetTypeHandle/CPP/Type_GetTypeHandle.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -public ref class MyClass1 -{ -private: - int x; - -public: - int MyMethod() - { - return x; - } -}; - -int main() -{ - MyClass1^ myClass1 = gcnew MyClass1; - - // Get the RuntimeTypeHandle from an object. - RuntimeTypeHandle myRTHFromObject = Type::GetTypeHandle( myClass1 ); - - // Get the RuntimeTypeHandle from a type. - RuntimeTypeHandle myRTHFromType = MyClass1::typeid->TypeHandle; - - Console::WriteLine( "\nmyRTHFromObject.Value: {0}", myRTHFromObject.Value ); - Console::WriteLine( "myRTHFromObject.GetType(): {0}", myRTHFromObject.GetType() ); - Console::WriteLine( "Get the type back from the handle..." ); - Console::WriteLine( "Type::GetTypeFromHandle(myRTHFromObject): {0}", - Type::GetTypeFromHandle(myRTHFromObject) ); - - Console::WriteLine( "\nmyRTHFromObject.Equals(myRTHFromType): {0}", - myRTHFromObject.Equals(myRTHFromType) ); - - Console::WriteLine( "\nmyRTHFromType.Value: {0}", myRTHFromType.Value ); - Console::WriteLine( "myRTHFromType.GetType(): {0}", myRTHFromType.GetType() ); - Console::WriteLine( "Get the type back from the handle..." ); - Console::WriteLine( "Type::GetTypeFromHandle(myRTHFromType): {0}", - Type::GetTypeFromHandle(myRTHFromType) ); -} - -/* This code example produces output similar to the following: - -myRTHFromObject.Value: 3295832 -myRTHFromObject.GetType(): System.RuntimeTypeHandle -Get the type back from the handle... -Type::GetTypeFromHandle(myRTHFromObject): MyClass1 - -myRTHFromObject.Equals(myRTHFromType): True - -myRTHFromType.Value: 3295832 -myRTHFromType.GetType(): System.RuntimeTypeHandle -Get the type back from the handle... -Type::GetTypeFromHandle(myRTHFromType): MyClass1 - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_Guid/CPP/type_guid.cpp b/snippets/cpp/VS_Snippets_CLR/Type_Guid/CPP/type_guid.cpp deleted file mode 100644 index 5f399d51673..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_Guid/CPP/type_guid.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -// -using namespace System; -ref class MyGetTypeFromCLSID -{ -public: - ref class MyClass1 - { - public: - void MyMethod1(){} - }; -}; - -int main() -{ - - // Get the type corresponding to the class MyClass. - Type^ myType = MyGetTypeFromCLSID::MyClass1::typeid; - - // Get the Object* of the Guid. - Guid myGuid = (Guid)myType->GUID; - Console::WriteLine( "The name of the class is {0}", myType ); - Console::WriteLine( "The ClassId of MyClass is {0}", myType->GUID ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_HasElementType/CPP/type_haselementtype.cpp b/snippets/cpp/VS_Snippets_CLR/Type_HasElementType/CPP/type_haselementtype.cpp deleted file mode 100644 index c11f4e80d20..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_HasElementType/CPP/type_haselementtype.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Runtime::InteropServices; - -public ref class Example -{ -public: - // This method is for demonstration purposes. It includes a - // tracking reference (C# ref, VB ByRef), an out parameter, - // and a pointer. - void Test(int% x, [OutAttribute()] int% y, int* z) - { - *z = x = y = 0; - } -}; - -int main() -{ - // All of the following display 'True'. - - // Define a managed array, get its type, and display HasElementType. - array^ examples = {gcnew Example(), gcnew Example()}; - Type^ t = examples::typeid; - Console::WriteLine(t); - Console::WriteLine("HasElementType is '{0}' for managed array types.", t->HasElementType); - - // When you use Reflection Emit to emit dynamic methods and - // assemblies, you can create array types using MakeArrayType. - // The following creates the type 'array of Example'. - t = Example::typeid->MakeArrayType(); - Console::WriteLine("HasElementType is '{0}' for managed array types.", t->HasElementType); - - // When you reflect over methods, HasElementType is true for - // ref, out, and pointer parameter types. The following - // gets the Test method, defined above, and examines its - // parameters. - MethodInfo^ mi = Example::typeid->GetMethod("Test"); - array^ parms = mi->GetParameters(); - t = parms[0]->ParameterType; - Console::WriteLine("HasElementType is '{0}' for ref parameter types.", t->HasElementType); - t = parms[1]->ParameterType; - Console::WriteLine("HasElementType is '{0}' for out parameter types.", t->HasElementType); - t = parms[2]->ParameterType; - Console::WriteLine("HasElementType is '{0}' for pointer parameter types.", t->HasElementType); - - // When you use Reflection Emit to emit dynamic methods and - // assemblies, you can create pointer and ByRef types to use - // when you define method parameters. - t = Example::typeid->MakePointerType(); - Console::WriteLine("HasElementType is '{0}' for pointer types.", t->HasElementType); - t = Example::typeid->MakeByRefType(); - Console::WriteLine("HasElementType is '{0}' for ByRef types.", t->HasElementType); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_HasElementTypeImpl/CPP/type_haselementtypeimpl.cpp b/snippets/cpp/VS_Snippets_CLR/Type_HasElementTypeImpl/CPP/type_haselementtypeimpl.cpp deleted file mode 100644 index a2a8c92e5cd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_HasElementTypeImpl/CPP/type_haselementtypeimpl.cpp +++ /dev/null @@ -1,86 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -public ref class MyTypeDelegator: public TypeDelegator -{ -public: - String^ myElementType; - -private: - Type^ myType; - -public: - MyTypeDelegator( Type^ myType ) - : TypeDelegator( myType ) - { - this->myType = myType; - } - - -protected: - - // Override Type::HasElementTypeImpl(). - virtual bool HasElementTypeImpl() override - { - - // Determine whether the type is an array. - if ( myType->IsArray ) - { - myElementType = "array"; - return true; - } - - - // Determine whether the type is a reference. - if ( myType->IsByRef ) - { - myElementType = "reference"; - return true; - } - - - // Determine whether the type is a pointer. - if ( myType->IsPointer ) - { - myElementType = "pointer"; - return true; - } - - - // Return false if the type is not a reference, array, or pointer type. - return false; - } - -}; - -int main() -{ - try - { - int myInt = 0; - array^myArray = gcnew array(5); - MyTypeDelegator^ myType = gcnew MyTypeDelegator( myArray->GetType() ); - - // Determine whether myType is an array, pointer, reference type. - Console::WriteLine( "\nDetermine whether a variable is an array, pointer, or reference type.\n" ); - if ( myType->HasElementType ) - Console::WriteLine( "The type of myArray is {0}.", myType->myElementType ); - else - Console::WriteLine( "myArray is not an array, pointer, or reference type." ); - myType = gcnew MyTypeDelegator( myInt.GetType() ); - - // Determine whether myType is an array, pointer, reference type. - if ( myType->HasElementType ) - Console::WriteLine( "The type of myInt is {0}.", myType->myElementType ); - else - Console::WriteLine( "myInt is not an array, pointer, or reference type." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_IsAnsiClass/CPP/Type_IsAnsiClass.cpp b/snippets/cpp/VS_Snippets_CLR/Type_IsAnsiClass/CPP/Type_IsAnsiClass.cpp deleted file mode 100644 index 6bdc99f8a1b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_IsAnsiClass/CPP/Type_IsAnsiClass.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -public ref class MyClass -{ -protected: - String^ myField; - -public: - MyClass() - { - myField = "A sample protected field"; - } -}; - -int main() -{ - try - { - MyClass^ myObject = gcnew MyClass; - - // Get the type of the 'MyClass'. - Type^ myType = MyClass::typeid; - - // Get the field information and the attributes associated with MyClass. - FieldInfo^ myFieldInfo = myType->GetField( "myField", static_cast(BindingFlags::NonPublic | BindingFlags::Instance) ); - Console::WriteLine( "\nChecking for the AnsiClass attribute for a field.\n" ); - - // Get and display the name, field, and the AnsiClass attribute. - Console::WriteLine( "Name of Class: {0} \nValue of Field: {1} \nIsAnsiClass = {2}", myType->FullName, myFieldInfo->GetValue( myObject ), myType->IsAnsiClass ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_IsArrayImpl/CPP/type_isarrayimpl.cpp b/snippets/cpp/VS_Snippets_CLR/Type_IsArrayImpl/CPP/type_isarrayimpl.cpp deleted file mode 100644 index dadf165d511..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_IsArrayImpl/CPP/type_isarrayimpl.cpp +++ /dev/null @@ -1,68 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -public ref class MyTypeDelegator: public TypeDelegator -{ -public: - String^ myElementType; - Type^ myType; - MyTypeDelegator( Type^ myType ) - : TypeDelegator( myType ) - { - this->myType = myType; - } - - -protected: - - // Override IsArrayImpl(). - virtual bool IsArrayImpl() override - { - - // Determine whether the type is an array. - if ( myType->IsArray ) - { - myElementType = "array"; - return true; - } - - - // Return false if the type is not an array. - return false; - } - -}; - -int main() -{ - try - { - int myInt = 0; - - // Create an instance of an array element. - array^myArray = gcnew array(5); - MyTypeDelegator^ myType = gcnew MyTypeDelegator( myArray->GetType() ); - Console::WriteLine( "\nDetermine whether the variable is an array.\n" ); - - // Determine whether myType is an array type. - if ( myType->IsArray ) - Console::WriteLine( "The type of myArray is {0}.", myType->myElementType ); - else - Console::WriteLine( "myArray is not an array." ); - myType = gcnew MyTypeDelegator( myInt.GetType() ); - - // Determine whether myType is an array type. - if ( myType->IsArray ) - Console::WriteLine( "The type of myInt is {0}.", myType->myElementType ); - else - Console::WriteLine( "myInt is not an array." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_IsAutoLayout/CPP/type_isautolayout.cpp b/snippets/cpp/VS_Snippets_CLR/Type_IsAutoLayout/CPP/type_isautolayout.cpp deleted file mode 100644 index 9c15d3604d7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_IsAutoLayout/CPP/type_isautolayout.cpp +++ /dev/null @@ -1,40 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Reflection; -using namespace System::ComponentModel; -using namespace System::Runtime::InteropServices; - -// The MyDemoAttribute class is selected as AutoLayout. - -[StructLayoutAttribute(LayoutKind::Auto)] -public ref class MyDemoAttribute{}; - -void MyAutoLayoutMethod( String^ typeName ) -{ - try - { - - // Create an instance of the Type class using the GetType method. - Type^ myType = Type::GetType( typeName ); - - // Get and display the IsAutoLayout property of the - // MyDemoAttribute instance. - Console::WriteLine( "\nThe AutoLayout property for the MyDemoAttribute is {0}.", myType->IsAutoLayout ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nAn exception occurred: {0}.", e->Message ); - } - -} - -int main() -{ - MyAutoLayoutMethod( "MyDemoAttribute" ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_IsClass/CPP/type_isclass.cpp b/snippets/cpp/VS_Snippets_CLR/Type_IsClass/CPP/type_isclass.cpp deleted file mode 100644 index 028383c4410..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_IsClass/CPP/type_isclass.cpp +++ /dev/null @@ -1,23 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -public ref class MyDemoClass{}; - -int main() -{ - try - { - Type^ myType = Type::GetType( "MyDemoClass" ); - - // Get and display the 'IsClass' property of the 'MyDemoClass' instance. - Console::WriteLine( "\nIs the specified type a class? {0}.", myType->IsClass ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nAn exception occurred: {0}.", e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_IsContextful/CPP/type_iscontextful.cpp b/snippets/cpp/VS_Snippets_CLR/Type_IsContextful/CPP/type_iscontextful.cpp deleted file mode 100644 index a9a34cadfd5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_IsContextful/CPP/type_iscontextful.cpp +++ /dev/null @@ -1,49 +0,0 @@ - -// -using namespace System; -using namespace System::Runtime::Remoting::Contexts; - -public ref class ContextBoundClass: public ContextBoundObject -{ - public: - String^ Value; -}; - -public ref class Example -{ -public: - void Demo() - { - // Determine whether the types can be hosted in a Context. - Console::WriteLine("The IsContextful property for the {0} type is {1}.", - Example::typeid->Name, Example::typeid->IsContextful); - Console::WriteLine("The IsContextful property for the {0} type is {1}.", - ContextBoundClass::typeid->Name, ContextBoundClass::typeid->IsContextful); - - // Determine whether the types are marshalled by reference. - Console::WriteLine("The IsMarshalByRef property of {0} is {1}.", - Example::typeid->Name, Example::typeid->IsMarshalByRef ); - Console::WriteLine("The IsMarshalByRef property of {0} is {1}.", - ContextBoundClass::typeid->Name, ContextBoundClass::typeid->IsMarshalByRef ); - - // Determine whether the types are primitive datatypes. - Console::WriteLine("{0} is a primitive data type: {1}.", - int::typeid->Name, int::typeid->IsPrimitive ); - Console::WriteLine("{0} is a primitive data type: {1}.", - String::typeid->Name, String::typeid->IsPrimitive ); - } -}; - -int main() -{ - Example^ ex = gcnew Example; - ex->Demo(); -} -// The example displays the following output: -// The IsContextful property for the Example type is False. -// The IsContextful property for the ContextBoundClass type is True. -// The IsMarshalByRef property of Example is False. -// The IsMarshalByRef property of ContextBoundClass is True. -// Int32 is a primitive data type: True. -// String is a primitive data type: False. -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_IsContextfulImpl/CPP/type_iscontextfulimpl.cpp b/snippets/cpp/VS_Snippets_CLR/Type_IsContextfulImpl/CPP/type_iscontextfulimpl.cpp deleted file mode 100644 index 1ce5137c1af..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_IsContextfulImpl/CPP/type_iscontextfulimpl.cpp +++ /dev/null @@ -1,82 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -public ref class MyTypeDelegatorClass: public TypeDelegator -{ -public: - String^ myElementType; - -private: - Type^ myType; - -public: - MyTypeDelegatorClass( Type^ myType ) - : TypeDelegator( myType ) - { - this->myType = myType; - } - -protected: - - // Override IsContextfulImpl. - virtual bool IsContextfulImpl() override - { - - // Check whether the type is contextful. - if ( myType->IsContextful ) - { - myElementType = " is contextful "; - return true; - } - - return false; - } - -}; - -public ref class MyTypeDemoClass{}; - - -// This class demonstrates IsContextfulImpl. -public ref class MyContextBoundClass: public ContextBoundObject -{ -public: - String^ myString; -}; - -int main() -{ - try - { - MyTypeDelegatorClass^ myType; - Console::WriteLine( "Check whether MyContextBoundClass can be hosted in a context." ); - - // Check whether MyContextBoundClass is contextful. - myType = gcnew MyTypeDelegatorClass( MyContextBoundClass::typeid ); - if ( myType->IsContextful ) - { - Console::WriteLine( "{0} can be hosted in a context.", MyContextBoundClass::typeid ); - } - else - { - Console::WriteLine( "{0} cannot be hosted in a context.", MyContextBoundClass::typeid ); - } - myType = gcnew MyTypeDelegatorClass( MyTypeDemoClass::typeid ); - Console::WriteLine( "\nCheck whether MyTypeDemoClass can be hosted in a context." ); - if ( myType->IsContextful ) - { - Console::WriteLine( "{0} can be hosted in a context.", MyTypeDemoClass::typeid ); - } - else - { - Console::WriteLine( "{0} cannot be hosted in a context.", MyTypeDemoClass::typeid ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_IsInterface/CPP/type_isinterface.cpp b/snippets/cpp/VS_Snippets_CLR/Type_IsInterface/CPP/type_isinterface.cpp deleted file mode 100644 index f8e795207a6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_IsInterface/CPP/type_isinterface.cpp +++ /dev/null @@ -1,35 +0,0 @@ - -// -using namespace System; - -// Declare an interface. -interface class myIFace{}; -public ref class MyIsInterface{}; - -void main() -{ - try - { - // Get the IsInterface attribute for myIFace. - bool myBool1 = myIFace::typeid->IsInterface; - - //Display the IsInterface attribute for myIFace. - Console::WriteLine( "Is the specified type an interface? {0}.", myBool1 ); - - // Get the attribute IsInterface for MyIsInterface. - bool myBool2 = MyIsInterface::typeid->IsInterface; - - //Display the IsInterface attribute for MyIsInterface. - Console::WriteLine( "Is the specified type an interface? {0}.", myBool2 ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nAn exception occurred: {0}.", e->Message ); - } -} -/* The example produces the following output: - -Is the specified type an interface? True. -Is the specified type an interface? False. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_IsLayoutSequential/CPP/type_islayoutsequential.cpp b/snippets/cpp/VS_Snippets_CLR/Type_IsLayoutSequential/CPP/type_islayoutsequential.cpp deleted file mode 100644 index db0652f266e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_IsLayoutSequential/CPP/type_islayoutsequential.cpp +++ /dev/null @@ -1,40 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Reflection; -using namespace System::ComponentModel; -using namespace System::Runtime::InteropServices; -ref class MyTypeSequential1{}; - - -[StructLayoutAttribute(LayoutKind::Sequential)] -ref class MyTypeSequential2{}; - -int main() -{ - try - { - - // Create an instance of myTypeSeq1. - MyTypeSequential1^ myObj1 = gcnew MyTypeSequential1; - - // Check for and display the SequentialLayout attribute. - Console::WriteLine( "\nThe object myObj1 has IsLayoutSequential: {0}.", myObj1->GetType()->IsLayoutSequential ); - - // Create an instance of 'myTypeSeq2' class. - MyTypeSequential2^ myObj2 = gcnew MyTypeSequential2; - - // Check for and display the SequentialLayout attribute. - Console::WriteLine( "\nThe object myObj2 has IsLayoutSequential: {0}.", myObj2->GetType()->IsLayoutSequential ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nAn exception occurred: {0}", e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_IsMarshalByRefImpl/CPP/type_ismarshalbyrefimpl.cpp b/snippets/cpp/VS_Snippets_CLR/Type_IsMarshalByRefImpl/CPP/type_ismarshalbyrefimpl.cpp deleted file mode 100644 index d6c5c85b0f9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_IsMarshalByRefImpl/CPP/type_ismarshalbyrefimpl.cpp +++ /dev/null @@ -1,81 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -public ref class MyTypeDelegatorClass: public TypeDelegator -{ -public: - String^ myElementType; - -private: - Type^ myType; - -public: - MyTypeDelegatorClass( Type^ myType ) - : TypeDelegator( myType ) - { - this->myType = myType; - } - -protected: - - // Override IsMarshalByRefImpl. - virtual bool IsMarshalByRefImpl() override - { - // Determine whether the type is marshalled by reference. - if ( myType->IsMarshalByRef ) - { - myElementType = " marshalled by reference"; - return true; - } - - return false; - } -}; - -public ref class MyTypeDemoClass{}; - - -// This class is used to demonstrate the IsMarshalByRefImpl method. -public ref class MyContextBoundClass: public ContextBoundObject -{ -public: - String^ myString; -}; - -int main() -{ - try - { - MyTypeDelegatorClass^ myType; - Console::WriteLine( "Determine whether MyContextBoundClass is marshalled by reference." ); - - // Determine whether MyContextBoundClass type is marshalled by reference. - myType = gcnew MyTypeDelegatorClass( MyContextBoundClass::typeid ); - if ( myType->IsMarshalByRef ) - { - Console::WriteLine( "{0} is marshalled by reference.", MyContextBoundClass::typeid ); - } - else - { - Console::WriteLine( "{0} is not marshalled by reference.", MyContextBoundClass::typeid ); - } - - // Determine whether int type is marshalled by reference. - myType = gcnew MyTypeDelegatorClass( int::typeid ); - Console::WriteLine( "\nDetermine whether int is marshalled by reference." ); - if ( myType->IsMarshalByRef ) - { - Console::WriteLine( "{0} is marshalled by reference.", int::typeid ); - } - else - { - Console::WriteLine( "{0} is not marshalled by reference.", int::typeid ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_IsPrimitiveImpl/CPP/type_isprimitiveimpl.cpp b/snippets/cpp/VS_Snippets_CLR/Type_IsPrimitiveImpl/CPP/type_isprimitiveimpl.cpp deleted file mode 100644 index 777086959b5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_IsPrimitiveImpl/CPP/type_isprimitiveimpl.cpp +++ /dev/null @@ -1,73 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; - -public ref class MyTypeDelegatorClass: public TypeDelegator -{ -public: - String^ myElementType; - -private: - Type^ myType; - -public: - MyTypeDelegatorClass( Type^ myType ) - : TypeDelegator( myType ) - { - this->myType = myType; - } - -protected: - - // Override the IsPrimitiveImpl. - virtual bool IsPrimitiveImpl() override - { - - // Determine whether the type is a primitive type. - if ( myType->IsPrimitive ) - { - myElementType = "primitive"; - return true; - } - - return false; - } -}; - -int main() -{ - try - { - Console::WriteLine( "Determine whether int is a primitive type." ); - MyTypeDelegatorClass^ myType; - myType = gcnew MyTypeDelegatorClass( int::typeid ); - - // Determine whether int is a primitive type. - if ( myType->IsPrimitive ) - { - Console::WriteLine( "{0} is a primitive type.", int::typeid ); - } - else - { - Console::WriteLine( "{0} is not a primitive type.", int::typeid ); - } - Console::WriteLine( "\nDetermine whether String is a primitive type." ); - myType = gcnew MyTypeDelegatorClass( String::typeid ); - - // Determine if String is a primitive type. - if ( myType->IsPrimitive ) - { - Console::WriteLine( "{0} is a primitive type.", String::typeid ); - } - else - { - Console::WriteLine( "{0} is not a primitive type.", String::typeid ); - } - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_IsSealed/CPP/type_issealed.cpp b/snippets/cpp/VS_Snippets_CLR/Type_IsSealed/CPP/type_issealed.cpp deleted file mode 100644 index ef24b8b9c18..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_IsSealed/CPP/type_issealed.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; - -// Declare MyTestClass as sealed. -ref class TestClass sealed{}; - -int main() -{ - TestClass^ testClassInstance = gcnew TestClass; - - // Get the type of testClassInstance. - Type^ type = testClassInstance->GetType(); - - // Get the IsSealed property of the myTestClassInstance. - bool sealed = type->IsSealed; - Console::WriteLine("{0} is sealed: {1}.", type->FullName, sealed); -} -// The example displays the following output: -// TestClass is sealed: True. -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_IsSerializable/CPP/type_isserializable.cpp b/snippets/cpp/VS_Snippets_CLR/Type_IsSerializable/CPP/type_isserializable.cpp deleted file mode 100644 index 80e31b7ccbb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_IsSerializable/CPP/type_isserializable.cpp +++ /dev/null @@ -1,37 +0,0 @@ - -// -using namespace System; -public ref class MyClass -{ -public: - - // Declare a public class with the [Serializable] attribute. - - [Serializable] - ref class MyTestClass{}; - - -}; - -int main() -{ - try - { - bool myBool = false; - MyClass::MyTestClass^ myTestClassInstance = gcnew MyClass::MyTestClass; - - // Get the type of myTestClassInstance. - Type^ myType = myTestClassInstance->GetType(); - - // Get the IsSerializable property of myTestClassInstance. - myBool = myType->IsSerializable; - Console::WriteLine( "\nIs {0} serializable? {1}.", myType->FullName, myBool ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "\nAn exception occurred: {0}", e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_IsValueType/CPP/type_isvaluetype.cpp b/snippets/cpp/VS_Snippets_CLR/Type_IsValueType/CPP/type_isvaluetype.cpp deleted file mode 100644 index c8ad8156905..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_IsValueType/CPP/type_isvaluetype.cpp +++ /dev/null @@ -1,24 +0,0 @@ - -// -using namespace System; - -// Declare an enum type. -public enum class NumEnum -{ - One, Two -}; - -int main() -{ - bool flag = false; - NumEnum testEnum = NumEnum::One; - - // Get the type of testEnum. - Type^ t = testEnum.GetType(); - - // Get the IsValueType property of the testEnum - // variable. - flag = t->IsValueType; - Console::WriteLine("{0} is a value type: {1}", t->FullName, flag); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_ToString/CPP/type_tostring.cpp b/snippets/cpp/VS_Snippets_CLR/Type_ToString/CPP/type_tostring.cpp deleted file mode 100644 index d6e8a01a328..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_ToString/CPP/type_tostring.cpp +++ /dev/null @@ -1,31 +0,0 @@ - -// -using namespace System; - -namespace MyNamespace -{ - ref class MyClass - { - }; -} - -void main() -{ - Type^ myType = MyNamespace::MyClass::typeid; - Console::WriteLine("Displaying information about {0}:", myType ); - - // Get the namespace of the class MyClass. - Console::WriteLine(" Namespace: {0}", myType->Namespace ); - - // Get the name of the module. - Console::WriteLine(" Module: {0}", myType->Module ); - - // Get the fully qualified common language runtime namespace. - Console::WriteLine(" Fully qualified type: {0}", myType ); -} -// The example displays the following output: -// Displaying information about MyNamespace.MyClass: -// Namespace: MyNamespace -// Module: type_tostring.exe -// Fully qualified name: MyNamespace.MyClass -// diff --git a/snippets/cpp/VS_Snippets_CLR/Type_TypeHandle/CPP/type_typehandle.cpp b/snippets/cpp/VS_Snippets_CLR/Type_TypeHandle/CPP/type_typehandle.cpp deleted file mode 100644 index 23ac79f22ee..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Type_TypeHandle/CPP/type_typehandle.cpp +++ /dev/null @@ -1,42 +0,0 @@ - -// -using namespace System; -using namespace System::Reflection; -ref class MyClass -{ -public: - int myField; -}; - -void DisplayTypeHandle( RuntimeTypeHandle myTypeHandle ) -{ - - // Get the type from the handle. - Type^ myType = Type::GetTypeFromHandle( myTypeHandle ); - - // Display the type. - Console::WriteLine( "\nDisplaying the type from the handle:\n" ); - Console::WriteLine( "The type is {0}.", myType ); -} - -int main() -{ - try - { - MyClass^ myClass = gcnew MyClass; - - // Get the type of MyClass. - Type^ myClassType = myClass->GetType(); - - // Get the runtime handle of MyClass. - RuntimeTypeHandle myClassHandle = myClassType->TypeHandle; - DisplayTypeHandle( myClassHandle ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/UInt16 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/UInt16 Example/CPP/source.cpp deleted file mode 100644 index 439589d1a61..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/UInt16 Example/CPP/source.cpp +++ /dev/null @@ -1,631 +0,0 @@ - -// This is the main DLL file. -using namespace System; -using namespace System::Globalization; - -#define NULL 0 - -// -/// -/// Temperature class stores the value as UInt16 -/// and delegates most of the functionality -/// to the UInt16 implementation. -/// -public ref class Temperature: public IComparable, public IFormattable -{ -protected: - - /// - /// IComparable.CompareTo implementation. - /// - short m_value; - -public: - virtual Int32 CompareTo( Object^ obj ) - { - if ( obj->GetType() == Temperature::typeid ) - { - Temperature^ temp = dynamic_cast(obj); - return m_value.CompareTo( temp->m_value ); - } - - throw gcnew ArgumentException( "object is not a Temperature" ); - } - - - /// - /// IFormattable.ToString implementation. - /// - virtual String^ ToString( String^ format, IFormatProvider^ provider ) - { - if ( format != nullptr ) - { - if ( format->Equals( "F" ) ) - { - return String::Format( "{0}'F", this->Value.ToString() ); - } - - if ( format->Equals( "C" ) ) - { - return String::Format( "{0}'C", this->Celsius.ToString() ); - } - } - - return m_value.ToString( format, provider ); - } - - - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - static Temperature^ Parse( String^ s, NumberStyles styles, IFormatProvider^ provider ) - { - Temperature^ temp = gcnew Temperature; - if ( s->EndsWith( "F" ) ) - { - temp->Value = UInt16::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ), styles, provider ); - } - else - { - if ( s->EndsWith( "C" ) ) - { - temp->Celsius = UInt16::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ), styles, provider ); - } - else - { - temp->Value = UInt16::Parse( s, styles, provider ); - } - } - - return temp; - } - - - property short Value - { - - // The value holder - short get() - { - return m_value; - } - - void set( short value ) - { - m_value = value; - } - - } - - property short Celsius - { - short get() - { - return (short)((m_value - 32) / 2); - } - - void set( short value ) - { - m_value = (short)(value * 2 + 32); - } - - } - - static property short MinValue - { - short get() - { - return UInt16::MinValue; - } - - } - - static property short MaxValue - { - short get() - { - return UInt16::MaxValue; - } - - } - -}; -// - -void main() -{ - Temperature^ t1 = Temperature::Parse( "40'F", NumberStyles::Integer, nullptr ); - Console::WriteLine( t1->ToString( "F", nullptr ) ); - String^ str1 = t1->ToString( "C", nullptr ); - Console::WriteLine( str1 ); - Temperature^ t2 = Temperature::Parse( str1, NumberStyles::Integer, nullptr ); - Console::WriteLine( t2->ToString( "F", nullptr ) ); - Console::WriteLine( t1->CompareTo( t2 ) ); - Temperature^ t3 = Temperature::Parse( "40'C", NumberStyles::Integer, nullptr ); - Console::WriteLine( t3->ToString( "F", nullptr ) ); - Console::WriteLine( t1->CompareTo( t3 ) ); -} - - -/* expected return values: -40'F -4'C -40'F -0 -112'F --72 -*/ -namespace Snippets2 -{ - // - public ref class Temperature - { - protected: - - // The value holder - short m_value; - - public: - - static property short MinValue - { - short get() - { - return UInt16::MinValue; - } - - } - - static property short MaxValue - { - short get() - { - return UInt16::MaxValue; - } - - } - - property short Value - { - short get() - { - return m_value; - } - - void set( short value ) - { - m_value = value; - } - - } - - property short Celsius - { - short get() - { - return (short)((m_value - 32) / 2); - } - - void set( short value ) - { - m_value = (short)(value * 2 + 32); - } - - } - - }; - -} -// - -namespace Snippets3 -{ - - // - public ref class Temperature: public IComparable - { - protected: - - /// - /// IComparable.CompareTo implementation. - /// - // The value holder - short m_value; - - public: - virtual Int32 CompareTo( Object^ obj ) - { - if ( obj->GetType() == Temperature::typeid ) - { - Temperature^ temp = dynamic_cast(obj); - return m_value.CompareTo( temp->m_value ); - } - - throw gcnew ArgumentException( "object is not a Temperature" ); - } - - - property short Value - { - short get() - { - return m_value; - } - - void set( short value ) - { - m_value = value; - } - - } - - property short Celsius - { - short get() - { - return (short)((m_value - 32) / 2); - } - - void set( short value ) - { - m_value = (value * 2 + 32); - } - - } - - }; - -} -// - -namespace Snippets4 -{ - - // - public ref class Temperature: public IFormattable - { - protected: - - /// - /// IFormattable.ToString implementation. - /// - // The value holder - short m_value; - - public: - virtual String^ ToString( String^ format, IFormatProvider^ provider ) - { - if ( format != nullptr ) - { - if ( format->Equals( "F" ) ) - { - return String::Format( "{0}'F", this->Value.ToString() ); - } - - if ( format->Equals( "C" ) ) - { - return String::Format( "{0}'C", this->Celsius.ToString() ); - } - } - - return m_value.ToString( format, provider ); - } - - - property short Value - { - short get() - { - return m_value; - } - - void set( short value ) - { - m_value = value; - } - - } - - property short Celsius - { - short get() - { - return (short)((m_value - 32) / 2); - } - - void set( short value ) - { - m_value = (short)(value * 2 + 32); - } - - } - - }; - -} -// - -namespace Snippets5 -{ - // - public ref class Temperature - { - protected: - - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - // The value holder - short m_value; - - public: - static Temperature^ Parse( String^ s ) - { - Temperature^ temp = gcnew Temperature; - if ( s->TrimEnd( NULL )->EndsWith( "'F" ) ) - { - temp->Value = UInt16::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ) ); - } - else - { - if ( s->TrimEnd( NULL )->EndsWith( "'C" ) ) - { - temp->Celsius = UInt16::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ) ); - } - else - { - temp->Value = UInt16::Parse( s ); - } - } - - return temp; - } - - - property short Value - { - short get() - { - return m_value; - } - - void set( short value ) - { - m_value = value; - } - - } - - property short Celsius - { - short get() - { - return (short)((m_value - 32) / 2); - } - - void set( short value ) - { - m_value = (short)(value * 2 + 32); - } - - } - - }; - -} -// - -namespace Snippets6 -{ - // - public ref class Temperature - { - protected: - - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - // The value holder - short m_value; - - public: - static Temperature^ Parse( String^ s, IFormatProvider^ provider ) - { - Temperature^ temp = gcnew Temperature; - if ( s->TrimEnd( NULL )->EndsWith( "'F" ) ) - { - temp->Value = UInt16::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ), provider ); - } - else - { - if ( s->TrimEnd( NULL )->EndsWith( "'C" ) ) - { - temp->Celsius = UInt16::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ), provider ); - } - else - { - temp->Value = UInt16::Parse( s, provider ); - } - } - - return temp; - } - - - property short Value - { - short get() - { - return m_value; - } - - void set( short value ) - { - m_value = value; - } - - } - - property short Celsius - { - short get() - { - return (short)((m_value - 32) / 2); - } - - void set( short value ) - { - m_value = (short)(value * 2 + 32); - } - - } - - }; - -} -// - -namespace Snippets7 -{ - // - public ref class Temperature - { - protected: - - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - // The value holder - short m_value; - - public: - static Temperature^ Parse( String^ s, NumberStyles styles ) - { - Temperature^ temp = gcnew Temperature; - if ( s->TrimEnd( NULL )->EndsWith( "'F" ) ) - { - temp->Value = UInt16::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ), styles ); - } - else - { - if ( s->TrimEnd( NULL )->EndsWith( "'C" ) ) - { - temp->Celsius = UInt16::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ), styles ); - } - else - { - temp->Value = UInt16::Parse( s, styles ); - } - } - - return temp; - } - - - property short Value - { - short get() - { - return m_value; - } - - void set( short value ) - { - m_value = value; - } - - } - - property short Celsius - { - short get() - { - return (short)((m_value - 32) / 2); - } - - void set( short value ) - { - m_value = (short)(value * 2 + 32); - } - - } - - }; - -} -// - -namespace Snippets8 -{ - // - public ref class Temperature - { - protected: - - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - // The value holder - short m_value; - - public: - static Temperature^ Parse( String^ s, NumberStyles styles, IFormatProvider^ provider ) - { - Temperature^ temp = gcnew Temperature; - if ( s->TrimEnd( NULL )->EndsWith( "'F" ) ) - { - temp->Value = UInt16::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ), styles, provider ); - } - else - { - if ( s->TrimEnd( NULL )->EndsWith( "'C" ) ) - { - temp->Celsius = UInt16::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ), styles, provider ); - } - else - { - temp->Value = UInt16::Parse( s, styles, provider ); - } - } - - return temp; - } - - - property short Value - { - short get() - { - return m_value; - } - - void set( short value ) - { - m_value = value; - } - - } - - property short Celsius - { - short get() - { - return (short)((m_value - 32) / 2); - } - - void set( short value ) - { - m_value = (short)(value * 2 + 32); - } - - } - - }; - -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/UInt16_Equals/CPP/uint16_equals.cpp b/snippets/cpp/VS_Snippets_CLR/UInt16_Equals/CPP/uint16_equals.cpp deleted file mode 100644 index 03bba64ea5d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/UInt16_Equals/CPP/uint16_equals.cpp +++ /dev/null @@ -1,34 +0,0 @@ - -// System::UInt16::Equals(Object) -/* -The following program demonstrates the 'Equals(Object)' method -of struct 'UInt16'. This compares an instance of 'UInt16' with the -passed in Object* and returns true if they are equal. -*/ -using namespace System; - -int main() -{ - try - { - // - UInt16 myVariable1 = 10; - UInt16 myVariable2 = 10; - - //Display the declaring type. - Console::WriteLine( "\nType of 'myVariable1' is '{0}' and value is : {1}", myVariable1.GetType(), myVariable1 ); - Console::WriteLine( "Type of 'myVariable2' is '{0}' and value is : {1}", myVariable2.GetType(), myVariable2 ); - - // Compare 'myVariable1' instance with 'myVariable2' Object. - if ( myVariable1.Equals( myVariable2 ) ) - Console::WriteLine( "\nStructures 'myVariable1' and 'myVariable2' are equal" ); - else - Console::WriteLine( "\nStructures 'myVariable1' and 'myVariable2' are not equal" ); - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - } - -} diff --git a/snippets/cpp/VS_Snippets_CLR/UInt32 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/UInt32 Example/CPP/source.cpp deleted file mode 100644 index 75a62e5c82b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/UInt32 Example/CPP/source.cpp +++ /dev/null @@ -1,417 +0,0 @@ -using namespace System; -using namespace System::Globalization; - -namespace Snippets -{ - // - /// - /// Temperature class stores the value as UInt32 - /// and delegates most of the functionality - /// to the UInt32 implementation. - /// - public ref class Temperature: public IComparable, public IFormattable - { - public: - /// - /// IComparable.CompareTo implementation. - /// - virtual int CompareTo( Object^ obj ) - { - if ( (Temperature^)( obj ) ) - { - Temperature^ temp = (Temperature^)( obj ); - - return m_value.CompareTo( temp->m_value ); - } - - throw gcnew ArgumentException( "object is not a Temperature" ); - } - - /// - /// IFormattable.ToString implementation. - /// - virtual String^ ToString( String^ format, IFormatProvider^ provider ) - { - if ( format != nullptr && format == "F" ) - { - return String::Format( "{0}'F", this->Value.ToString() ); - } - - return m_value.ToString( format, provider ); - } - - - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - static Temperature^ Parse( String^ s, NumberStyles styles, IFormatProvider^ provider ) - { - Temperature^ temp = gcnew Temperature; - - if ( s->TrimEnd( 0 )->EndsWith( "'F" ) ) - { - temp->Value = UInt32::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ), styles, provider ); - } - else - { - temp->Value = UInt32::Parse( s, styles, provider ); - } - - return temp; - } - - protected: - // The value holder - UInt32 m_value; - - public: - property UInt32 Value - { - UInt32 get() - { - return m_value; - } - void set( UInt32 value ) - { - m_value = value; - } - } - }; -} -// - -namespace Snippets2 -{ - // - public ref class Temperature - { - public: - static property UInt32 MinValue - { - UInt32 get() - { - return UInt32::MinValue; - } - } - - static property UInt32 MaxValue - { - UInt32 get() - { - return UInt32::MaxValue; - } - } - - protected: - // The value holder - UInt32 m_value; - - public: - property UInt32 Value - { - UInt32 get() - { - return m_value; - } - void set( UInt32 value ) - { - m_value = value; - } - } - }; -} -// - -namespace Snippets3 -{ - // - public ref class Temperature: public IComparable - { - public: - /// - /// IComparable.CompareTo implementation. - /// - virtual int CompareTo( Object^ obj ) - { - if ( (Temperature^)( obj ) ) - { - Temperature^ temp = (Temperature^)( obj ); - - return m_value.CompareTo( temp->m_value ); - } - - throw gcnew ArgumentException( "object is not a Temperature" ); - } - - protected: - // The value holder - UInt32 m_value; - - public: - property UInt32 Value - { - UInt32 get() - { - return m_value; - } - void set( UInt32 value ) - { - m_value = value; - } - } - }; -} -// - -namespace Snippets4 -{ - // - public ref class Temperature: public IFormattable - { - public: - /// - /// IFormattable.ToString implementation. - /// - virtual String^ ToString( String^ format, IFormatProvider^ provider ) - { - if ( format != nullptr && format == "F" ) - { - return String::Format( "{0}'F", this->Value.ToString() ); - } - - return m_value.ToString( format, provider ); - } - - protected: - // The value holder - UInt32 m_value; - - public: - property UInt32 Value - { - UInt32 get() - { - return m_value; - } - void set( UInt32 value ) - { - m_value = value; - } - } - }; -} -// - -namespace Snippets5 -{ - // - public ref class Temperature - { - public: - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - static Temperature^ Parse( String^ s ) - { - Temperature^ temp = gcnew Temperature; - - if ( s->TrimEnd( 0 )->EndsWith( "'F" ) ) - { - temp->Value = UInt32::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ) ); - } - else - { - temp->Value = UInt32::Parse( s ); - } - - return temp; - } - - protected: - // The value holder - UInt32 m_value; - - public: - property UInt32 Value - { - UInt32 get() - { - return m_value; - } - void set( UInt32 value ) - { - m_value = value; - } - } - }; -} -// - -namespace Snippets6 -{ - // - public ref class Temperature - { - public: - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - static Temperature^ Parse( String^ s, IFormatProvider^ provider ) - { - Temperature^ temp = gcnew Temperature; - - if ( s->TrimEnd( 0 )->EndsWith( "'F" ) ) - { - temp->Value = UInt32::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ), provider ); - } - else - { - temp->Value = UInt32::Parse( s, provider ); - } - - return temp; - } - - protected: - // The value holder - UInt32 m_value; - - public: - property UInt32 Value - { - UInt32 get() - { - return m_value; - } - void set( UInt32 value ) - { - m_value = value; - } - } - }; -} -// - -namespace Snippets7 -{ - // - public ref class Temperature - { - public: - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - static Temperature^ Parse( String^ s, NumberStyles styles ) - { - Temperature^ temp = gcnew Temperature; - - if ( s->TrimEnd( 0 )->EndsWith( "'F" ) ) - { - temp->Value = UInt32::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ), styles ); - } - else - { - temp->Value = UInt32::Parse( s, styles ); - } - - return temp; - } - - protected: - // The value holder - UInt32 m_value; - - public: - property UInt32 Value - { - UInt32 get() - { - return m_value; - } - void set( UInt32 value ) - { - m_value = value; - } - } - }; -} -// - -namespace Snippets8 -{ - // - public ref class Temperature - { - public: - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - static Temperature^ Parse( String^ s, NumberStyles styles, IFormatProvider^ provider ) - { - Temperature^ temp = gcnew Temperature; - - if ( s->TrimEnd( 0 )->EndsWith( "'F" ) ) - { - temp->Value = UInt32::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ), styles, provider ); - } - else - { - temp->Value = UInt32::Parse( s, styles, provider ); - } - - return temp; - } - - protected: - // The value holder - UInt32 m_value; - - public: - property UInt32 Value - { - UInt32 get() - { - return m_value; - } - void set( UInt32 value ) - { - m_value = value; - } - } - }; -} -// - -namespace Snippets -{ - void Main() - { - Temperature^ t1 = Temperature::Parse( "20'F", NumberStyles::Integer, nullptr ); - Console::WriteLine( t1->ToString( "F", nullptr ) ); - - String^ str1 = t1->ToString( "G", nullptr ); - Console::WriteLine( str1 ); - - Temperature^ t2 = Temperature::Parse( str1, NumberStyles::Integer, nullptr ); - Console::WriteLine( t2->ToString( "F", nullptr ) ); - - Console::WriteLine( t1->CompareTo( t2 ) ); - - Temperature^ t3 = Temperature::Parse( "30'F", NumberStyles::Integer, nullptr ); - Console::WriteLine( t3->ToString( "F", nullptr ) ); - - Console::WriteLine( t1->CompareTo( t3 ) ); - - Console::ReadLine(); - } -} - -int main() -{ - Snippets::Main(); -} diff --git a/snippets/cpp/VS_Snippets_CLR/UInt32_Equals/CPP/uint32_equals.cpp b/snippets/cpp/VS_Snippets_CLR/UInt32_Equals/CPP/uint32_equals.cpp deleted file mode 100644 index 66564fc6421..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/UInt32_Equals/CPP/uint32_equals.cpp +++ /dev/null @@ -1,34 +0,0 @@ - -// System::UInt32::Equals(Object) -/* -The following program demonstrates the 'Equals(Object)' method -of struct 'UInt32'. This compares an instance of 'UInt32' with the -passed in Object* and returns true if they are equal. -*/ -using namespace System; - -int main() -{ - try - { - // - UInt32 myVariable1 = 20; - UInt32 myVariable2 = 20; - - // Display the declaring type. - Console::WriteLine( "\nType of 'myVariable1' is '{0}' and value is : {1}", myVariable1.GetType(), myVariable1 ); - Console::WriteLine( "Type of 'myVariable2' is '{0}' and value is : {1}", myVariable2.GetType(), myVariable2 ); - - // Compare 'myVariable1' instance with 'myVariable2' Object. - if ( myVariable1.Equals( myVariable2 ) ) - Console::WriteLine( "\nStructures 'myVariable1' and 'myVariable2' are equal" ); - else - Console::WriteLine( "\nStructures 'myVariable1' and 'myVariable2' are not equal" ); - // - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception : {0}", e->Message ); - } - -} diff --git a/snippets/cpp/VS_Snippets_CLR/UInt64 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/UInt64 Example/CPP/source.cpp deleted file mode 100644 index 0e4d7eef2ef..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/UInt64 Example/CPP/source.cpp +++ /dev/null @@ -1,405 +0,0 @@ -using namespace System; -using namespace System::Globalization; - -// -/// -/// Temperature class stores the value as UInt64 -/// and delegates most of the functionality -/// to the UInt64 implementation. -/// -public ref class Temperature: public IComparable, public IFormattable -{ -public: - /// - /// IComparable.CompareTo implementation. - /// - virtual int CompareTo( Object^ obj ) - { - if ( (Temperature^)( obj ) ) - { - Temperature^ temp = (Temperature^)( obj ); - - return m_value.CompareTo( temp->m_value ); - } - - throw gcnew ArgumentException( "object is not a Temperature" ); - } - - /// - /// IFormattable.ToString implementation. - /// - virtual String^ ToString( String^ format, IFormatProvider^ provider ) - { - if ( format != nullptr && format == "F" ) - { - return String::Format( "{0}'F", this->Value.ToString() ); - } - - return m_value.ToString( format, provider ); - } - - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - static Temperature^ Parse( String^ s, NumberStyles styles, IFormatProvider^ provider ) - { - Temperature^ temp = gcnew Temperature; - - if ( s->TrimEnd( 0 )->EndsWith( "'F" ) ) - { - temp->Value = UInt64::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ), styles, provider ); - } - else - { - temp->Value = UInt64::Parse( s, styles, provider ); - } - - return temp; - } - -protected: - // The value holder - UInt64 m_value; - -public: - property UInt64 Value - { - UInt64 get() - { - return m_value; - } - void set( UInt64 value ) - { - m_value = value; - } - } -}; -// - -namespace Snippets2 -{ - // - public ref class Temperature - { - public: - static property Int64 MinValue - { - Int64 get() - { - return UInt64::MinValue; - } - } - - static property UInt64 MaxValue - { - UInt64 get() - { - return UInt64::MaxValue; - } - } - - protected: - // The value holder - UInt64 m_value; - - public: - property UInt64 Value - { - UInt64 get() - { - return m_value; - } - void set( UInt64 value ) - { - m_value = value; - } - } - }; -} -// - -namespace Snippets3 -{ - // - public ref class Temperature: public IComparable - { - public: - /// - /// IComparable.CompareTo implementation. - /// - virtual int CompareTo( Object^ obj ) - { - if ( (Temperature^)( obj ) ) - { - Temperature^ temp = (Temperature^)( obj ); - - return m_value.CompareTo( temp->m_value ); - } - - throw gcnew ArgumentException( "object is not a Temperature" ); - } - - protected: - // The value holder - UInt64 m_value; - - public: - property UInt64 Value - { - UInt64 get() - { - return m_value; - } - void set( UInt64 value ) - { - m_value = value; - } - } - }; -} -// - -namespace Snippets4 -{ - // - public ref class Temperature: public IFormattable - { - public: - /// - /// IFormattable.ToString implementation. - /// - virtual String^ ToString( String^ format, IFormatProvider^ provider ) - { - if ( format != nullptr && format == "F" ) - { - return String::Format( "{0}'F", this->Value.ToString() ); - } - - return m_value.ToString( format, provider ); - } - - protected: - // The value holder - UInt64 m_value; - - public: - property UInt64 Value - { - UInt64 get() - { - return m_value; - } - void set( UInt64 value ) - { - m_value = value; - } - } - }; -} -// - -namespace Snippets5 -{ - // - public ref class Temperature - { - public: - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - static Temperature^ Parse( String^ s ) - { - Temperature^ temp = gcnew Temperature; - - if ( s->TrimEnd( 0 )->EndsWith( "'F" ) ) - { - temp->Value = UInt64::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ) ); - } - else - { - temp->Value = UInt64::Parse( s ); - } - - return temp; - } - - protected: - // The value holder - UInt64 m_value; - - public: - property UInt64 Value - { - UInt64 get() - { - return m_value; - } - void set( UInt64 value ) - { - m_value = value; - } - } - }; -} -// - -namespace Snippets6 -{ - // - public ref class Temperature - { - public: - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - static Temperature^ Parse( String^ s, IFormatProvider^ provider ) - { - Temperature^ temp = gcnew Temperature; - - if ( s->TrimEnd( 0 )->EndsWith( "'F" ) ) - { - temp->Value = UInt64::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ), provider ); - } - else - { - temp->Value = UInt64::Parse( s, provider ); - } - - return temp; - } - - protected: - // The value holder - UInt64 m_value; - - public: - property UInt64 Value - { - UInt64 get() - { - return m_value; - } - void set( UInt64 value ) - { - m_value = value; - } - } - }; -} -// - -namespace Snippets7 -{ - // - public ref class Temperature - { - public: - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - static Temperature^ Parse( String^ s, NumberStyles styles ) - { - Temperature^ temp = gcnew Temperature; - - if ( s->TrimEnd( 0 )->EndsWith( "'F" ) ) - { - temp->Value = UInt64::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ), styles ); - } - else - { - temp->Value = UInt64::Parse( s, styles ); - } - - return temp; - } - - protected: - // The value holder - UInt64 m_value; - - public: - property UInt64 Value - { - UInt64 get() - { - return m_value; - } - void set( UInt64 value ) - { - m_value = value; - } - } - }; -} -// - -namespace Snippets8 -{ - // - public ref class Temperature - { - public: - /// - /// Parses the temperature from a string in form - /// [ws][sign]digits['F|'C][ws] - /// - static Temperature^ Parse( String^ s, NumberStyles styles, IFormatProvider^ provider ) - { - Temperature^ temp = gcnew Temperature; - - if ( s->TrimEnd( 0 )->EndsWith( "'F" ) ) - { - temp->Value = UInt64::Parse( s->Remove( s->LastIndexOf( '\'' ), 2 ), styles, provider ); - } - else - { - temp->Value = UInt64::Parse( s, styles, provider ); - } - - return temp; - } - - protected: - // The value holder - UInt64 m_value; - - public: - property UInt64 Value - { - UInt64 get() - { - return m_value; - } - void set( UInt64 value ) - { - m_value = value; - } - } - }; -} -// - -int main() -{ - Temperature^ t1 = Temperature::Parse( "20'F", NumberStyles::Integer, nullptr ); - Console::WriteLine( t1->ToString( "F", nullptr ) ); - - String^ str1 = t1->ToString( "G", nullptr ); - Console::WriteLine( str1 ); - - Temperature^ t2 = Temperature::Parse( str1, NumberStyles::Integer, nullptr ); - Console::WriteLine( t2->ToString( "F", nullptr ) ); - - Console::WriteLine( t1->CompareTo( t2 ) ); - - Temperature^ t3 = Temperature::Parse( "30'F", NumberStyles::Integer, nullptr ); - Console::WriteLine( t3->ToString( "F", nullptr ) ); - - Console::WriteLine( t1->CompareTo( t3 ) ); - - Console::ReadLine(); -} diff --git a/snippets/cpp/VS_Snippets_CLR/UInt64_Equals/CPP/uint64_equals.cpp b/snippets/cpp/VS_Snippets_CLR/UInt64_Equals/CPP/uint64_equals.cpp deleted file mode 100644 index b5928f9ee25..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/UInt64_Equals/CPP/uint64_equals.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// -using namespace System; - -int main() -{ - UInt64 value1 = 50; - UInt64 value2 = 50; - - // Display the values. - Console::WriteLine("value1: Type: {0} Value: {1}", - value1.GetType()->Name, value1); - Console::WriteLine("value2: Type: {0} Value: {1}", - value2.GetType()->Name, value2); - - // Compare the two values. - Console::WriteLine("value1 and value2 are equal: {0}", - value1.Equals(value2)); -} -// The example displays the following output: -// value1: Type: UInt64 Value: 50 -// value2: Type: UInt64 Value: 50 -// value1 and value2 are equal: True -// diff --git a/snippets/cpp/VS_Snippets_CLR/Uri_IsHexDigit/CPP/uri_ishexdigit.cpp b/snippets/cpp/VS_Snippets_CLR/Uri_IsHexDigit/CPP/uri_ishexdigit.cpp deleted file mode 100644 index 6a1f8f2f542..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Uri_IsHexDigit/CPP/uri_ishexdigit.cpp +++ /dev/null @@ -1,43 +0,0 @@ - - -/* -System.Uri.IsHexDigit - -The following program reads a string from console and determines whether the -specified character is valid hexadecimal digit. -*/ -#using - -using namespace System; -int main() -{ - try - { - // - Console::Write( "Type a string : " ); - String^ myString = Console::ReadLine(); - for ( int i = 0; i < myString->Length; i++ ) - if ( Uri::IsHexDigit( myString[ i ] ) ) - Console::WriteLine( "{0} is a hexadecimal digit.", myString[ i ] ); - else - Console::WriteLine( "{0} is not a hexadecimal digit.", myString[ i ] ); - // The example produces output like the following: - // Type a string : 3f5EaZ - // 3 is a hexadecimal digit. - // f is a hexadecimal digit. - // 5 is a hexadecimal digit. - // E is a hexadecimal digit. - // a is a hexadecimal digit. - // Z is not a hexadecimal digit. - // - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } -} - -// ***** Output ***** -/* - -*/ diff --git a/snippets/cpp/VS_Snippets_CLR/ValueType.Equals Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/ValueType.Equals Example/CPP/source.cpp deleted file mode 100644 index dfec68d03a1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/ValueType.Equals Example/CPP/source.cpp +++ /dev/null @@ -1,28 +0,0 @@ - -using namespace System; - -// -public ref struct Complex -{ -public: - double m_Re; - double m_Im; - virtual bool Equals( Object^ ob ) override - { - if ( dynamic_cast(ob) ) - { - Complex^ c = dynamic_cast(ob); - return m_Re == c->m_Re && m_Im == c->m_Im; - } - else - { - return false; - } - } - - virtual int GetHashCode() override - { - return m_Re.GetHashCode() ^ m_Im.GetHashCode(); - } -}; -// diff --git a/snippets/cpp/VS_Snippets_CLR/char.cvtutf32/CPP/utf.cpp b/snippets/cpp/VS_Snippets_CLR/char.cvtutf32/CPP/utf.cpp deleted file mode 100644 index 7cd42aba971..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/char.cvtutf32/CPP/utf.cpp +++ /dev/null @@ -1,57 +0,0 @@ - -// -// This example demonstrates the Char.ConvertFromUtf32() method -// and Char.ConvertToUtf32() overloads. -using namespace System; -void Show( String^ s ) -{ -// Console::Write( "0x{0:X}, 0x{1:X}", (int)s->get_Chars( 0 ), (int)s->get_Chars( 1 ) ); - Console::Write( "0x{0:X}, 0x{1:X}", (int)s[ 0 ], (int)s[ 1 ] ); -} - -int main() -{ - int music = 0x1D161; //U+1D161 = MUSICAL SYMBOL SIXTEENTH NOTE - - String^ s1; - String^ comment1a = "Create a UTF-16 encoded string from a code point."; - String^ comment1b = "Create a code point from a surrogate pair at a certain position in a string."; - String^ comment1c = "Create a code point from a high surrogate and a low surrogate code point."; - - // ------------------------------------------------------------------- - // Convert the code point U+1D161 to UTF-16. The UTF-16 equivalent of - // U+1D161 is a surrogate pair with hexadecimal values D834 and DD61. - Console::WriteLine( comment1a ); - s1 = Char::ConvertFromUtf32( music ); - Console::Write( " 1a) 0x{0:X} => ", music ); - Show( s1 ); - Console::WriteLine(); - - // Convert the surrogate pair in the string at index position - // zero to a code point. - Console::WriteLine( comment1b ); - music = Char::ConvertToUtf32( s1, 0 ); - Console::Write( " 1b) " ); - Show( s1 ); - Console::WriteLine( " => 0x{0:X}", music ); - - // Convert the high and low characters in the surrogate pair into a code point. - Console::WriteLine( comment1c ); - music = Char::ConvertToUtf32( s1[ 0 ], s1[ 1 ] ); - Console::Write( " 1c) " ); - Show( s1 ); - Console::WriteLine( " => 0x{0:X}", music ); -} - -/* -This example produces the following results: - -Create a UTF-16 encoded string from a code point. - 1a) 0x1D161 => 0xD834, 0xDD61 -Create a code point from a surrogate pair at a certain position in a string. - 1b) 0xD834, 0xDD61 => 0x1D161 -Create a code point from a high surrogate and a low surrogate code point. - 1c) 0xD834, 0xDD61 => 0x1D161 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/char.surrogate/CPP/sur.cpp b/snippets/cpp/VS_Snippets_CLR/char.surrogate/CPP/sur.cpp deleted file mode 100644 index 1a9d98b34ef..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/char.surrogate/CPP/sur.cpp +++ /dev/null @@ -1,85 +0,0 @@ - -// -// This example demonstrates the Char.IsLowSurrogate() method -// IsHighSurrogate() method -// IsSurrogatePair() method -using namespace System; -int main() -{ - Char cHigh = L'\xD800'; - Char cLow = L'\xDC00'; - array^temp0 = {L'a',L'\xD800',L'\xDC00',L'z'}; - String^ s1 = gcnew String( temp0 ); - String^ divider = String::Concat( Environment::NewLine, gcnew String( '-',70 ), Environment::NewLine ); - Console::WriteLine(); - Console::WriteLine( "Hexadecimal code point of the character, cHigh: {0:X4}", (int)cHigh ); - Console::WriteLine( "Hexadecimal code point of the character, cLow: {0:X4}", (int)cLow ); - Console::WriteLine(); - Console::WriteLine( "Characters in string, s1: 'a', high surrogate, low surrogate, 'z'" ); - Console::WriteLine( "Hexadecimal code points of the characters in string, s1: " ); - for ( int i = 0; i < s1->Length; i++ ) - { - Console::WriteLine( "s1[{0}] = {1:X4} ", i, (int)s1[ i ] ); - } - Console::WriteLine( divider ); - Console::WriteLine( "Is each of the following characters a high surrogate?" ); - Console::WriteLine( "A1) cLow? - {0}", Char::IsHighSurrogate( cLow ) ); - Console::WriteLine( "A2) cHigh? - {0}", Char::IsHighSurrogate( cHigh ) ); - Console::WriteLine( "A3) s1[0]? - {0}", Char::IsHighSurrogate( s1, 0 ) ); - Console::WriteLine( "A4) s1[1]? - {0}", Char::IsHighSurrogate( s1, 1 ) ); - Console::WriteLine( divider ); - Console::WriteLine( "Is each of the following characters a low surrogate?" ); - Console::WriteLine( "B1) cLow? - {0}", Char::IsLowSurrogate( cLow ) ); - Console::WriteLine( "B2) cHigh? - {0}", Char::IsLowSurrogate( cHigh ) ); - Console::WriteLine( "B3) s1[0]? - {0}", Char::IsLowSurrogate( s1, 0 ) ); - Console::WriteLine( "B4) s1[2]? - {0}", Char::IsLowSurrogate( s1, 2 ) ); - Console::WriteLine( divider ); - Console::WriteLine( "Is each of the following pairs of characters a surrogate pair?" ); - Console::WriteLine( "C1) cHigh and cLow? - {0}", Char::IsSurrogatePair( cHigh, cLow ) ); - Console::WriteLine( "C2) s1[0] and s1[1]? - {0}", Char::IsSurrogatePair( s1, 0 ) ); - Console::WriteLine( "C3) s1[1] and s1[2]? - {0}", Char::IsSurrogatePair( s1, 1 ) ); - Console::WriteLine( "C4) s1[2] and s1[3]? - {0}", Char::IsSurrogatePair( s1, 2 ) ); - Console::WriteLine( divider ); -} - -/* -This example produces the following results: - -Hexadecimal code point of the character, cHigh: D800 -Hexadecimal code point of the character, cLow: DC00 - -Characters in string, s1: 'a', high surrogate, low surrogate, 'z' -Hexadecimal code points of the characters in string, s1: -s1[0] = 0061 -s1[1] = D800 -s1[2] = DC00 -s1[3] = 007A - ----------------------------------------------------------------------- - -Is each of the following characters a high surrogate? -A1) cLow? - False -A2) cHigh? - True -A3) s1[0]? - False -A4) s1[1]? - True - ----------------------------------------------------------------------- - -Is each of the following characters a low surrogate? -B1) cLow? - True -B2) cHigh? - False -B3) s1[0]? - False -B4) s1[2]? - True - ----------------------------------------------------------------------- - -Is each of the following pairs of characters a surrogate pair? -C1) cHigh and cLow? - True -C2) s1[0] and s1[1]? - False -C3) s1[1] and s1[2]? - True -C4) s1[2] and s1[3]? - False - ----------------------------------------------------------------------- - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/console.beep/CPP/beep.cpp b/snippets/cpp/VS_Snippets_CLR/console.beep/CPP/beep.cpp deleted file mode 100644 index 23e5a5ec992..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/console.beep/CPP/beep.cpp +++ /dev/null @@ -1,42 +0,0 @@ - -// -// This example demonstrates the Console.Beep() method. -using namespace System; -int main() -{ - array^args = Environment::GetCommandLineArgs(); - int x = 0; - - // - if ( (args->Length == 2) && (Int32::TryParse( args[ 1 ], x )) && ((x >= 1) && (x <= 9)) ) - { - for ( int i = 1; i <= x; i++ ) - { - Console::WriteLine( "Beep number {0}.", i ); - Console::Beep(); - - } - } - else - Console::WriteLine( "Usage: Enter the number of times (between 1 and 9) to beep." ); -} - -/* -This example produces the following results: - ->beep -Usage: Enter the number of times (between 1 and 9) to beep - ->beep 9 -Beep number 1. -Beep number 2. -Beep number 3. -Beep number 4. -Beep number 5. -Beep number 6. -Beep number 7. -Beep number 8. -Beep number 9. - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/console.beep2/CPP/b2.cpp b/snippets/cpp/VS_Snippets_CLR/console.beep2/CPP/b2.cpp deleted file mode 100644 index d933d3fdf50..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/console.beep2/CPP/b2.cpp +++ /dev/null @@ -1,124 +0,0 @@ - -// -// This example demonstrates the Console.Beep(Int32, Int32) method -using namespace System; -using namespace System::Threading; -ref class Sample -{ -protected: - - // Define the frequencies of notes in an octave, as well as - // silence (rest). - enum class Tone - { - REST = 0, - GbelowC = 196, - A = 220, - Asharp = 233, - B = 247, - C = 262, - Csharp = 277, - D = 294, - Dsharp = 311, - E = 330, - F = 349, - Fsharp = 370, - G = 392, - Gsharp = 415 - }; - - - // Define the duration of a note in units of milliseconds. - enum class Duration - { - WHOLE = 1600, - HALF = Duration::WHOLE / 2, - QUARTER = Duration::HALF / 2, - EIGHTH = Duration::QUARTER / 2, - SIXTEENTH = Duration::EIGHTH / 2 - }; - - -public: - - // Define a note as a frequency (tone) and the amount of - // time (duration) the note plays. - value struct Note - { - public: - Tone toneVal; - Duration durVal; - - // Define a constructor to create a specific note. - Note( Tone frequency, Duration time ) - { - toneVal = frequency; - durVal = time; - } - - - property Tone NoteTone - { - - // Define properties to return the note's tone and duration. - Tone get() - { - return toneVal; - } - - } - - property Duration NoteDuration - { - Duration get() - { - return durVal; - } - - } - - }; - - -protected: - - // Play the notes in a song. - static void Play( array^ tune ) - { - System::Collections::IEnumerator^ myEnum = tune->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Note n = *safe_cast(myEnum->Current); - if ( n.NoteTone == Tone::REST ) - Thread::Sleep( (int)n.NoteDuration ); - else - Console::Beep( (int)n.NoteTone, (int)n.NoteDuration ); - } - } - - -public: - static void Main() - { - - // Declare the first few notes of the song, "Mary Had A Little Lamb". - array^ Mary = {Note( Tone::B, Duration::QUARTER ),Note( Tone::A, Duration::QUARTER ),Note( Tone::GbelowC, Duration::QUARTER ),Note( Tone::A, Duration::QUARTER ),Note( Tone::B, Duration::QUARTER ),Note( Tone::B, Duration::QUARTER ),Note( Tone::B, Duration::HALF ),Note( Tone::A, Duration::QUARTER ),Note( Tone::A, Duration::QUARTER ),Note( Tone::A, Duration::HALF ),Note( Tone::B, Duration::QUARTER ),Note( Tone::D, Duration::QUARTER ),Note( Tone::D, Duration::HALF )}; - - // Play the song - Play( Mary ); - } - -}; - -int main() -{ - Sample::Main(); -} - -/* -This example produces the following results: - -This example plays the first few notes of "Mary Had A Little Lamb" -through the console speaker. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/console.bufferHW/CPP/hw.cpp b/snippets/cpp/VS_Snippets_CLR/console.bufferHW/CPP/hw.cpp deleted file mode 100644 index 75f186ab055..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/console.bufferHW/CPP/hw.cpp +++ /dev/null @@ -1,18 +0,0 @@ - -// -// This example demonstrates the Console.BufferHeight and -// Console.BufferWidth properties. -using namespace System; -int main() -{ - Console::WriteLine( "The current buffer height is {0} rows.", Console::BufferHeight ); - Console::WriteLine( "The current buffer width is {0} columns.", Console::BufferWidth ); -} - -/* -This example produces the following results: - -The current buffer height is 300 rows. -The current buffer width is 85 columns. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/console.cancelkeypress/cpp/ckp.cpp b/snippets/cpp/VS_Snippets_CLR/console.cancelkeypress/cpp/ckp.cpp deleted file mode 100644 index 4ad4c4573e5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/console.cancelkeypress/cpp/ckp.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// -using namespace System; - -void OnCancelKeyPressed(Object^ sender, - ConsoleCancelEventArgs^ args) -{ - Console::WriteLine("{0}The read operation has been interrupted.", - Environment::NewLine); - - Console::WriteLine(" Key pressed: {0}", args->SpecialKey); - - Console::WriteLine(" Cancel property: {0}", args->Cancel); - - // Set the Cancel property to true to prevent the process from - // terminating. - Console::WriteLine("Setting the Cancel property to true..."); - args->Cancel = true; - - // Announce the new value of the Cancel property. - Console::WriteLine(" Cancel property: {0}", args->Cancel); - Console::WriteLine("The read operation will resume...{0}", - Environment::NewLine); -} - -int main() -{ - // Clear the screen. - Console::Clear(); - - // Establish an event handler to process key press events. - Console::CancelKeyPress += - gcnew ConsoleCancelEventHandler(OnCancelKeyPressed); - - while (true) - { - // Prompt the user. - Console::Write("Press any key, or 'X' to quit, or "); - Console::WriteLine("CTRL+C to interrupt the read operation:"); - - // Start a console read operation. Do not display the input. - ConsoleKeyInfo^ keyInfo = Console::ReadKey(true); - - // Announce the name of the key that was pressed . - Console::WriteLine(" Key pressed: {0}{1}", keyInfo->Key, - Environment::NewLine); - - // Exit if the user pressed the 'X' key. - if (keyInfo->Key == ConsoleKey::X) - { - break; - } - } -} -// The example displays output similar to the following: -// Press any key, or 'X' to quit, or CTRL+C to interrupt the read operation: -// Key pressed: J -// -// Press any key, or 'X' to quit, or CTRL+C to interrupt the read operation: -// Key pressed: Enter -// -// Press any key, or 'X' to quit, or CTRL+C to interrupt the read operation: -// -// The read operation has been interrupted. -// Key pressed: ControlC -// Cancel property: False -// Setting the Cancel property to true... -// Cancel property: True -// The read operation will resume... -// -// Key pressed: Q -// -// Press any key, or 'X' to quit, or CTRL+C to interrupt the read operation: -// Key pressed: X -// diff --git a/snippets/cpp/VS_Snippets_CLR/console.cursorLTS/CPP/lts.cpp b/snippets/cpp/VS_Snippets_CLR/console.cursorLTS/CPP/lts.cpp deleted file mode 100644 index fb1544c6848..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/console.cursorLTS/CPP/lts.cpp +++ /dev/null @@ -1,75 +0,0 @@ - -// -// This example demonstrates the -// Console.CursorLeft and -// Console.CursorTop properties, and the -// Console.SetCursorPosition and -// Console.Clear methods. -using namespace System; -int origRow; -int origCol; -void WriteAt( String^ s, int x, int y ) -{ - try - { - Console::SetCursorPosition( origCol + x, origRow + y ); - Console::Write( s ); - } - catch ( ArgumentOutOfRangeException^ e ) - { - Console::Clear(); - Console::WriteLine( e->Message ); - } - -} - -int main() -{ - - // Clear the screen, then save the top and left coordinates. - Console::Clear(); - origRow = Console::CursorTop; - origCol = Console::CursorLeft; - - // Draw the left side of a 5x5 rectangle, from top to bottom. - WriteAt( "+", 0, 0 ); - WriteAt( "|", 0, 1 ); - WriteAt( "|", 0, 2 ); - WriteAt( "|", 0, 3 ); - WriteAt( "+", 0, 4 ); - - // Draw the bottom side, from left to right. - WriteAt( "-", 1, 4 ); // shortcut: WriteAt("---", 1, 4) - WriteAt( "-", 2, 4 ); // ... - WriteAt( "-", 3, 4 ); // ... - WriteAt( "+", 4, 4 ); - - // Draw the right side, from bottom to top. - WriteAt( "|", 4, 3 ); - WriteAt( "|", 4, 2 ); - WriteAt( "|", 4, 1 ); - WriteAt( "+", 4, 0 ); - - // Draw the top side, from right to left. - WriteAt( "-", 3, 0 ); // shortcut: WriteAt("---", 1, 0) - WriteAt( "-", 2, 0 ); // ... - WriteAt( "-", 1, 0 ); // ... - - // - WriteAt( "All done!", 0, 6 ); - Console::WriteLine(); -} - -/* -This example produces the following results: - -+---+ -| | -| | -| | -+---+ - -All done! - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/console.cursorsize/CPP/csize.cpp b/snippets/cpp/VS_Snippets_CLR/console.cursorsize/CPP/csize.cpp deleted file mode 100644 index d04872cd7db..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/console.cursorsize/CPP/csize.cpp +++ /dev/null @@ -1,45 +0,0 @@ - -// -// This example demonstrates the Console.CursorSize property. -using namespace System; -int main() -{ - String^ m0 = "This example increments the cursor size from 1% to 100%:\n"; - String^ m1 = "Cursor size = {0}%. (Press any key to continue...)"; - array^sizes = {1,10,20,30,40,50,60,70,80,90,100}; - int saveCursorSize; - - // - saveCursorSize = Console::CursorSize; - Console::WriteLine( m0 ); - System::Collections::IEnumerator^ myEnum = sizes->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - int size = *safe_cast(myEnum->Current); - Console::CursorSize = size; - Console::WriteLine( m1, size ); - Console::ReadKey(); - } - - Console::CursorSize = saveCursorSize; -} - -/* -This example produces the following results: - -This example increments the cursor size from 1% to 100%: - -Cursor size = 1%. (Press any key to continue...) -Cursor size = 10%. (Press any key to continue...) -Cursor size = 20%. (Press any key to continue...) -Cursor size = 30%. (Press any key to continue...) -Cursor size = 40%. (Press any key to continue...) -Cursor size = 50%. (Press any key to continue...) -Cursor size = 60%. (Press any key to continue...) -Cursor size = 70%. (Press any key to continue...) -Cursor size = 80%. (Press any key to continue...) -Cursor size = 90%. (Press any key to continue...) -Cursor size = 100%. (Press any key to continue...) - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/console.cursorvis/CPP/vis.cpp b/snippets/cpp/VS_Snippets_CLR/console.cursorvis/CPP/vis.cpp deleted file mode 100644 index bf60e0028a7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/console.cursorvis/CPP/vis.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// -// This example demonstrates the Console.CursorVisible property. -using namespace System; - -int main() -{ - String^ m1 = "\nThe cursor is {0}.\nType any text then press Enter. " - "Type '+' in the first column to show \n" - "the cursor, '-' to hide the cursor, " - "or lowercase 'x' to quit:"; - String^ s; - bool saveCursorVisibile; - int saveCursorSize; - - // - Console::CursorVisible = true; // Initialize the cursor to visible. - saveCursorVisibile = Console::CursorVisible; - saveCursorSize = Console::CursorSize; - Console::CursorSize = 100; // Emphasize the cursor. - for ( ; ; ) - { - Console::WriteLine( m1, ((Console::CursorVisible == true) ? (String^)"VISIBLE" : "HIDDEN") ); - s = Console::ReadLine(); - if ( !String::IsNullOrEmpty( s ) ) - if ( s[ 0 ] == '+' ) - Console::CursorVisible = true; - else - if ( s[ 0 ] == '-' ) - Console::CursorVisible = false; - else - if ( s[ 0 ] == 'x' ) - break; - - } - Console::CursorVisible = saveCursorVisibile; - Console::CursorSize = saveCursorSize; -} - -/* -This example produces the following results. Note that these results -cannot depict cursor visibility. You must run the example to see the -cursor behavior: - -The cursor is VISIBLE. -Type any text then press Enter. Type '+' in the first column to show -the cursor, '-' to hide the cursor, or lowercase 'x' to quit: -The quick brown fox - -The cursor is VISIBLE. -Type any text then press Enter. Type '+' in the first column to show -the cursor, '-' to hide the cursor, or lowercase 'x' to quit: -- - -The cursor is HIDDEN. -Type any text then press Enter. Type '+' in the first column to show -the cursor, '-' to hide the cursor, or lowercase 'x' to quit: -jumps over - -The cursor is HIDDEN. -Type any text then press Enter. Type '+' in the first column to show -the cursor, '-' to hide the cursor, or lowercase 'x' to quit: -+ - -The cursor is VISIBLE. -Type any text then press Enter. Type '+' in the first column to show -the cursor, '-' to hide the cursor, or lowercase 'x' to quit: -the lazy dog. - -The cursor is VISIBLE. -Type any text then press Enter. Type '+' in the first column to show -the cursor, '-' to hide the cursor, or lowercase 'x' to quit: -x - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/console.keyavailable/CPP/ka.cpp b/snippets/cpp/VS_Snippets_CLR/console.keyavailable/CPP/ka.cpp deleted file mode 100644 index 8b8f1a06db8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/console.keyavailable/CPP/ka.cpp +++ /dev/null @@ -1,40 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -int main() -{ - ConsoleKeyInfo cki; - do - { - Console::WriteLine( "\nPress a key to display; press the 'x' key to quit." ); - - // Your code could perform some useful task in the following loop. However, - // for the sake of this example we'll merely pause for a quarter second. - while ( !Console::KeyAvailable ) - Thread::Sleep( 250 ); - cki = Console::ReadKey( true ); - Console::WriteLine( "You pressed the '{0}' key.", cki.Key ); - } - while ( cki.Key != ConsoleKey::X ); -} - -/* -This example produces results similar to the following: - -Press a key to display; press the 'x' key to quit. -You pressed the 'H' key. - -Press a key to display; press the 'x' key to quit. -You pressed the 'E' key. - -Press a key to display; press the 'x' key to quit. -You pressed the 'PageUp' key. - -Press a key to display; press the 'x' key to quit. -You pressed the 'DownArrow' key. - -Press a key to display; press the 'x' key to quit. -You pressed the 'X' key. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/console.read/CPP/read.cpp b/snippets/cpp/VS_Snippets_CLR/console.read/CPP/read.cpp deleted file mode 100644 index fa7edff4517..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/console.read/CPP/read.cpp +++ /dev/null @@ -1,82 +0,0 @@ - -// -// This example demonstrates the Console.Read() method. -using namespace System; -int main() -{ - String^ m1 = "\nType a string of text then press Enter. " - "Type '+' anywhere in the text to quit:\n"; - String^ m2 = "Character '{0}' is hexadecimal 0x{1:x4}."; - String^ m3 = "Character is hexadecimal 0x{0:x4}."; - Char ch; - int x; - - // - Console::WriteLine( m1 ); - do - { - x = Console::Read(); - try - { - ch = Convert::ToChar( x ); - if ( Char::IsWhiteSpace( ch ) ) - { - Console::WriteLine( m3, x ); - if ( ch == 0x0a ) - Console::WriteLine( m1 ); - } - else - Console::WriteLine( m2, ch, x ); - } - catch ( OverflowException^ e ) - { - Console::WriteLine( "{0} Value read = {1}.", e->Message, x ); - ch = Char::MinValue; - Console::WriteLine( m1 ); - } - - } - while ( ch != '+' ); -} - -/* -This example produces the following results: - -Type a string of text then press Enter. Type '+' anywhere in the text to quit: - -The quick brown fox. -Character 'T' is hexadecimal 0x0054. -Character 'h' is hexadecimal 0x0068. -Character 'e' is hexadecimal 0x0065. -Character is hexadecimal 0x0020. -Character 'q' is hexadecimal 0x0071. -Character 'u' is hexadecimal 0x0075. -Character 'i' is hexadecimal 0x0069. -Character 'c' is hexadecimal 0x0063. -Character 'k' is hexadecimal 0x006b. -Character is hexadecimal 0x0020. -Character 'b' is hexadecimal 0x0062. -Character 'r' is hexadecimal 0x0072. -Character 'o' is hexadecimal 0x006f. -Character 'w' is hexadecimal 0x0077. -Character 'n' is hexadecimal 0x006e. -Character is hexadecimal 0x0020. -Character 'f' is hexadecimal 0x0066. -Character 'o' is hexadecimal 0x006f. -Character 'x' is hexadecimal 0x0078. -Character '.' is hexadecimal 0x002e. -Character is hexadecimal 0x000d. -Character is hexadecimal 0x000a. - -Type a string of text then press Enter. Type '+' anywhere in the text to quit: - -^Z -Value was either too large or too small for a character. Value read = -1. - -Type a string of text then press Enter. Type '+' anywhere in the text to quit: - -+ -Character '+' is hexadecimal 0x002b. - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/console.readkey1/CPP/rk.cpp b/snippets/cpp/VS_Snippets_CLR/console.readkey1/CPP/rk.cpp deleted file mode 100644 index d2f1a175be4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/console.readkey1/CPP/rk.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// Console.ReadKey.cpp : main project file. - -// -using namespace System; - -void main() -{ - ConsoleKeyInfo cki; - // Prevent example from ending if CTL+C is pressed. - Console::TreatControlCAsInput = true; - - Console::WriteLine("Press any combination of CTL, ALT, and SHIFT, and a console key."); - Console::WriteLine("Press the Escape (Esc) key to quit: \n"); - do - { - cki = Console::ReadKey(); - Console::Write(" --- You pressed "); - if((cki.Modifiers & ConsoleModifiers::Alt) != ConsoleModifiers()) Console::Write("ALT+"); - if((cki.Modifiers & ConsoleModifiers::Shift) != ConsoleModifiers()) Console::Write("SHIFT+"); - if((cki.Modifiers & ConsoleModifiers::Control) != ConsoleModifiers()) Console::Write("CTL+"); - Console::WriteLine(cki.Key.ToString()); - } while (cki.Key != ConsoleKey::Escape); -} -// This example displays output similar to the following: -// Press any combination of CTL, ALT, and SHIFT, and a console key. -// Press the Escape (Esc) key to quit: -// -// a --- You pressed A -// k --- You pressed ALT+K -// â–º --- You pressed CTL+P -// --- You pressed RightArrow -// R --- You pressed SHIFT+R -// --- You pressed CTL+I -// j --- You pressed ALT+J -// O --- You pressed SHIFT+O -// § --- You pressed CTL+U } -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/console.readkey2/CPP/rkbool.cpp b/snippets/cpp/VS_Snippets_CLR/console.readkey2/CPP/rkbool.cpp deleted file mode 100644 index f354fdf3929..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/console.readkey2/CPP/rkbool.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// Console.ReadKey2.cpp : main project file. - -// -using namespace System; - -void main() -{ - ConsoleKeyInfo cki; - // Prevent example from ending if CTL+C is pressed. - Console::TreatControlCAsInput = true; - - Console::WriteLine("Press any combination of CTL, ALT, and SHIFT, and a console key."); - Console::WriteLine("Press the Escape (Esc) key to quit: \n"); - do { - cki = Console::ReadKey(true); - Console::Write("You pressed "); - if ((cki.Modifiers & ConsoleModifiers::Alt) != ConsoleModifiers()) Console::Write("ALT+"); - if ((cki.Modifiers & ConsoleModifiers::Shift) != ConsoleModifiers()) Console::Write("SHIFT+"); - if ((cki.Modifiers & ConsoleModifiers::Control) != ConsoleModifiers()) Console::Write("CTL+"); - Console::WriteLine("{0} (character '{1}')", cki.Key, cki.KeyChar); - } while (cki.Key != ConsoleKey::Escape); -} -// This example displays output similar to the following: -// Press any combination of CTL, ALT, and SHIFT, and a console key. -// Press the Escape (Esc) key to quit: -// -// You pressed CTL+A (character '☺') -// You pressed C (character 'c') -// You pressed CTL+C (character '♥') -// You pressed K (character 'k') -// You pressed ALT+I (character 'i') -// You pressed ALT+U (character 'u') -// You pressed ALT+SHIFT+H (character 'H') -// You pressed Escape (character 'â†') -// diff --git a/snippets/cpp/VS_Snippets_CLR/console.setwindowsize/CPP/sws.cpp b/snippets/cpp/VS_Snippets_CLR/console.setwindowsize/CPP/sws.cpp deleted file mode 100644 index 074acc11362..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/console.setwindowsize/CPP/sws.cpp +++ /dev/null @@ -1,55 +0,0 @@ - -// -// This example demonstrates the Console.SetWindowSize method, -// the Console.WindowWidth property, -// and the Console.WindowHeight property. -using namespace System; -int main() -{ - int origWidth; - int width; - int origHeight; - int height; - String^ m1 = "The current window width is {0}, and the " - "current window height is {1}."; - String^ m2 = "The new window width is {0}, and the new " - "window height is {1}."; - String^ m4 = " (Press any key to continue...)"; - - // - // Step 1: Get the current window dimensions. - // - origWidth = Console::WindowWidth; - origHeight = Console::WindowHeight; - Console::WriteLine( m1, Console::WindowWidth, Console::WindowHeight ); - Console::WriteLine( m4 ); - Console::ReadKey( true ); - - // - // Step 2: Cut the window to 1/4 its original size. - // - width = origWidth / 2; - height = origHeight / 2; - Console::SetWindowSize( width, height ); - Console::WriteLine( m2, Console::WindowWidth, Console::WindowHeight ); - Console::WriteLine( m4 ); - Console::ReadKey( true ); - - // - // Step 3: Restore the window to its original size. - // - Console::SetWindowSize( origWidth, origHeight ); - Console::WriteLine( m1, Console::WindowWidth, Console::WindowHeight ); -} - -/* -This example produces the following results: - -The current window width is 85, and the current window height is 43. - (Press any key to continue...) -The new window width is 42, and the new window height is 21. - (Press any key to continue...) -The current window width is 85, and the current window height is 43. - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/console.title/CPP/mytitle.cpp b/snippets/cpp/VS_Snippets_CLR/console.title/CPP/mytitle.cpp deleted file mode 100644 index 9fd1a51bc1b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/console.title/CPP/mytitle.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -// This example demonstrates the Console.Title property. -using namespace System; -int main() -{ - Console::WriteLine( "The current console title is: \"{0}\"", Console::Title ); - Console::WriteLine( " (Press any key to change the console title.)" ); - Console::ReadKey( true ); - Console::Title = "The title has changed!"; - Console::WriteLine( "Note that the new console title is \"{0}\"\n" - " (Press any key to quit.)", Console::Title ); - Console::ReadKey( true ); -} - -/* -This example produces the following results: - ->myTitle -The current console title is: "Command Prompt - myTitle" - (Press any key to change the console title.) -Note that the new console title is "The title has changed!" - (Press any key to quit.) - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/console.windowLT/CPP/wlt.cpp b/snippets/cpp/VS_Snippets_CLR/console.windowLT/CPP/wlt.cpp deleted file mode 100644 index cb5364bab15..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/console.windowLT/CPP/wlt.cpp +++ /dev/null @@ -1,135 +0,0 @@ - -// -// This example demonstrates the Console.WindowLeft and -// Console.WindowTop properties. -using namespace System; -using namespace System::Text; -using namespace System::IO; - -// -int saveBufferWidth; -int saveBufferHeight; -int saveWindowHeight; -int saveWindowWidth; -bool saveCursorVisible; - -// -int main() -{ - String^ m1 = "1) Press the cursor keys to move the console window.\n" - "2) Press any key to begin. When you're finished...\n" - "3) Press the Escape key to quit."; - String^ g1 = "+----"; - String^ g2 = "| "; - String^ grid1; - String^ grid2; - StringBuilder^ sbG1 = gcnew StringBuilder; - StringBuilder^ sbG2 = gcnew StringBuilder; - ConsoleKeyInfo cki; - int y; - - // - try - { - saveBufferWidth = Console::BufferWidth; - saveBufferHeight = Console::BufferHeight; - saveWindowHeight = Console::WindowHeight; - saveWindowWidth = Console::WindowWidth; - saveCursorVisible = Console::CursorVisible; - - // - Console::Clear(); - Console::WriteLine( m1 ); - Console::ReadKey( true ); - - // Set the smallest possible window size before setting the buffer size. - Console::SetWindowSize( 1, 1 ); - Console::SetBufferSize( 80, 80 ); - Console::SetWindowSize( 40, 20 ); - - // Create grid lines to fit the buffer. (The buffer width is 80, but - // this same technique could be used with an arbitrary buffer width.) - for ( y = 0; y < Console::BufferWidth / g1->Length; y++ ) - { - sbG1->Append( g1 ); - sbG2->Append( g2 ); - - } - sbG1->Append( g1, 0, Console::BufferWidth % g1->Length ); - sbG2->Append( g2, 0, Console::BufferWidth % g2->Length ); - grid1 = sbG1->ToString(); - grid2 = sbG2->ToString(); - Console::CursorVisible = false; - Console::Clear(); - for ( y = 0; y < Console::BufferHeight - 1; y++ ) - { - if ( y % 3 == 0 ) - Console::Write( grid1 ); - else - Console::Write( grid2 ); - - } - Console::SetWindowPosition( 0, 0 ); - do - { - cki = Console::ReadKey( true ); - switch ( cki.Key ) - { - case ConsoleKey::LeftArrow: - if ( Console::WindowLeft > 0 ) - Console::SetWindowPosition( Console::WindowLeft - 1, Console::WindowTop ); - break; - - case ConsoleKey::UpArrow: - if ( Console::WindowTop > 0 ) - Console::SetWindowPosition( Console::WindowLeft, Console::WindowTop - 1 ); - break; - - case ConsoleKey::RightArrow: - if ( Console::WindowLeft < (Console::BufferWidth - Console::WindowWidth) ) - Console::SetWindowPosition( Console::WindowLeft + 1, Console::WindowTop ); - break; - - case ConsoleKey::DownArrow: - if ( Console::WindowTop < (Console::BufferHeight - Console::WindowHeight) ) - Console::SetWindowPosition( Console::WindowLeft, Console::WindowTop + 1 ); - break; - } - } - while ( cki.Key != ConsoleKey::Escape ); - } - catch ( IOException^ e ) - { - Console::WriteLine( e->Message ); - } - finally - { - Console::Clear(); - Console::SetWindowSize( 1, 1 ); - Console::SetBufferSize( saveBufferWidth, saveBufferHeight ); - Console::SetWindowSize( saveWindowWidth, saveWindowHeight ); - Console::CursorVisible = saveCursorVisible; - } - -} // end Main - - -/* -This example produces results similar to the following: - -1) Press the cursor keys to move the console window. -2) Press any key to begin. When you're finished... -3) Press the Escape key to quit. - -... - -+----+----+----+- -| | | | -| | | | -+----+----+----+- -| | | | -| | | | -+----+----+----+- - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/console.writelineFmt1/cpp/wl.cpp b/snippets/cpp/VS_Snippets_CLR/console.writelineFmt1/cpp/wl.cpp deleted file mode 100644 index b31dd5edc66..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/console.writelineFmt1/cpp/wl.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// -// This code example demonstrates the Console.WriteLine() method. -// Formatting for this example uses the "en-US" culture. - -using namespace System; - -public enum class Color {Yellow = 1, Blue, Green}; - -int main() -{ - DateTime thisDate = DateTime::Now; - Console::Clear(); - - // Format a negative integer or floating-point number in various ways. - Console::WriteLine("Standard Numeric Format Specifiers"); - Console::WriteLine( - "(C) Currency: . . . . . . . . {0:C}\n" + - "(D) Decimal:. . . . . . . . . {0:D}\n" + - "(E) Scientific: . . . . . . . {1:E}\n" + - "(F) Fixed point:. . . . . . . {1:F}\n" + - "(G) General:. . . . . . . . . {0:G}\n" + - " (default):. . . . . . . . {0} (default = 'G')\n" + - "(N) Number: . . . . . . . . . {0:N}\n" + - "(P) Percent:. . . . . . . . . {1:P}\n" + - "(R) Round-trip: . . . . . . . {1:R}\n" + - "(X) Hexadecimal:. . . . . . . {0:X}\n", - -123, -123.45f); - - // Format the current date in various ways. - Console::WriteLine("Standard DateTime Format Specifiers"); - Console::WriteLine( - "(d) Short date: . . . . . . . {0:d}\n" + - "(D) Long date:. . . . . . . . {0:D}\n" + - "(t) Short time: . . . . . . . {0:t}\n" + - "(T) Long time:. . . . . . . . {0:T}\n" + - "(f) Full date/short time: . . {0:f}\n" + - "(F) Full date/long time:. . . {0:F}\n" + - "(g) General date/short time:. {0:g}\n" + - "(G) General date/long time: . {0:G}\n" + - " (default):. . . . . . . . {0} (default = 'G')\n" + - "(M) Month:. . . . . . . . . . {0:M}\n" + - "(R) RFC1123:. . . . . . . . . {0:R}\n" + - "(s) Sortable: . . . . . . . . {0:s}\n" + - "(u) Universal sortable: . . . {0:u} (invariant)\n" + - "(U) Universal full date/time: {0:U}\n" + - "(Y) Year: . . . . . . . . . . {0:Y}\n", - thisDate); - - // Format a Color enumeration value in various ways. - Console::WriteLine("Standard Enumeration Format Specifiers"); - Console::WriteLine( - "(G) General:. . . . . . . . . {0:G}\n" + - " (default):. . . . . . . . {0} (default = 'G')\n" + - "(F) Flags:. . . . . . . . . . {0:F} (flags or integer)\n" + - "(D) Decimal number: . . . . . {0:D}\n" + - "(X) Hexadecimal:. . . . . . . {0:X}\n", - Color::Green); - -}; - - -/* -This code example produces the following results: - -Standard Numeric Format Specifiers -(C) Currency: . . . . . . . . ($123.00) -(D) Decimal:. . . . . . . . . -123 -(E) Scientific: . . . . . . . -1.234500E+002 -(F) Fixed point:. . . . . . . -123.45 -(G) General:. . . . . . . . . -123 -(default):. . . . . . . . -123 (default = 'G') -(N) Number: . . . . . . . . . -123.00 -(P) Percent:. . . . . . . . . -12,345.00 % -(R) Round-trip: . . . . . . . -123.45 -(X) Hexadecimal:. . . . . . . FFFFFF85 - -Standard DateTime Format Specifiers -(d) Short date: . . . . . . . 6/26/2004 -(D) Long date:. . . . . . . . Saturday, June 26, 2004 -(t) Short time: . . . . . . . 8:11 PM -(T) Long time:. . . . . . . . 8:11:04 PM -(f) Full date/short time: . . Saturday, June 26, 2004 8:11 PM -(F) Full date/long time:. . . Saturday, June 26, 2004 8:11:04 PM -(g) General date/short time:. 6/26/2004 8:11 PM -(G) General date/long time: . 6/26/2004 8:11:04 PM -(default):. . . . . . . . 6/26/2004 8:11:04 PM (default = 'G') -(M) Month:. . . . . . . . . . June 26 -(R) RFC1123:. . . . . . . . . Sat, 26 Jun 2004 20:11:04 GMT -(s) Sortable: . . . . . . . . 2004-06-26T20:11:04 -(u) Universal sortable: . . . 2004-06-26 20:11:04Z (invariant) -(U) Universal full date/time: Sunday, June 27, 2004 3:11:04 AM -(Y) Year: . . . . . . . . . . June, 2004 - -Standard Enumeration Format Specifiers -(G) General:. . . . . . . . . Green -(default):. . . . . . . . Green (default = 'G') -(F) Flags:. . . . . . . . . . Green (flags or integer) -(D) Decimal number: . . . . . 3 -(X) Hexadecimal:. . . . . . . 00000003 - -*/ -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/consolein/CPP/consolein.cpp b/snippets/cpp/VS_Snippets_CLR/consolein/CPP/consolein.cpp deleted file mode 100644 index 528816ff13d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/consolein/CPP/consolein.cpp +++ /dev/null @@ -1,15 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -int main() -{ - TextReader^ tIn = Console::In; - TextWriter^ tOut = Console::Out; - tOut->WriteLine( "Hola Mundo!" ); - tOut->Write( "What is your name: " ); - String^ name = tIn->ReadLine(); - tOut->WriteLine( "Buenos Dias, {0}!", name ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/convert.tobase64chararray/CPP/tb64ca.cpp b/snippets/cpp/VS_Snippets_CLR/convert.tobase64chararray/CPP/tb64ca.cpp deleted file mode 100644 index a876518582c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/convert.tobase64chararray/CPP/tb64ca.cpp +++ /dev/null @@ -1,100 +0,0 @@ - -// -// This example demonstrates the Convert.ToBase64CharArray() and -// Convert.FromBase64CharArray methods -using namespace System; -bool ArraysAreEqual( array^a1, array^a2 ); -int main() -{ - array^byteArray1 = gcnew array(256); - array^byteArray2 = gcnew array(256); - array^charArray = gcnew array(352); - int charArrayLength; - String^ nl = Environment::NewLine; - String^ ruler1a = " 1 2 3 4"; - String^ ruler2a = "1234567890123456789012345678901234567890"; - String^ ruler3a = "----+----+----+----+----+----+----+----+"; - String^ ruler1b = " 5 6 7 "; - String^ ruler2b = "123456789012345678901234567890123456"; - String^ ruler3b = "----+----+----+----+----+----+----+-"; - String^ ruler = String::Concat( ruler1a, ruler1b, nl, ruler2a, ruler2b, nl, ruler3a, ruler3b ); - - // 1) Initialize and display a Byte array of arbitrary data. - Console::WriteLine( "1) Input: A Byte array of arbitrary data.{0}", nl ); - for ( int x = 0; x < byteArray1->Length; x++ ) - { - byteArray1[ x ] = (Byte)x; - Console::Write( "{0:X2} ", byteArray1[ x ] ); - if ( ((x + 1) % 20) == 0 ) - Console::WriteLine(); - - } - Console::Write( "{0}{0}", nl ); - - // 2) Convert the input Byte array to a Char array, with newlines inserted. - charArrayLength = Convert::ToBase64CharArray( byteArray1, 0, byteArray1->Length, - charArray, 0, - Base64FormattingOptions::InsertLineBreaks ); - Console::WriteLine( "2) Convert the input Byte array to a Char array with newlines." ); - Console::Write( " Output: A Char array (length = {0}). ", charArrayLength ); - Console::WriteLine( "The elements of the array are:{0}", nl ); - Console::WriteLine( ruler ); - Console::WriteLine( gcnew String( charArray ) ); - Console::WriteLine(); - - // 3) Convert the Char array back to a Byte array. - Console::WriteLine( "3) Convert the Char array to an output Byte array." ); - byteArray2 = Convert::FromBase64CharArray( charArray, 0, charArrayLength ); - - // 4) Are the input and output Byte arrays equivalent? - Console::WriteLine( "4) The output Byte array is equal to the input Byte array: {0}", ArraysAreEqual( byteArray1, byteArray2 ) ); -} - -bool ArraysAreEqual( array^a1, array^a2 ) -{ - if ( a1->Length != a2->Length ) - return false; - - for ( int i = 0; i < a1->Length; i++ ) - if ( a1[ i ] != a2[ i ] ) - return false; - - return true; -} - -/* -This example produces the following results: - -1) Input: A Byte array of arbitrary data. - -00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 -14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 -28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B -3C 3D 3E 3F 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F -50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 60 61 62 63 -64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 -78 79 7A 7B 7C 7D 7E 7F 80 81 82 83 84 85 86 87 88 89 8A 8B -8C 8D 8E 8F 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F -A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF B0 B1 B2 B3 -B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF C0 C1 C2 C3 C4 C5 C6 C7 -C8 C9 CA CB CC CD CE CF D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB -DC DD DE DF E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF -F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF - -2) Convert the input Byte array to a Char array with newlines. - Output: A Char array (length = 352). The elements of the array are: - - 1 2 3 4 5 6 7 -1234567890123456789012345678901234567890123456789012345678901234567890123456 -----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+- -AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4 -OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3Bx -cnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmq -q6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj -5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w== - -3) Convert the Char array to an output Byte array. -4) The output Byte array is equal to the input Byte array: True - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/convert.tobase64string/CPP/tb64s.cpp b/snippets/cpp/VS_Snippets_CLR/convert.tobase64string/CPP/tb64s.cpp deleted file mode 100644 index 316e8eeab95..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/convert.tobase64string/CPP/tb64s.cpp +++ /dev/null @@ -1,113 +0,0 @@ - -// -// This example demonstrates the Convert.ToBase64String() and -// Convert.FromBase64String() methods -using namespace System; -bool ArraysAreEqual( array^a1, array^a2 ); -int main() -{ - array^inArray = gcnew array(256); - array^outArray = gcnew array(256); - String^ s2; - String^ s3; - String^ step1 = "1) The input is a byte array (inArray) of arbitrary data."; - String^ step2 = "2) Convert a subarray of the input data array to a base 64 string."; - String^ step3 = "3) Convert the entire input data array to a base 64 string."; - String^ step4 = "4) The two methods in steps 2 and 3 produce the same result: {0}"; - String^ step5 = "5) Convert the base 64 string to an output byte array (outArray)."; - String^ step6 = "6) The input and output arrays, inArray and outArray, are equal: {0}"; - int x; - String^ nl = Environment::NewLine; - String^ ruler1a = " 1 2 3 4"; - String^ ruler2a = "1234567890123456789012345678901234567890"; - String^ ruler3a = "----+----+----+----+----+----+----+----+"; - String^ ruler1b = " 5 6 7 "; - String^ ruler2b = "123456789012345678901234567890123456"; - String^ ruler3b = "----+----+----+----+----+----+----+-"; - String^ ruler = String::Concat( ruler1a, ruler1b, nl, ruler2a, ruler2b, nl, ruler3a, ruler3b, nl ); - - // 1) Display an arbitrary array of input data (inArray). The data could be - // derived from user input, a file, an algorithm, etc. - Console::WriteLine( step1 ); - Console::WriteLine(); - for ( x = 0; x < inArray->Length; x++ ) - { - inArray[ x ] = (Byte)x; - Console::Write( "{0:X2} ", inArray[ x ] ); - if ( ((x + 1) % 20) == 0 ) - Console::WriteLine(); - - } - Console::Write( "{0}{0}", nl ); - - // 2) Convert a subarray of the input data to a base64 string. In this case, - // the subarray is the entire input data array. New lines (CRLF) are inserted. - Console::WriteLine( step2 ); - s2 = Convert::ToBase64String( inArray, 0, inArray->Length, Base64FormattingOptions::InsertLineBreaks ); - Console::WriteLine( "{0}{1}{2}{3}", nl, ruler, s2, nl ); - - // 3) Convert the input data to a base64 string. In this case, the entire - // input data array is converted by default. New lines (CRLF) are inserted. - Console::WriteLine( step3 ); - s3 = Convert::ToBase64String( inArray, Base64FormattingOptions::InsertLineBreaks ); - - // 4) Test whether the methods in steps 2 and 3 produce the same result. - Console::WriteLine( step4, s2->Equals( s3 ) ); - - // 5) Convert the base 64 string to an output array (outArray). - Console::WriteLine( step5 ); - outArray = Convert::FromBase64String( s2 ); - - // 6) Is outArray equal to inArray? - Console::WriteLine( step6, ArraysAreEqual( inArray, outArray ) ); -} - -bool ArraysAreEqual( array^a1, array^a2 ) -{ - if ( a1->Length != a2->Length ) - return false; - - for ( int i = 0; i < a1->Length; i++ ) - if ( a1[ i ] != a2[ i ] ) - return false; - - return true; -} - -/* -This example produces the following results: - -1) The input is a byte array (inArray) of arbitrary data. - -00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 -14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 -28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B -3C 3D 3E 3F 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F -50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 60 61 62 63 -64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 -78 79 7A 7B 7C 7D 7E 7F 80 81 82 83 84 85 86 87 88 89 8A 8B -8C 8D 8E 8F 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F -A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF B0 B1 B2 B3 -B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF C0 C1 C2 C3 C4 C5 C6 C7 -C8 C9 CA CB CC CD CE CF D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB -DC DD DE DF E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF -F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF - -2) Convert a subarray of the input data array to a base 64 string. - - 1 2 3 4 5 6 7 -1234567890123456789012345678901234567890123456789012345678901234567890123456 -----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+- -AAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaGxwdHh8gISIjJCUmJygpKissLS4vMDEyMzQ1Njc4 -OTo7PD0+P0BBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWltcXV5fYGFiY2RlZmdoaWprbG1ub3Bx -cnN0dXZ3eHl6e3x9fn+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanqKmq -q6ytrq+wsbKztLW2t7i5uru8vb6/wMHCw8TFxsfIycrLzM3Oz9DR0tPU1dbX2Nna29zd3t/g4eLj -5OXm5+jp6uvs7e7v8PHy8/T19vf4+fr7/P3+/w== - -3) Convert the entire input data array to a base 64 string. -4) The two methods in steps 2 and 3 produce the same result: True -5) Convert the base 64 string to an output byte array (outArray). -6) The input and output arrays, inArray and outArray, are equal: True - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/convertchangetype/CPP/convertchangetype.cpp b/snippets/cpp/VS_Snippets_CLR/convertchangetype/CPP/convertchangetype.cpp deleted file mode 100644 index 38f78b48eef..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/convertchangetype/CPP/convertchangetype.cpp +++ /dev/null @@ -1,14 +0,0 @@ - -// -using namespace System; - -int main() -{ - Double d = -2.345; - int i = *safe_cast(Convert::ChangeType( d, int::typeid )); - Console::WriteLine( "The double value {0} when converted to an int becomes {1}", d, i ); - String^ s = "12/12/98"; - DateTime dt = *safe_cast(Convert::ChangeType( s, DateTime::typeid )); - Console::WriteLine( "The string value {0} when converted to a Date becomes {1}", s, dt ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/datetime.ctor_Int64/CPP/ticks.cpp b/snippets/cpp/VS_Snippets_CLR/datetime.ctor_Int64/CPP/ticks.cpp deleted file mode 100644 index 1e507f938a2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/datetime.ctor_Int64/CPP/ticks.cpp +++ /dev/null @@ -1,39 +0,0 @@ - -// -// This example demonstrates the DateTime(Int64) constructor. -using namespace System; -using namespace System::Globalization; -int main() -{ - - // Instead of using the implicit, default "G" date and time format string, we - // use a custom format string that aligns the results and inserts leading zeroes. - String^ format = "{0}) The {1} date and time is {2:MM/dd/yyyy hh:mm:ss tt}"; - - // Create a DateTime for the maximum date and time using ticks. - DateTime dt1 = DateTime(DateTime::MaxValue.Ticks); - - // Create a DateTime for the minimum date and time using ticks. - DateTime dt2 = DateTime(DateTime::MinValue.Ticks); - - // Create a custom DateTime for 7/28/1979 at 10:35:05 PM using a - // calendar based on the "en-US" culture, and ticks. - Int64 ticks = DateTime(1979,07,28,22,35,5,(gcnew CultureInfo( "en-US",false ))->Calendar).Ticks; - DateTime dt3 = DateTime(ticks); - Console::WriteLine( format, 1, "maximum", dt1 ); - Console::WriteLine( format, 2, "minimum", dt2 ); - Console::WriteLine( format, 3, "custom ", dt3 ); - Console::WriteLine( "\nThe custom date and time is created from {0:N0} ticks.", ticks ); -} - -/* -This example produces the following results: - -1) The maximum date and time is 12/31/9999 11:59:59 PM -2) The minimum date and time is 01/01/0001 12:00:00 AM -3) The custom date and time is 07/28/1979 10:35:05 PM - -The custom date and time is created from 624,376,461,050,000,000 ticks. - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/enum.tostring/CPP/tostr.cpp b/snippets/cpp/VS_Snippets_CLR/enum.tostring/CPP/tostr.cpp deleted file mode 100644 index a798bc4a24c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/enum.tostring/CPP/tostr.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// -// Sample for Enum::ToString(String) - -using namespace System; - -public enum class Colors -{ - Red, Green, Blue, Yellow = 12 -}; - -int main() -{ - Colors myColor = Colors::Yellow; - Console::WriteLine( "Colors::Red = {0}", Colors::Red.ToString( "d" ) ); - Console::WriteLine( "Colors::Green = {0}", Colors::Green.ToString( "d" ) ); - Console::WriteLine( "Colors::Blue = {0}", Colors::Blue.ToString( "d" ) ); - Console::WriteLine( "Colors::Yellow = {0}", Colors::Yellow.ToString( "d" ) ); - Console::WriteLine( " {0}myColor = Colors::Yellow {0}", Environment::NewLine ); - Console::WriteLine( "myColor->ToString(\"g\") = {0}", myColor.ToString( "g" ) ); - Console::WriteLine( "myColor->ToString(\"G\") = {0}", myColor.ToString( "G" ) ); - Console::WriteLine( "myColor->ToString(\"x\") = {0}", myColor.ToString( "x" ) ); - Console::WriteLine( "myColor->ToString(\"X\") = {0}", myColor.ToString( "X" ) ); - Console::WriteLine( "myColor->ToString(\"d\") = {0}", myColor.ToString( "d" ) ); - Console::WriteLine( "myColor->ToString(\"D\") = {0}", myColor.ToString( "D" ) ); - Console::WriteLine( "myColor->ToString(\"f\") = {0}", myColor.ToString( "f" ) ); - Console::WriteLine( "myColor->ToString(\"F\") = {0}", myColor.ToString( "F" ) ); -} - -/* -This example produces the following results: -Colors::Red = 0 -Colors::Green = 1 -Colors::Blue = 2 -Colors::Yellow = 12 - -myColor = Colors::Yellow - -myColor->ToString("g") = Yellow -myColor->ToString("G") = Yellow -myColor->ToString("x") = 0000000C -myColor->ToString("X") = 0000000C -myColor->ToString("d") = 12 -myColor->ToString("D") = 12 -myColor->ToString("f") = Yellow -myColor->ToString("F") = Yellow -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/enumcompareto/CPP/EnumCompareTo.cpp b/snippets/cpp/VS_Snippets_CLR/enumcompareto/CPP/EnumCompareTo.cpp deleted file mode 100644 index 8d067455708..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/enumcompareto/CPP/EnumCompareTo.cpp +++ /dev/null @@ -1,31 +0,0 @@ - -// -using namespace System; - -public enum class VehicleDoors -{ - Motorbike = 0, - Sportscar = 2, - Sedan = 4, - Hatchback = 5 -}; - -int main() -{ - VehicleDoors myVeh = VehicleDoors::Sportscar; - VehicleDoors yourVeh = VehicleDoors::Motorbike; - VehicleDoors otherVeh = VehicleDoors::Sedan; - Console::WriteLine( "Does a {0} have more doors than a {1}?", myVeh, yourVeh ); - Int32 iRes = myVeh.CompareTo( yourVeh ); - Console::WriteLine( "{0}{1}", iRes > 0 ? (String^)"Yes" : "No", Environment::NewLine ); - Console::WriteLine( "Does a {0} have more doors than a {1}?", myVeh, otherVeh ); - iRes = myVeh.CompareTo( otherVeh ); - Console::WriteLine( "{0}", iRes > 0 ? (String^)"Yes" : "No" ); -} -// The example displays the following output: -// Does a Sportscar have more doors than a Motorbike? -// Yes -// -// Does a Sportscar have more doors than a Sedan? -// No -// diff --git a/snippets/cpp/VS_Snippets_CLR/enumequals/CPP/EnumEquals.cpp b/snippets/cpp/VS_Snippets_CLR/enumequals/CPP/EnumEquals.cpp deleted file mode 100644 index 2c8b0fb26db..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/enumequals/CPP/EnumEquals.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// -using namespace System; -public enum class Colors -{ - Red, Green, Blue, Yellow -}; - -public enum class Mammals -{ - Cat, Dog, Horse, Dolphin -}; - -int main() -{ - Mammals myPet = Mammals::Cat; - Colors myColor = Colors::Red; - Mammals yourPet = Mammals::Dog; - Colors yourColor = Colors::Red; - Console::WriteLine( "My favorite animal is a {0}", myPet ); - Console::WriteLine( "Your favorite animal is a {0}", yourPet ); - Console::WriteLine( "Do we like the same animal? {0}", myPet.Equals( yourPet ) ? (String^)"Yes" : "No" ); - Console::WriteLine(); - Console::WriteLine( "My favorite color is {0}", myColor ); - Console::WriteLine( "Your favorite color is {0}", yourColor ); - Console::WriteLine( "Do we like the same color? {0}", myColor.Equals( yourColor ) ? (String^)"Yes" : "No" ); - Console::WriteLine(); - Console::WriteLine( "The value of my color ({0}) is {1}", myColor, Enum::Format( Colors::typeid, myColor, "d" ) ); - Console::WriteLine( "The value of my pet (a {0}) is {1}", myPet, Enum::Format( Mammals::typeid, myPet, "d" ) ); - Console::WriteLine( "Even though they have the same value, are they equal? {0}", myColor.Equals( myPet ) ? (String^)"Yes" : "No" ); -} -// The example displays the following output: -// My favorite animal is a Cat -// Your favorite animal is a Dog -// Do we like the same animal? No -// -// My favorite color is Red -// Your favorite color is Red -// Do we like the same color? Yes -// -// The value of my color (Red) is 0 -// The value of my pet (a Cat) is 0 -// Even though they have the same value, are they equal? No -// diff --git a/snippets/cpp/VS_Snippets_CLR/enumformat/CPP/EnumFormat.cpp b/snippets/cpp/VS_Snippets_CLR/enumformat/CPP/EnumFormat.cpp deleted file mode 100644 index 1176bcd60d1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/enumformat/CPP/EnumFormat.cpp +++ /dev/null @@ -1,20 +0,0 @@ - -// -using namespace System; -public enum class Colors -{ - Red, Green, Blue, Yellow -}; - -int main() -{ - Colors myColor = Colors::Blue; - Console::WriteLine( "My favorite color is {0}.", myColor ); - Console::WriteLine( "The value of my favorite color is {0}.", Enum::Format( Colors::typeid, myColor, "d" ) ); - Console::WriteLine( "The hex value of my favorite color is {0}.", Enum::Format( Colors::typeid, myColor, "x" ) ); -} -// The example displays the folowing output: -// My favorite color is Blue. -// The value of my favorite color is 2. -// The hex value of my favorite color is 00000002. -// diff --git a/snippets/cpp/VS_Snippets_CLR/enumgetname/CPP/EnumGetName.cpp b/snippets/cpp/VS_Snippets_CLR/enumgetname/CPP/EnumGetName.cpp deleted file mode 100644 index f5f08936cf6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/enumgetname/CPP/EnumGetName.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// -using namespace System; - -enum class Colors -{ - Red, Green, Blue, Yellow -}; - -enum class Styles -{ - Plaid, Striped, Tartan, Corduroy -}; - -int main() -{ - Console::WriteLine( "The 4th value of the Colors Enum is {0}", Enum::GetName( Colors::typeid, 3 ) ); - Console::WriteLine( "The 4th value of the Styles Enum is {0}", Enum::GetName( Styles::typeid, 3 ) ); -} -// The example displays the following output: -// The 4th value of the Colors Enum is Yellow -// The 4th value of the Styles Enum is Corduroy -// diff --git a/snippets/cpp/VS_Snippets_CLR/enumgetnames/CPP/EnumGetNames.cpp b/snippets/cpp/VS_Snippets_CLR/enumgetnames/CPP/EnumGetNames.cpp deleted file mode 100644 index 5c01de3f879..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/enumgetnames/CPP/EnumGetNames.cpp +++ /dev/null @@ -1,49 +0,0 @@ - -// -using namespace System; -enum class Colors -{ - Red, Green, Blue, Yellow -}; - -enum class Styles -{ - Plaid, Striped, Tartan, Corduroy -}; - -int main() -{ - Console::WriteLine( "The members of the Colors enum are:" ); - Array^ a = Enum::GetNames( Colors::typeid ); - Int32 i = 0; - do - { - Object^ o = a->GetValue( i ); - Console::WriteLine( o->ToString() ); - } - while ( ++i < a->Length ); - - Console::WriteLine(); - Console::WriteLine( "The members of the Styles enum are:" ); - Array^ b = Enum::GetNames( Styles::typeid ); - i = 0; - do - { - Object^ o = b->GetValue( i ); - Console::WriteLine( o->ToString() ); - } - while ( ++i < b->Length ); -} -// The example displays the following output: -// The members of the Colors enum are: -// Red -// Green -// Blue -// Yellow -// -// The members of the Styles enum are: -// Plaid -// Striped -// Tartan -// Corduroy -// diff --git a/snippets/cpp/VS_Snippets_CLR/enumgetvalues/CPP/EnumGetValues.cpp b/snippets/cpp/VS_Snippets_CLR/enumgetvalues/CPP/EnumGetValues.cpp deleted file mode 100644 index 69416cafd99..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/enumgetvalues/CPP/EnumGetValues.cpp +++ /dev/null @@ -1,48 +0,0 @@ - -// -using namespace System; -enum class Colors -{ - Red, Green, Blue, Yellow -}; - -enum class Styles -{ - Plaid = 0, - Striped = 23, - Tartan = 65, - Corduroy = 78 -}; - -int main() -{ - Console::WriteLine( "The values of the Colors Enum are:" ); - Array^ a = Enum::GetValues( Colors::typeid ); - for ( Int32 i = 0; i < a->Length; i++ ) - { - Object^ o = a->GetValue( i ); - Console::WriteLine( "{0}", Enum::Format( Colors::typeid, o, "D" ) ); - } - Console::WriteLine(); - Console::WriteLine( "The values of the Styles Enum are:" ); - Array^ b = Enum::GetValues( Styles::typeid ); - for ( Int32 i = 0; i < b->Length; i++ ) - { - Object^ o = b->GetValue( i ); - Console::WriteLine( "{0}", Enum::Format( Styles::typeid, o, "D" ) ); - - } -} -// The example produces the following output: -// The values of the Colors Enum are: -// 0 -// 1 -// 2 -// 3 -// -// The values of the Styles Enum are: -// 0 -// 23 -// 65 -// 78 -// diff --git a/snippets/cpp/VS_Snippets_CLR/enumparse/CPP/EnumParse.cpp b/snippets/cpp/VS_Snippets_CLR/enumparse/CPP/EnumParse.cpp deleted file mode 100644 index a5fc6c7c51d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/enumparse/CPP/EnumParse.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// -using namespace System; - -[Flags] -enum class Colors -{ - Red = 1, - Green = 2, - Blue = 4, - Yellow = 8 -}; - -int main() -{ - Console::WriteLine( "The entries of the Colors enumeration are:" ); - Array^ a = Enum::GetNames( Colors::typeid ); - Int32 i = 0; - while ( i < a->Length ) - { - Object^ o = a->GetValue( i ); - Console::WriteLine( o->ToString() ); - i++; - } - - Console::WriteLine(); - Object^ orange = Enum::Parse( Colors::typeid, "Red, Yellow" ); - Console::WriteLine("The orange value has the combined entries of {0}", orange ); -} - -/* -This code example produces the following results: - -The entries of the Colors Enum are: -Red -Green -Blue -Yellow - -The orange value has the combined entries of Red, Yellow - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/environment.CommandLine/CPP/commandline.cpp b/snippets/cpp/VS_Snippets_CLR/environment.CommandLine/CPP/commandline.cpp deleted file mode 100644 index d8cae622055..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/environment.CommandLine/CPP/commandline.cpp +++ /dev/null @@ -1,19 +0,0 @@ - -// -using namespace System; - -int main() -{ - Console::WriteLine(); - - // Invoke this sample with an arbitrary set of command line arguments. - Console::WriteLine( "CommandLine: {0}", Environment::CommandLine ); -} -/* -The example displays output like the following: - -C:\>env0 ARBITRARY TEXT - -CommandLine: env0 ARBITRARY TEXT -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/environment.ExpandEnvironmentVariables/CPP/expandenvironmentvariables.cpp b/snippets/cpp/VS_Snippets_CLR/environment.ExpandEnvironmentVariables/CPP/expandenvironmentvariables.cpp deleted file mode 100644 index 8da45abecdb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/environment.ExpandEnvironmentVariables/CPP/expandenvironmentvariables.cpp +++ /dev/null @@ -1,23 +0,0 @@ - -// -// Sample for the Environment::ExpandEnvironmentVariables method -using namespace System; -int main() -{ - String^ str; - String^ nl = Environment::NewLine; - Console::WriteLine(); - - // <-- Keep this information secure! --> - String^ query = "My system drive is %SystemDrive% and my system root is %SystemRoot%"; - str = Environment::ExpandEnvironmentVariables( query ); - Console::WriteLine( "ExpandEnvironmentVariables: {0} {1}", nl, str ); -} - -/* -This example produces the following results: - -ExpandEnvironmentVariables: -My system drive is C: and my system root is C:\WINNT -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/environment.class/CPP/env0.cpp b/snippets/cpp/VS_Snippets_CLR/environment.class/CPP/env0.cpp deleted file mode 100644 index 3da3cc965d5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/environment.class/CPP/env0.cpp +++ /dev/null @@ -1,104 +0,0 @@ - -// -// Sample for Environment class summary -using namespace System; -using namespace System::Collections; -int main() -{ - String^ str; - String^ nl = Environment::NewLine; - - // - Console::WriteLine(); - Console::WriteLine( "-- Environment members --" ); - - // Invoke this sample with an arbitrary set of command line arguments. - Console::WriteLine( "CommandLine: {0}", Environment::CommandLine ); - array^arguments = Environment::GetCommandLineArgs(); - Console::WriteLine( "GetCommandLineArgs: {0}", String::Join( ", ", arguments ) ); - - // <-- Keep this information secure! --> - Console::WriteLine( "CurrentDirectory: {0}", Environment::CurrentDirectory ); - Console::WriteLine( "ExitCode: {0}", Environment::ExitCode ); - Console::WriteLine( "HasShutdownStarted: {0}", Environment::HasShutdownStarted ); - - // <-- Keep this information secure! --> - Console::WriteLine( "MachineName: {0}", Environment::MachineName ); - Console::WriteLine( "NewLine: {0} first line {0} second line {0} third line", Environment::NewLine ); - Console::WriteLine( "OSVersion: {0}", Environment::OSVersion ); - Console::WriteLine( "StackTrace: ' {0}'", Environment::StackTrace ); - - // <-- Keep this information secure! --> - Console::WriteLine( "SystemDirectory: {0}", Environment::SystemDirectory ); - Console::WriteLine( "TickCount: {0}", Environment::TickCount ); - - // <-- Keep this information secure! --> - Console::WriteLine( "UserDomainName: {0}", Environment::UserDomainName ); - Console::WriteLine( "UserInteractive: {0}", Environment::UserInteractive ); - - // <-- Keep this information secure! --> - Console::WriteLine( "UserName: {0}", Environment::UserName ); - Console::WriteLine( "Version: {0}", Environment::Version ); - Console::WriteLine( "WorkingSet: {0}", Environment::WorkingSet ); - - // No example for Exit(exitCode) because doing so would terminate this example. - // <-- Keep this information secure! --> - String^ query = "My system drive is %SystemDrive% and my system root is %SystemRoot%"; - str = Environment::ExpandEnvironmentVariables( query ); - Console::WriteLine( "ExpandEnvironmentVariables: {0} {1}", nl, str ); - Console::WriteLine( "GetEnvironmentVariable: {0} My temporary directory is {1}.", nl, Environment::GetEnvironmentVariable( "TEMP" ) ); - Console::WriteLine( "GetEnvironmentVariables: " ); - IDictionary^ environmentVariables = Environment::GetEnvironmentVariables(); - IEnumerator^ myEnum = environmentVariables->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DictionaryEntry^ de = safe_cast(myEnum->Current); - Console::WriteLine( " {0} = {1}", de->Key, de->Value ); - } - - Console::WriteLine( "GetFolderPath: {0}", Environment::GetFolderPath( Environment::SpecialFolder::System ) ); - array^drives = Environment::GetLogicalDrives(); - Console::WriteLine( "GetLogicalDrives: {0}", String::Join( ", ", drives ) ); -} - -/* -This example produces results similar to the following: -(Any result that is lengthy or reveals information that should remain -secure has been omitted and marked S"!---OMITTED---!".) - -C:\>env0 ARBITRARY TEXT - --- Environment members -- -CommandLine: env0 ARBITRARY TEXT -GetCommandLineArgs: env0, ARBITRARY, TEXT -CurrentDirectory: C:\Documents and Settings\!---OMITTED---! -ExitCode: 0 -HasShutdownStarted: False -MachineName: !---OMITTED---! -NewLine: - first line - second line - third line -OSVersion: Microsoft Windows NT 5.1.2600.0 -StackTrace: ' at System::Environment::GetStackTrace(Exception e) - at System::Environment::GetStackTrace(Exception e) - at System::Environment::get_StackTrace() - at Sample::Main()' -SystemDirectory: C:\WINNT\System32 -TickCount: 17995355 -UserDomainName: !---OMITTED---! -UserInteractive: True -UserName: !---OMITTED---! -Version: !---OMITTED---! -WorkingSet: 5038080 -ExpandEnvironmentVariables: - My system drive is C: and my system root is C:\WINNT -GetEnvironmentVariable: - My temporary directory is C:\DOCUME~1\!---OMITTED---!\LOCALS~1\Temp. -GetEnvironmentVariables: - !---OMITTED---! -GetFolderPath: C:\WINNT\System32 -GetLogicalDrives: A:\, C:\, D:\ - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/environment.processorcount/CPP/pc.cpp b/snippets/cpp/VS_Snippets_CLR/environment.processorcount/CPP/pc.cpp deleted file mode 100644 index 8a06d998c6d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/environment.processorcount/CPP/pc.cpp +++ /dev/null @@ -1,16 +0,0 @@ - -// -// This example demonstrates the -// Environment.ProcessorCount property. -using namespace System; -int main() -{ - Console::WriteLine( "The number of processors on this computer is {0}.", Environment::ProcessorCount ); -} - -/* -This example produces the following results: - -The number of processors on this computer is 1. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/eventsoverview/cpp/programwithdata.cpp b/snippets/cpp/VS_Snippets_CLR/eventsoverview/cpp/programwithdata.cpp deleted file mode 100644 index d1bc63b6472..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/eventsoverview/cpp/programwithdata.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// -using namespace System; - -public ref class ThresholdReachedEventArgs : public EventArgs -{ - public: - property int Threshold; - property DateTime TimeReached; -}; - -public ref class Counter -{ - private: - int threshold; - int total; - - public: - Counter() {}; - - Counter(int passedThreshold) - { - threshold = passedThreshold; - } - - void Add(int x) - { - total += x; - if (total >= threshold) { - ThresholdReachedEventArgs^ args = gcnew ThresholdReachedEventArgs(); - args->Threshold = threshold; - args->TimeReached = DateTime::Now; - OnThresholdReached(args); - } - } - - event EventHandler^ ThresholdReached; - - protected: - virtual void OnThresholdReached(ThresholdReachedEventArgs^ e) - { - ThresholdReached(this, e); - } -}; - -public ref class SampleHandler -{ - public: - static void c_ThresholdReached(Object^ sender, ThresholdReachedEventArgs^ e) - { - Console::WriteLine("The threshold of {0} was reached at {1}.", - e->Threshold, e->TimeReached); - Environment::Exit(0); - } -}; - -void main() -{ - Counter^ c = gcnew Counter((gcnew Random())->Next(10)); - c->ThresholdReached += gcnew EventHandler(SampleHandler::c_ThresholdReached); - - Console::WriteLine("press 'a' key to increase total"); - while (Console::ReadKey(true).KeyChar == 'a') { - Console::WriteLine("adding one"); - c->Add(1); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/exception.data/CPP/data.cpp b/snippets/cpp/VS_Snippets_CLR/exception.data/CPP/data.cpp deleted file mode 100644 index 57b3be51deb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/exception.data/CPP/data.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// -using namespace System; -using namespace System::Collections; - -void NestedRunTest( bool displayDetails ); // forward declarations -void NestedRoutine1( bool displayDetails ); -void NestedRoutine2( bool displayDetails ); -void RunTest( bool displayDetails ); - -int main() -{ - Console::WriteLine("\nException with some extra information..." ); - RunTest(false); - Console::WriteLine("\nException with all extra information..." ); - RunTest(true); -} - -void RunTest( bool displayDetails ) -{ - try - { - NestedRoutine1( displayDetails ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "An exception was thrown." ); - Console::WriteLine( e->Message ); - if ( e->Data != nullptr ) - { - Console::WriteLine( " Extra details:" ); - - for each (DictionaryEntry de in e->Data) - Console::WriteLine(" Key: {0,-20} Value: {1}", - "'" + de.Key->ToString() + "'", de.Value); - } - } -} - -void NestedRoutine1( bool displayDetails ) -{ - try - { - NestedRoutine2( displayDetails ); - } - catch ( Exception^ e ) - { - e->Data[ "ExtraInfo" ] = "Information from NestedRoutine1."; - e->Data->Add( "MoreExtraInfo", "More information from NestedRoutine1." ); - throw; - } -} - -void NestedRoutine2( bool displayDetails ) -{ - Exception^ e = gcnew Exception( "This statement is the original exception message." ); - if ( displayDetails ) - { - String^ s = "Information from NestedRoutine2."; - int i = -903; - DateTime dt = DateTime::Now; - e->Data->Add( "stringInfo", s ); - e->Data[ "IntInfo" ] = i; - e->Data[ "DateTimeInfo" ] = dt; - } - - throw e; -} - -/* -This example produces the following results: - -Exception with some extra information... -An exception was thrown. -This statement is the original exception message. - Extra details: - The key is 'ExtraInfo' and the value is: Information from NestedRoutine1. - The key is 'MoreExtraInfo' and the value is: More information from NestedRoutine1. - -Exception with all extra information... -An exception was thrown. -This statement is the original exception message. - Extra details: - The key is 'stringInfo' and the value is: Information from NestedRoutine2. - The key is 'IntInfo' and the value is: -903 - The key is 'DateTimeInfo' and the value is: 11/26/2002 2:12:58 PM - The key is 'ExtraInfo' and the value is: Information from NestedRoutine1. - The key is 'MoreExtraInfo' and the value is: More information from NestedRoutine1. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/math.atanx/CPP/atan.cpp b/snippets/cpp/VS_Snippets_CLR/math.atanx/CPP/atan.cpp deleted file mode 100644 index 66e8c71ecbd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/math.atanx/CPP/atan.cpp +++ /dev/null @@ -1,47 +0,0 @@ - -// -// This example demonstrates Math.Atan() -// Math.Atan2() -// Math.Tan() -using namespace System; -int main() -{ - double x = 1.0; - double y = 2.0; - double angle; - double radians; - double result; - - // Calculate the tangent of 30 degrees. - angle = 30; - radians = angle * (Math::PI / 180); - result = Math::Tan( radians ); - Console::WriteLine( "The tangent of 30 degrees is {0}.", result ); - - // Calculate the arctangent of the previous tangent. - radians = Math::Atan( result ); - angle = radians * (180 / Math::PI); - Console::WriteLine( "The previous tangent is equivalent to {0} degrees.", angle ); - - // Calculate the arctangent of an angle. - String^ line1 = "{0}The arctangent of the angle formed by the x-axis and "; - String^ line2 = "a vector to point ({0},{1}) is {2}, "; - String^ line3 = "which is equivalent to {0} degrees."; - radians = Math::Atan2( y, x ); - angle = radians * (180 / Math::PI); - Console::WriteLine( line1, Environment::NewLine ); - Console::WriteLine( line2, x, y, radians ); - Console::WriteLine( line3, angle ); -} - -/* -This example produces the following results: - -The tangent of 30 degrees is 0.577350269189626. -The previous tangent is equivalent to 30 degrees. - -The arctangent of the angle formed by the x-axis and -a vector to point (1,2) is 1.10714871779409, -which is equivalent to 63.434948822922 degrees. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/math.bigmul/CPP/bigmul.cpp b/snippets/cpp/VS_Snippets_CLR/math.bigmul/CPP/bigmul.cpp deleted file mode 100644 index ce21aac3d31..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/math.bigmul/CPP/bigmul.cpp +++ /dev/null @@ -1,22 +0,0 @@ - -// -// This example demonstrates Math.BigMul() -using namespace System; -int main() -{ - int int1 = Int32::MaxValue; - int int2 = Int32::MaxValue; - Int64 longResult; - - // - longResult = Math::BigMul( int1, int2 ); - Console::WriteLine( "Calculate the product of two Int32 values:" ); - Console::WriteLine( "{0} * {1} = {2}", int1, int2, longResult ); -} - -/* -This example produces the following results: -Calculate the product of two Int32 values: -2147483647 * 2147483647 = 4611686014132420609 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/math.max/CPP/max.cpp b/snippets/cpp/VS_Snippets_CLR/math.max/CPP/max.cpp deleted file mode 100644 index 30f8d543207..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/math.max/CPP/max.cpp +++ /dev/null @@ -1,59 +0,0 @@ - -// -// This example demonstrates Math.Max() -using namespace System; -int main() -{ - String^ str = "{0}: The greater of {1,3} and {2,3} is {3}."; - String^ nl = Environment::NewLine; - Byte xByte1 = 1,xByte2 = 51; - short xShort1 = -2,xShort2 = 52; - int xInt1 = -3,xInt2 = 53; - long xLong1 = -4,xLong2 = 54; - float xSingle1 = 5.0f,xSingle2 = 55.0f; - double xDouble1 = 6.0,xDouble2 = 56.0; - Decimal xDecimal1 = 7,xDecimal2 = 57; - - // The following types are not CLS-compliant. - SByte xSbyte1 = 101,xSbyte2 = 111; - UInt16 xUshort1 = 102,xUshort2 = 112; - UInt32 xUint1 = 103,xUint2 = 113; - UInt64 xUlong1 = 104,xUlong2 = 114; - Console::WriteLine( "{0}Display the greater of two values:{0}", nl ); - Console::WriteLine( str, "Byte ", xByte1, xByte2, Math::Max( xByte1, xByte2 ) ); - Console::WriteLine( str, "Int16 ", xShort1, xShort2, Math::Max( xShort1, xShort2 ) ); - Console::WriteLine( str, "Int32 ", xInt1, xInt2, Math::Max( xInt1, xInt2 ) ); - Console::WriteLine( str, "Int64 ", xLong1, xLong2, Math::Max( xLong1, xLong2 ) ); - Console::WriteLine( str, "Single ", xSingle1, xSingle2, Math::Max( xSingle1, xSingle2 ) ); - Console::WriteLine( str, "Double ", xDouble1, xDouble2, Math::Max( xDouble1, xDouble2 ) ); - Console::WriteLine( str, "Decimal", xDecimal1, xDecimal2, Math::Max( xDecimal1, xDecimal2 ) ); - - // - Console::WriteLine( "{0}The following types are not CLS-compliant.{0}", nl ); - Console::WriteLine( str, "SByte ", xSbyte1, xSbyte2, Math::Max( xSbyte1, xSbyte2 ) ); - Console::WriteLine( str, "UInt16 ", xUshort1, xUshort2, Math::Max( xUshort1, xUshort2 ) ); - Console::WriteLine( str, "UInt32 ", xUint1, xUint2, Math::Max( xUint1, xUint2 ) ); - Console::WriteLine( str, "UInt64 ", xUlong1, xUlong2, Math::Max( xUlong1, xUlong2 ) ); -} - -/* -This example produces the following results: - -Display the greater of two values: - -Byte : The greater of 1 and 51 is 51. -Int16 : The greater of -2 and 52 is 52. -Int32 : The greater of -3 and 53 is 53. -Int64 : The greater of -4 and 54 is 54. -Single : The greater of 5 and 55 is 55. -Double : The greater of 6 and 56 is 56. -Decimal: The greater of 7 and 57 is 57. - -(The following types are not CLS-compliant.) - -SByte : The greater of 101 and 111 is 111. -UInt16 : The greater of 102 and 112 is 112. -UInt32 : The greater of 103 and 113 is 113. -UInt64 : The greater of 104 and 114 is 114. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/math.min/CPP/min.cpp b/snippets/cpp/VS_Snippets_CLR/math.min/CPP/min.cpp deleted file mode 100644 index fe4036cee2d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/math.min/CPP/min.cpp +++ /dev/null @@ -1,59 +0,0 @@ - -// -// This example demonstrates Math.Min() -using namespace System; -int main() -{ - String^ str = "{0}: The lesser of {1,3} and {2,3} is {3}."; - String^ nl = Environment::NewLine; - Byte xByte1 = 1,xByte2 = 51; - short xShort1 = -2,xShort2 = 52; - int xInt1 = -3,xInt2 = 53; - long xLong1 = -4,xLong2 = 54; - float xSingle1 = 5.0f,xSingle2 = 55.0f; - double xDouble1 = 6.0,xDouble2 = 56.0; - Decimal xDecimal1 = 7,xDecimal2 = 57; - - // The following types are not CLS-compliant. - SByte xSbyte1 = 101,xSbyte2 = 111; - UInt16 xUshort1 = 102,xUshort2 = 112; - UInt32 xUint1 = 103,xUint2 = 113; - UInt64 xUlong1 = 104,xUlong2 = 114; - Console::WriteLine( "{0}Display the lesser of two values:{0}", nl ); - Console::WriteLine( str, "Byte ", xByte1, xByte2, Math::Min( xByte1, xByte2 ) ); - Console::WriteLine( str, "Int16 ", xShort1, xShort2, Math::Min( xShort1, xShort2 ) ); - Console::WriteLine( str, "Int32 ", xInt1, xInt2, Math::Min( xInt1, xInt2 ) ); - Console::WriteLine( str, "Int64 ", xLong1, xLong2, Math::Min( xLong1, xLong2 ) ); - Console::WriteLine( str, "Single ", xSingle1, xSingle2, Math::Min( xSingle1, xSingle2 ) ); - Console::WriteLine( str, "Double ", xDouble1, xDouble2, Math::Min( xDouble1, xDouble2 ) ); - Console::WriteLine( str, "Decimal", xDecimal1, xDecimal2, Math::Min( xDecimal1, xDecimal2 ) ); - - // - Console::WriteLine( "{0}The following types are not CLS-compliant:{0}", nl ); - Console::WriteLine( str, "SByte ", xSbyte1, xSbyte2, Math::Min( xSbyte1, xSbyte2 ) ); - Console::WriteLine( str, "UInt16 ", xUshort1, xUshort2, Math::Min( xUshort1, xUshort2 ) ); - Console::WriteLine( str, "UInt32 ", xUint1, xUint2, Math::Min( xUint1, xUint2 ) ); - Console::WriteLine( str, "UInt64 ", xUlong1, xUlong2, Math::Min( xUlong1, xUlong2 ) ); -} - -/* -This example produces the following results: - -Display the lesser of two values: - -Byte : The lesser of 1 and 51 is 1. -Int16 : The lesser of -2 and 52 is -2. -Int32 : The lesser of -3 and 53 is -3. -Int64 : The lesser of -4 and 54 is -4. -Single : The lesser of 5 and 55 is 5. -Double : The lesser of 6 and 56 is 6. -Decimal: The lesser of 7 and 57 is 7. - -The following types are not CLS-compliant: - -SByte : The lesser of 101 and 111 is 101. -UInt16 : The lesser of 102 and 112 is 102. -UInt32 : The lesser of 103 and 113 is 103. -UInt64 : The lesser of 104 and 114 is 104. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/math.sign/CPP/sign.cpp b/snippets/cpp/VS_Snippets_CLR/math.sign/CPP/sign.cpp deleted file mode 100644 index 200dda534ac..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/math.sign/CPP/sign.cpp +++ /dev/null @@ -1,59 +0,0 @@ - -// -// This example demonstrates Math.Sign() -using namespace System; -String^ Test( int compare ) -{ - if ( compare == 0 ) - return "equal to"; - else - if ( compare < 0 ) - return "less than"; - else - return "greater than"; -} - -int main() -{ - String^ str = "{0}: {1,3} is {2} zero."; - String^ nl = Environment::NewLine; - Byte xByte1 = 0; - short xShort1 = -2; - int xInt1 = -3; - long xLong1 = -4; - float xSingle1 = 0.0f; - double xDouble1 = 6.0; - Decimal xDecimal1 = -7; - - // The following type is not CLS-compliant. - SByte xSbyte1 = -101; - Console::WriteLine( "{0}Test the sign of the following types of values:", nl ); - Console::WriteLine( str, "Byte ", xByte1, Test( Math::Sign( xByte1 ) ) ); - Console::WriteLine( str, "Int16 ", xShort1, Test( Math::Sign( xShort1 ) ) ); - Console::WriteLine( str, "Int32 ", xInt1, Test( Math::Sign( xInt1 ) ) ); - Console::WriteLine( str, "Int64 ", xLong1, Test( Math::Sign( xLong1 ) ) ); - Console::WriteLine( str, "Single ", xSingle1, Test( Math::Sign( xSingle1 ) ) ); - Console::WriteLine( str, "Double ", xDouble1, Test( Math::Sign( xDouble1 ) ) ); - Console::WriteLine( str, "Decimal", xDecimal1, Test( Math::Sign( xDecimal1 ) ) ); - - // - Console::WriteLine( "{0}The following type is not CLS-compliant.", nl ); - Console::WriteLine( str, "SByte ", xSbyte1, Test( Math::Sign( xSbyte1 ) ) ); -} - -/* -This example produces the following results: - -Test the sign of the following types of values: -Byte : 0 is equal to zero. -Int16 : -2 is less than zero. -Int32 : -3 is less than zero. -Int64 : -4 is less than zero. -Single : 0 is equal to zero. -Double : 6 is greater than zero. -Decimal: -7 is less than zero. - -The following type is not CLS-compliant. -SByte : -101 is less than zero. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/platformID.class/CPP/pid.cpp b/snippets/cpp/VS_Snippets_CLR/platformID.class/CPP/pid.cpp deleted file mode 100644 index 0db73927f0c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/platformID.class/CPP/pid.cpp +++ /dev/null @@ -1,39 +0,0 @@ - -// -// This example demonstrates the PlatformID enumeration. -using namespace System; -int main() -{ - String^ msg1 = L"This is a Windows operating system."; - String^ msg2 = L"This is a Unix operating system."; - String^ msg3 = L"ERROR: This platform identifier is invalid."; - - // Assume this example is run on a Windows operating system. - OperatingSystem^ os = Environment::OSVersion; - PlatformID pid = os->Platform; - switch ( pid ) - { - case PlatformID::Win32NT: - case PlatformID::Win32S: - case PlatformID::Win32Windows: - case PlatformID::WinCE: - Console::WriteLine( msg1 ); - break; - - case PlatformID::Unix: - Console::WriteLine( msg2 ); - break; - - default: - Console::WriteLine( msg3 ); - break; - } - return 1; -} - -/* -This example produces the following results: - -This is a Windows operating system. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.LastIndexOf7/CPP/lastixof7.cpp b/snippets/cpp/VS_Snippets_CLR/string.LastIndexOf7/CPP/lastixof7.cpp deleted file mode 100644 index 985c85cb847..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.LastIndexOf7/CPP/lastixof7.cpp +++ /dev/null @@ -1,39 +0,0 @@ - -// -// Sample for String::LastIndexOf(String, Int32) -using namespace System; -int main() -{ - String^ br1 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-"; - String^ br2 = "0123456789012345678901234567890123456789012345678901234567890123456"; - String^ str = "Now is the time for all good men to come to the aid of their party."; - int start; - int at; - start = str->Length - 1; - Console::WriteLine( "All occurrences of 'he' from position {0} to 0.", start ); - Console::WriteLine( "{0}\n{1}\n{2}\n", br1, br2, str ); - Console::Write( "The string 'he' occurs at position(s): " ); - at = 0; - while ( (start > -1) && (at > -1) ) - { - at = str->LastIndexOf( "he", start ); - if ( at > -1 ) - { - Console::Write( " {0} ", at ); - start = at - 1; - } - } - - Console::WriteLine(); -} - -/* -This example produces the following results: -All occurrences of 'he' from position 66 to 0. -0----+----1----+----2----+----3----+----4----+----5----+----6----+- -0123456789012345678901234567890123456789012345678901234567890123456 -Now is the time for all good men to come to the aid of their party. - -The string 'he' occurs at position(s): 56 45 8 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.LastIndexOf8/CPP/lastixof8.cpp b/snippets/cpp/VS_Snippets_CLR/string.LastIndexOf8/CPP/lastixof8.cpp deleted file mode 100644 index 707743dd829..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.LastIndexOf8/CPP/lastixof8.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// -// Sample for String::LastIndexOf(String, Int32, Int32) -using namespace System; -int main() -{ - String^ br1 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-"; - String^ br2 = "0123456789012345678901234567890123456789012345678901234567890123456"; - String^ str = "Now is the time for all good men to come to the aid of their party."; - int start; - int at; - int count; - int end; - start = str->Length - 1; - end = start / 2 - 1; - Console::WriteLine( "All occurrences of 'he' from position {0} to {1}.", start, end ); - Console::WriteLine( "{1}{0}{2}{0}{3}{0}", Environment::NewLine, br1, br2, str ); - Console::Write( "The string 'he' occurs at position(s): " ); - count = 0; - at = 0; - while ( (start > -1) && (at > -1) ) - { - count = start - end; //Count must be within the substring. - at = str->LastIndexOf( "he", start, count ); - if ( at > -1 ) - { - Console::Write( "{0} ", at ); - start = at - 1; - } - } - - Console::Write( "{0} {0} {0}", Environment::NewLine ); -} - -/* -This example produces the following results: -All occurrences of 'he' from position 66 to 32. -0----+----1----+----2----+----3----+----4----+----5----+----6----+- -0123456789012345678901234567890123456789012345678901234567890123456 -Now is the time for all good men to come to the aid of their party. - -The string 'he' occurs at position(s): 56 45 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.LastIndexOfAny1/CPP/lastixany1.cpp b/snippets/cpp/VS_Snippets_CLR/string.LastIndexOfAny1/CPP/lastixany1.cpp deleted file mode 100644 index 545ffd356be..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.LastIndexOfAny1/CPP/lastixany1.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -// -// Sample for String::LastIndexOfAny(Char[]) -using namespace System; -int main() -{ - String^ br1 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-"; - String^ br2 = "0123456789012345678901234567890123456789012345678901234567890123456"; - String^ str = "Now is the time for all good men to come to the aid of their party."; - int start; - int at; - String^ target = "is"; - array^anyOf = target->ToCharArray(); - start = str->Length - 1; - Console::WriteLine( "The last character occurrence from position {0} to 0.", start ); - Console::WriteLine( "{1}{0}{2}{0}{3}{0}", Environment::NewLine, br1, br2, str ); - Console::Write( "A character in '{0}' occurs at position: ", target ); - at = str->LastIndexOfAny( anyOf ); - if ( at > -1 ) - Console::Write( at ); - else - Console::Write( "(not found)" ); - - Console::Write( "{0}{0}{0}", Environment::NewLine ); -} - -/* -This example produces the following results: -The last character occurrence from position 66 to 0. -0----+----1----+----2----+----3----+----4----+----5----+----6----+- -0123456789012345678901234567890123456789012345678901234567890123456 -Now is the time for all good men to come to the aid of their party. - -A character in 'is' occurs at position: 58 - - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.LastIndexOfAny2/CPP/lastixany2.cpp b/snippets/cpp/VS_Snippets_CLR/string.LastIndexOfAny2/CPP/lastixany2.cpp deleted file mode 100644 index 4328318576a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.LastIndexOfAny2/CPP/lastixany2.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -// -// Sample for String::LastIndexOfAny(Char, Int32) -using namespace System; -int main() -{ - String^ br1 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-"; - String^ br2 = "0123456789012345678901234567890123456789012345678901234567890123456"; - String^ str = "Now is the time for all good men to come to the aid of their party."; - int start; - int at; - String^ target = "is"; - array^anyOf = target->ToCharArray(); - start = (str->Length - 1) / 2; - Console::WriteLine( "The last character occurrence from position {0} to 0.", start ); - Console::WriteLine( "{1}{0}{2}{0}{3}{0}", Environment::NewLine, br1, br2, str ); - Console::Write( "A character in '{0}' occurs at position: ", target ); - at = str->LastIndexOfAny( anyOf, start ); - if ( at > -1 ) - Console::Write( at ); - else - Console::Write( "(not found)" ); - - Console::Write( "{0}{0}{0}", Environment::NewLine ); -} - -/* -This example produces the following results: -The last character occurrence from position 33 to 0. -0----+----1----+----2----+----3----+----4----+----5----+----6----+- -0123456789012345678901234567890123456789012345678901234567890123456 -Now is the time for all good men to come to the aid of their party. - -A character in 'is' occurs at position: 12 - - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.LastIndexOfAny3/CPP/lastixany3.cpp b/snippets/cpp/VS_Snippets_CLR/string.LastIndexOfAny3/CPP/lastixany3.cpp deleted file mode 100644 index 2c3f5ecd695..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.LastIndexOfAny3/CPP/lastixany3.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -// -// Sample for String::LastIndexOfAny(Char[], Int32, Int32) -using namespace System; -int main() -{ - String^ br1 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-"; - String^ br2 = "0123456789012345678901234567890123456789012345678901234567890123456"; - String^ str = "Now is the time for all good men to come to the aid of their party."; - int start; - int at; - int count; - String^ target = "aid"; - array^anyOf = target->ToCharArray(); - start = ((str->Length - 1) * 2) / 3; - count = (str->Length - 1) / 3; - Console::WriteLine( "The last character occurrence from position {0} for {1} characters.", start, count ); - Console::WriteLine( "{1}{0}{2}{0}{3}{0}", Environment::NewLine, br1, br2, str ); - Console::Write( "A character in '{0}' occurs at position: ", target ); - at = str->LastIndexOfAny( anyOf, start, count ); - if ( at > -1 ) - Console::Write( at ); - else - Console::Write( "(not found)" ); - - Console::Write( "{0}{0}{0}", Environment::NewLine ); -} - -/* -This example produces the following results: -The last character occurrence from position 44 for 22 characters. -0----+----1----+----2----+----3----+----4----+----5----+----6----+- -0123456789012345678901234567890123456789012345678901234567890123456 -Now is the time for all good men to come to the aid of their party. - -A character in 'aid' occurs at position: 27 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.ToCharArray1/CPP/tocharry1.cpp b/snippets/cpp/VS_Snippets_CLR/string.ToCharArray1/CPP/tocharry1.cpp deleted file mode 100644 index 338ffdc3b4f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.ToCharArray1/CPP/tocharry1.cpp +++ /dev/null @@ -1,32 +0,0 @@ - -// -// Sample for String::ToCharArray(Int32, Int32) -using namespace System; -using namespace System::Collections; -int main() -{ - String^ str = "012wxyz789"; - array^arr; - arr = str->ToCharArray( 3, 4 ); - Console::Write( "The letters in '{0}' are: '", str ); - Console::Write( arr ); - Console::WriteLine( "'" ); - Console::WriteLine( "Each letter in '{0}' is:", str ); - IEnumerator^ myEnum = arr->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Char c = safe_cast(myEnum->Current); - Console::WriteLine( c ); - } -} - -/* -This example produces the following results: -The letters in '012wxyz789' are: 'wxyz' -Each letter in '012wxyz789' is: -w -x -y -z -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.comp4/CPP/string.comp4.cpp b/snippets/cpp/VS_Snippets_CLR/string.comp4/CPP/string.comp4.cpp deleted file mode 100644 index 67cba53ecab..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.comp4/CPP/string.comp4.cpp +++ /dev/null @@ -1,34 +0,0 @@ - -// -using namespace System; -using namespace System::Globalization; -String^ symbol( int r ) -{ - String^ s = "="; - if ( r < 0 ) - s = "<"; - else - if ( r > 0 ) - s = ">"; - - - return s; -} - -int main() -{ - String^ str1 = "change"; - String^ str2 = "dollar"; - String^ relation = nullptr; - relation = symbol( String::Compare( str1, str2, false, gcnew CultureInfo( "en-US" ) ) ); - Console::WriteLine( "For en-US: {0} {1} {2}", str1, relation, str2 ); - relation = symbol( String::Compare( str1, str2, false, gcnew CultureInfo( "cs-CZ" ) ) ); - Console::WriteLine( "For cs-CZ: {0} {1} {2}", str1, relation, str2 ); -} - -/* -This example produces the following results. -For en-US: change < dollar -For cs-CZ: change > dollar -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.compare3/CPP/comp3.cpp b/snippets/cpp/VS_Snippets_CLR/string.compare3/CPP/comp3.cpp deleted file mode 100644 index 069e685cc76..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.compare3/CPP/comp3.cpp +++ /dev/null @@ -1,28 +0,0 @@ - -// -// Sample for String::Compare(String, Int32, String, Int32, Int32) -using namespace System; -int main() -{ - - // 0123456 - String^ str1 = "machine"; - String^ str2 = "device"; - String^ str; - int result; - Console::WriteLine(); - Console::WriteLine( "str1 = '{0}', str2 = '{1}'", str1, str2 ); - result = String::Compare( str1, 2, str2, 0, 2 ); - str = ((result < 0) ? "less than" : ((result > 0) ? (String^)"greater than" : "equal to")); - Console::Write( "Substring '{0}' in ' {1}' is ", str1->Substring( 2, 2 ), str1 ); - Console::Write( " {0} ", str ); - Console::WriteLine( "substring '{0}' in ' {1}'.", str2->Substring( 0, 2 ), str2 ); -} - -/* -This example produces the following results: - -str1 = 'machine', str2 = 'device' -Substring 'ch' in 'machine' is less than substring 'de' in 'device'. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.compare4/CPP/comp4.cpp b/snippets/cpp/VS_Snippets_CLR/string.compare4/CPP/comp4.cpp deleted file mode 100644 index 0e2fd3df934..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.compare4/CPP/comp4.cpp +++ /dev/null @@ -1,40 +0,0 @@ - -// -// Sample for String::Compare(String, Int32, String, Int32, Int32, Boolean) -using namespace System; -int main() -{ - - // 0123456 - String^ str1 = "MACHINE"; - String^ str2 = "machine"; - String^ str; - int result; - Console::WriteLine(); - Console::WriteLine( "str1 = '{0}', str2 = '{1}'", str1, str2 ); - Console::WriteLine( "Ignore case:" ); - result = String::Compare( str1, 2, str2, 2, 2, true ); - str = ((result < 0) ? "less than" : ((result > 0) ? (String^)"greater than" : "equal to")); - Console::Write( "Substring '{0}' in '{1}' is ", str1->Substring( 2, 2 ), str1 ); - Console::Write( " {0} ", str ); - Console::WriteLine( "substring '{0}' in '{1}'.", str2->Substring( 2, 2 ), str2 ); - Console::WriteLine(); - Console::WriteLine( "Honor case:" ); - result = String::Compare( str1, 2, str2, 2, 2, false ); - str = ((result < 0) ? "less than" : ((result > 0) ? (String^)"greater than" : "equal to")); - Console::Write( "Substring '{0}' in '{1}' is ", str1->Substring( 2, 2 ), str1 ); - Console::Write( " {0} ", str ); - Console::WriteLine( "substring '{0}' in '{1}'.", str2->Substring( 2, 2 ), str2 ); -} - -/* -This example produces the following results: - -str1 = 'MACHINE', str2 = 'machine' -Ignore case: -Substring 'CH' in 'MACHINE' is equal to substring 'ch' in 'machine'. - -Honor case: -Substring 'CH' in 'MACHINE' is greater than substring 'ch' in 'machine'. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.compare5/CPP/comp5.cpp b/snippets/cpp/VS_Snippets_CLR/string.compare5/CPP/comp5.cpp deleted file mode 100644 index 3afdbfd074c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.compare5/CPP/comp5.cpp +++ /dev/null @@ -1,41 +0,0 @@ - -// -// Sample for String::Compare(String, Int32, String, Int32, Int32, Boolean, CultureInfo) -using namespace System; -using namespace System::Globalization; -int main() -{ - - // 0123456 - String^ str1 = "MACHINE"; - String^ str2 = "machine"; - String^ str; - int result; - Console::WriteLine(); - Console::WriteLine( "str1 = '{0}', str2 = '{1}'", str1, str2 ); - Console::WriteLine( "Ignore case, Turkish culture:" ); - result = String::Compare( str1, 4, str2, 4, 2, true, gcnew CultureInfo( "tr-TR" ) ); - str = ((result < 0) ? "less than" : ((result > 0) ? (String^)"greater than" : "equal to")); - Console::Write( "Substring '{0}' in '{1}' is ", str1->Substring( 4, 2 ), str1 ); - Console::Write( " {0} ", str ); - Console::WriteLine( "substring '{0}' in '{1}'.", str2->Substring( 4, 2 ), str2 ); - Console::WriteLine(); - Console::WriteLine( "Ignore case, invariant culture:" ); - result = String::Compare( str1, 4, str2, 4, 2, true, CultureInfo::InvariantCulture ); - str = ((result < 0) ? "less than" : ((result > 0) ? (String^)"greater than" : "equal to")); - Console::Write( "Substring '{0}' in '{1}' is ", str1->Substring( 4, 2 ), str1 ); - Console::Write( " {0} ", str ); - Console::WriteLine( "substring '{0}' in '{1}'.", str2->Substring( 4, 2 ), str2 ); -} - -/* -This example produces the following results: - -str1 = 'MACHINE', str2 = 'machine' -Ignore case, Turkish culture: -Substring 'IN' in 'MACHINE' is less than substring 'in' in 'machine'. - -Ignore case, invariant culture: -Substring 'IN' in 'MACHINE' is equal to substring 'in' in 'machine'. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.compareordinal/CPP/comp0.cpp b/snippets/cpp/VS_Snippets_CLR/string.compareordinal/CPP/comp0.cpp deleted file mode 100644 index 52112724b74..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.compareordinal/CPP/comp0.cpp +++ /dev/null @@ -1,28 +0,0 @@ - -// -// Sample for String::CompareOrdinal(String, String) -using namespace System; -int main() -{ - String^ str1 = "ABCD"; - String^ str2 = "abcd"; - String^ str; - int result; - Console::WriteLine(); - Console::WriteLine( "Compare the numeric values of the corresponding Char objects in each string." ); - Console::WriteLine( "str1 = '{0}', str2 = '{1}'", str1, str2 ); - result = String::CompareOrdinal( str1, str2 ); - str = ((result < 0) ? "less than" : ((result > 0) ? (String^)"greater than" : "equal to")); - Console::Write( "String '{0}' is ", str1 ); - Console::Write( "{0} ", str ); - Console::WriteLine( "String '{0}'.", str2 ); -} - -/* -This example produces the following results: - -Compare the numeric values of the corresponding Char objects in each string. -str1 = 'ABCD', str2 = 'abcd' -String 'ABCD' is less than String 'abcd'. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.concat5/CPP/string.concat5.cpp b/snippets/cpp/VS_Snippets_CLR/string.concat5/CPP/string.concat5.cpp deleted file mode 100644 index 4b457f0078d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.concat5/CPP/string.concat5.cpp +++ /dev/null @@ -1,33 +0,0 @@ - -// -using namespace System; - -int main() -{ - int i = -123; - Object^ o = i; - array^objs = { -123, -456, -789}; - Console::WriteLine("Concatenate 1, 2, and 3 objects:"); - Console::WriteLine("1) {0}", String::Concat(o)); - Console::WriteLine("2) {0}", String::Concat(o, o)); - Console::WriteLine("3) {0}", String::Concat(o, o, o)); - - Console::WriteLine("\nConcatenate 4 objects and a variable length parameter list:" ); - Console::WriteLine("4) {0}", String::Concat(o, o, o, o)); - Console::WriteLine("5) {0}", String::Concat( o, o, o, o, o)); - Console::WriteLine("\nConcatenate a 3-element object array:"); - Console::WriteLine("6) {0}", String::Concat(objs)); -} -// The example displays the following output: -// Concatenate 1, 2, and 3 objects: -// 1) -123 -// 2) -123-123 -// 3) -123-123-123 -// -// Concatenate 4 objects and a variable length parameter list: -// 4) -123-123-123-123 -// 5) -123-123-123-123-123 -// -// Concatenate a 3-element object array: -// 6) -123-456-789 -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.contains/CPP/cont.cpp b/snippets/cpp/VS_Snippets_CLR/string.contains/CPP/cont.cpp deleted file mode 100644 index d9beeec7af6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.contains/CPP/cont.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; - -int main() -{ - String^ s1 = "The quick brown fox jumps over the lazy dog"; - String^ s2 = "fox"; - bool b = s1->Contains( s2 ); - Console::WriteLine( "Is the string, s2, in the string, s1?: {0}", b ); - if (b) { - int index = s1->IndexOf(s2); - if (index >= 0) - Console::WriteLine("'{0} begins at character position {1}", - s2, index + 1); - } -} -// This example displays the following output: -// 'fox' is in the string 'The quick brown fox jumps over the lazy dog': True -// 'fox begins at character position 17 -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.equals/CPP/equals.cpp b/snippets/cpp/VS_Snippets_CLR/string.equals/CPP/equals.cpp deleted file mode 100644 index 94de0334063..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.equals/CPP/equals.cpp +++ /dev/null @@ -1,55 +0,0 @@ - -// -// Sample for String::Equals(Object) -// String::Equals(String) -// String::Equals(String, String) -using namespace System; -using namespace System::Text; -int main() -{ - StringBuilder^ sb = gcnew StringBuilder( "abcd" ); - String^ str1 = "abcd"; - String^ str2 = nullptr; - Object^ o2 = nullptr; - Console::WriteLine(); - Console::WriteLine( " * The value of String str1 is '{0}'.", str1 ); - Console::WriteLine( " * The value of StringBuilder sb is '{0}'.", sb ); - Console::WriteLine(); - Console::WriteLine( "1a) String::Equals(Object). Object is a StringBuilder, not a String." ); - Console::WriteLine( " Is str1 equal to sb?: {0}", str1->Equals( sb ) ); - Console::WriteLine(); - Console::WriteLine( "1b) String::Equals(Object). Object is a String." ); - str2 = sb->ToString(); - o2 = str2; - Console::WriteLine( " * The value of Object o2 is '{0}'.", o2 ); - Console::WriteLine( " Is str1 equal to o2?: {0}", str1->Equals( o2 ) ); - Console::WriteLine(); - Console::WriteLine( " 2) String::Equals(String)" ); - Console::WriteLine( " * The value of String str2 is '{0}'.", str2 ); - Console::WriteLine( " Is str1 equal to str2?: {0}", str1->Equals( str2 ) ); - Console::WriteLine(); - Console::WriteLine( " 3) String::Equals(String, String)" ); - Console::WriteLine( " Is str1 equal to str2?: {0}", String::Equals( str1, str2 ) ); -} - -/* -This example produces the following results: - - * The value of String str1 is 'abcd'. - * The value of StringBuilder sb is 'abcd'. - -1a) String::Equals(Object). Object is a StringBuilder, not a String. - Is str1 equal to sb?: False - -1b) String::Equals(Object). Object is a String. - * The value of Object o2 is 'abcd'. - Is str1 equal to o2?: True - - 2) String::Equals(String) - * The value of String str2 is 'abcd'. - Is str1 equal to str2?: True - - 3) String::Equals(String, String) - Is str1 equal to str2?: True -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.gettypecode/CPP/gtc.cpp b/snippets/cpp/VS_Snippets_CLR/string.gettypecode/CPP/gtc.cpp deleted file mode 100644 index 536db349ec4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.gettypecode/CPP/gtc.cpp +++ /dev/null @@ -1,16 +0,0 @@ - -// -// Sample for String.GetTypeCode() -using namespace System; -int main() -{ - String^ str = "abc"; - TypeCode tc = str->GetTypeCode(); - Console::WriteLine( "The type code for '{0}' is {1}, which represents {2}.", str, tc.ToString( "D" ), tc.ToString( "F" ) ); -} - -/* -This example produces the following results: -The type code for 'abc' is 18, which represents String. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.indexof1/CPP/ixof1.cpp b/snippets/cpp/VS_Snippets_CLR/string.indexof1/CPP/ixof1.cpp deleted file mode 100644 index 30d08ce5ace..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.indexof1/CPP/ixof1.cpp +++ /dev/null @@ -1,42 +0,0 @@ - -// -// Sample for String::IndexOf(Char, Int32) -using namespace System; -int main() -{ - String^ br1 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-"; - String^ br2 = "0123456789012345678901234567890123456789012345678901234567890123456"; - String^ str = "Now is the time for all good men to come to the aid of their party."; - int start; - int at; - Console::WriteLine(); - Console::WriteLine( "All occurrences of 't' from position 0 to {0}.", str->Length - 1 ); - Console::WriteLine( "{1}{0}{2}{0}{3}{0}", Environment::NewLine, br1, br2, str ); - Console::Write( "The letter 't' occurs at position(s): " ); - at = 0; - start = 0; - while ( (start < str->Length) && (at > -1) ) - { - at = str->IndexOf( 't', start ); - if ( at == -1 ) - break; - - Console::Write( "{0} ", at ); - start = at + 1; - } - - Console::WriteLine(); -} - -/* -This example produces the following results: - -All occurrences of 't' from position 0 to 66. -0----+----1----+----2----+----3----+----4----+----5----+----6----+- -0123456789012345678901234567890123456789012345678901234567890123456 -Now is the time for all good men to come to the aid of their party. - -The letter 't' occurs at position(s): 7 11 33 41 44 55 64 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.indexof8/CPP/ixof8.cpp b/snippets/cpp/VS_Snippets_CLR/string.indexof8/CPP/ixof8.cpp deleted file mode 100644 index f8a1385b749..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.indexof8/CPP/ixof8.cpp +++ /dev/null @@ -1,49 +0,0 @@ - -// -// Sample for String::IndexOf(String, Int32, Int32) -using namespace System; -int main() -{ - String^ br1 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-"; - String^ br2 = "0123456789012345678901234567890123456789012345678901234567890123456"; - String^ str = "Now is the time for all good men to come to the aid of their party."; - int start; - int at; - int end; - int count; - end = str->Length; - start = end / 2; - Console::WriteLine(); - Console::WriteLine( "All occurrences of 'he' from position {0} to {1}.", start, end - 1 ); - Console::WriteLine( "{1}{0}{2}{0}{3}{0}", Environment::NewLine, br1, br2, str ); - Console::Write( "The string 'he' occurs at position(s): " ); - count = 0; - at = 0; - while ( (start <= end) && (at > -1) ) - { - - // start+count must be a position within -str-. - count = end - start; - at = str->IndexOf( "he", start, count ); - if ( at == -1 ) - break; - - Console::Write( "{0} ", at ); - start = at + 1; - } - - Console::WriteLine(); -} - -/* -This example produces the following results: - -All occurrences of 'he' from position 33 to 66. -0----+----1----+----2----+----3----+----4----+----5----+----6----+- -0123456789012345678901234567890123456789012345678901234567890123456 -Now is the time for all good men to come to the aid of their party. - -The string 'he' occurs at position(s): 45 56 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.indexofany2/CPP/ixany2.cpp b/snippets/cpp/VS_Snippets_CLR/string.indexofany2/CPP/ixany2.cpp deleted file mode 100644 index 47b0a1db97c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.indexofany2/CPP/ixany2.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -// -// Sample for String::IndexOfAny(Char[], Int32) -using namespace System; -int main() -{ - String^ br1 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-"; - String^ br2 = "0123456789012345678901234567890123456789012345678901234567890123456"; - String^ str = "Now is the time for all good men to come to the aid of their party."; - int start; - int at; - String^ target = "is"; - array^anyOf = target->ToCharArray(); - start = str->Length / 2; - Console::WriteLine(); - Console::WriteLine( "The first character occurrence from position {0} to {1}.", start, str->Length - 1 ); - Console::WriteLine( "{1}{0}{2}{0}{3}{0}", Environment::NewLine, br1, br2, str ); - Console::Write( "A character in '{0}' occurs at position: ", target ); - at = str->IndexOfAny( anyOf, start ); - if ( at > -1 ) - Console::Write( at ); - else - Console::Write( "(not found)" ); - - Console::WriteLine(); -} - -/* - -The first character occurrence from position 33 to 66. -0----+----1----+----2----+----3----+----4----+----5----+----6----+- -0123456789012345678901234567890123456789012345678901234567890123456 -Now is the time for all good men to come to the aid of their party. - -A character in 'is' occurs at position: 49 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.indexofany3/CPP/ixany3.cpp b/snippets/cpp/VS_Snippets_CLR/string.indexofany3/CPP/ixany3.cpp deleted file mode 100644 index 4bd03080726..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.indexofany3/CPP/ixany3.cpp +++ /dev/null @@ -1,40 +0,0 @@ - -// -// Sample for String::IndexOfAny(Char[], Int32, Int32) -using namespace System; -int main() -{ - String^ br1 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-"; - String^ br2 = "0123456789012345678901234567890123456789012345678901234567890123456"; - String^ str = "Now is the time for all good men to come to the aid of their party."; - int start; - int at; - int count; - String^ target = "aid"; - array^anyOf = target->ToCharArray(); - start = (str->Length - 1) / 3; - count = (str->Length - 1) / 4; - Console::WriteLine(); - Console::WriteLine( "The first character occurrence from position {0} for {1} characters.", start, count ); - Console::WriteLine( "{1}{0}{2}{0}{3}{0}", Environment::NewLine, br1, br2, str ); - Console::Write( "A character in '{0}' occurs at position: ", target ); - at = str->IndexOfAny( anyOf, start, count ); - if ( at > -1 ) - Console::Write( at ); - else - Console::Write( "(not found)" ); - - Console::WriteLine(); -} - -/* - -The first character occurrence from position 22 for 16 characters. -0----+----1----+----2----+----3----+----4----+----5----+----6----+- -0123456789012345678901234567890123456789012345678901234567890123456 -Now is the time for all good men to come to the aid of their party. - -A character in 'aid' occurs at position: 27 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.intern/CPP/string_intern.cpp b/snippets/cpp/VS_Snippets_CLR/string.intern/CPP/string_intern.cpp deleted file mode 100644 index b70c604b0b1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.intern/CPP/string_intern.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -// Sample for String::Intern(String) -using namespace System; -using namespace System::Text; -int main() -{ - String^ s1 = "MyTest"; - String^ s2 = (gcnew StringBuilder)->Append( "My" )->Append( "Test" )->ToString(); - String^ s3 = String::Intern( s2 ); - Console::WriteLine( "s1 == '{0}'", s1 ); - Console::WriteLine( "s2 == '{0}'", s2 ); - Console::WriteLine( "s3 == '{0}'", s3 ); - Console::WriteLine( "Is s2 the same reference as s1?: {0}", s2 == s1 ); - Console::WriteLine( "Is s3 the same reference as s1?: {0}", s3 == s1 ); -} - -/* -This example produces the following results: -s1 == 'MyTest' -s2 == 'MyTest' -s3 == 'MyTest' -Is s2 the same reference as s1?: False -Is s3 the same reference as s1?: True -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.isNullOrEmpty/CPP/inoe.cpp b/snippets/cpp/VS_Snippets_CLR/string.isNullOrEmpty/CPP/inoe.cpp deleted file mode 100644 index a9a9593c87e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.isNullOrEmpty/CPP/inoe.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -// -using namespace System; -String^ Test( String^ s ) -{ - if (String::IsNullOrEmpty(s)) - return "is null or empty"; - else - return String::Format( "(\"{0}\") is neither null nor empty", s ); -} - -int main() -{ - String^ s1 = "abcd"; - String^ s2 = ""; - String^ s3 = nullptr; - Console::WriteLine( "String s1 {0}.", Test( s1 ) ); - Console::WriteLine( "String s2 {0}.", Test( s2 ) ); - Console::WriteLine( "String s3 {0}.", Test( s3 ) ); -} -// The example displays the following output: -// String s1 ("abcd") is neither null nor empty. -// String s2 is null or empty. -// String s3 is null or empty. -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.isinterned/CPP/isin.cpp b/snippets/cpp/VS_Snippets_CLR/string.isinterned/CPP/isin.cpp deleted file mode 100644 index bec722b1e9e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.isinterned/CPP/isin.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// -// Sample for String::IsInterned(String) -using namespace System; -using namespace System::Text; -using namespace System::Runtime::CompilerServices; - -// In the .NET Framework 2.0 the following attribute declaration allows you to -// avoid the use of the interning when you use NGEN.exe to compile an assembly -// to the native image cache. -[assembly:CompilationRelaxations(CompilationRelaxations::NoStringInterning)]; -void Test( int sequence, String^ str ) -{ - Console::Write( "{0} The string '", sequence ); - String^ strInterned = String::IsInterned( str ); - if ( strInterned == nullptr ) - Console::WriteLine( "{0}' is not interned.", str ); - else - Console::WriteLine( "{0}' is interned.", strInterned ); -} - -int main() -{ - - // String str1 is known at compile time, and is automatically interned. - String^ str1 = "abcd"; - - // Constructed string, str2, is not explicitly or automatically interned. - String^ str2 = (gcnew StringBuilder)->Append( "wx" )->Append( "yz" )->ToString(); - Console::WriteLine(); - Test( 1, str1 ); - Test( 2, str2 ); -} - -//This example produces the following results: - -//1) The string, 'abcd', is interned. -//2) The string, 'wxyz', is not interned. - -//If you use NGEN.exe to compile the assembly to the native image cache, this -//example produces the following results: - -//1) The string, 'abcd', is not interned. -//2) The string, 'wxyz', is not interned. - -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.join2/CPP/join2.cpp b/snippets/cpp/VS_Snippets_CLR/string.join2/CPP/join2.cpp deleted file mode 100644 index 07f204ebd9e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.join2/CPP/join2.cpp +++ /dev/null @@ -1,22 +0,0 @@ - -// -// Sample for String::Join(String, String[], int int) -using namespace System; -int main() -{ - array^val = {"apple","orange","grape","pear"}; - String^ sep = ", "; - String^ result; - Console::WriteLine( "sep = '{0}'", sep ); - Console::WriteLine( "val[] = {{'{0}' '{1}' '{2}' '{3}'}}", val[ 0 ], val[ 1 ], val[ 2 ], val[ 3 ] ); - result = String::Join( sep, val, 1, 2 ); - Console::WriteLine( "String::Join(sep, val, 1, 2) = '{0}'", result ); -} - -/* -This example produces the following results: -sep = ', ' -val[] = {'apple' 'orange' 'grape' 'pear'} -String::Join(sep, val, 1, 2) = 'orange, grape' -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.lastindexof1/CPP/lastixof1.cpp b/snippets/cpp/VS_Snippets_CLR/string.lastindexof1/CPP/lastixof1.cpp deleted file mode 100644 index 809d2c001d6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.lastindexof1/CPP/lastixof1.cpp +++ /dev/null @@ -1,37 +0,0 @@ - -// -// Sample for String::LastIndexOf(Char, Int32) -using namespace System; -int main() -{ - String^ br1 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-"; - String^ br2 = "0123456789012345678901234567890123456789012345678901234567890123456"; - String^ str = "Now is the time for all good men to come to the aid of their party."; - int start; - int at; - start = str->Length - 1; - Console::WriteLine( "All occurrences of 't' from position {0} to 0.", start ); - Console::WriteLine( "{0}\n{1}\n{2}\n", br1, br2, str ); - Console::Write( "The letter 't' occurs at position(s): " ); - at = 0; - while ( (start > -1) && (at > -1) ) - { - at = str->LastIndexOf( 't', start ); - if ( at > -1 ) - { - Console::Write( " {0} ", at ); - start = at - 1; - } - } -} - -/* -This example produces the following results: -All occurrences of 't' from position 66 to 0. -0----+----1----+----2----+----3----+----4----+----5----+----6----+- -0123456789012345678901234567890123456789012345678901234567890123456 -Now is the time for all good men to come to the aid of their party. - -The letter 't' occurs at position(s): 64 55 44 41 33 11 7 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.lastindexof2/CPP/lastixof2.cpp b/snippets/cpp/VS_Snippets_CLR/string.lastindexof2/CPP/lastixof2.cpp deleted file mode 100644 index 881187073e4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.lastindexof2/CPP/lastixof2.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// -// Sample for String::LastIndexOf(Char, Int32, Int32) -using namespace System; -int main() -{ - String^ br1 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-"; - String^ br2 = "0123456789012345678901234567890123456789012345678901234567890123456"; - String^ str = "Now is the time for all good men to come to the aid of their party."; - int start; - int at; - int count; - int end; - start = str->Length - 1; - end = start / 2 - 1; - Console::WriteLine( "All occurrences of 't' from position {0} to {1}.", start, end ); - Console::WriteLine( "\n{0}\n{1}\n{2}", br1, br2, str ); - Console::Write( "The letter 't' occurs at position(s): " ); - count = 0; - at = 0; - while ( (start > -1) && (at > -1) ) - { - count = start - end; //Count must be within the substring. - at = str->LastIndexOf( 't', start, count ); - if ( at > -1 ) - { - Console::Write( " {0} ", at ); - start = at - 1; - } - } -} - -/* -This example produces the following results: -All occurrences of 't' from position 66 to 32. -0----+----1----+----2----+----3----+----4----+----5----+----6----+- -0123456789012345678901234567890123456789012345678901234567890123456 -Now is the time for all good men to come to the aid of their party. - -The letter 't' occurs at position(s): 64 55 44 41 33 - - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.length/CPP/length.cpp b/snippets/cpp/VS_Snippets_CLR/string.length/CPP/length.cpp deleted file mode 100644 index e3a6250c8ac..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.length/CPP/length.cpp +++ /dev/null @@ -1,20 +0,0 @@ - -// -// Sample for String::Length -using namespace System; -int main() -{ - String^ str = "abcdefg"; - Console::WriteLine( "1) The length of '{0}' is {1}", str, str->Length ); - Console::WriteLine( "2) The length of '{0}' is {1}", "xyz", ((String^)"xyz")->Length ); - int length = str->Length; - Console::WriteLine( "1) The length of '{0}' is {1}", str, length ); -} - -/* -This example displays the following output: - 1) The length of 'abcdefg' is 7 - 2) The length of 'xyz' is 3 - 3) The length of 'abcdefg' is 7 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.normalize/CPP/norm.cpp b/snippets/cpp/VS_Snippets_CLR/string.normalize/CPP/norm.cpp deleted file mode 100644 index 8193a3115e2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.normalize/CPP/norm.cpp +++ /dev/null @@ -1,117 +0,0 @@ - -// -using namespace System; -using namespace System::Text; - -void Show( String^ title, String^ s ) -{ - Console::Write( "Characters in string {0} = ", title ); - for each (short x in s) { - Console::Write("{0:X4} ", x); - } - Console::WriteLine(); -} - -int main() -{ - - // Character c; combining characters acute and cedilla; character 3/4 - array^temp0 = {L'c',L'\u0301',L'\u0327',L'\u00BE'}; - String^ s1 = gcnew String( temp0 ); - String^ s2 = nullptr; - String^ divider = gcnew String( '-',80 ); - divider = String::Concat( Environment::NewLine, divider, Environment::NewLine ); - - Show( "s1", s1 ); - Console::WriteLine(); - Console::WriteLine( "U+0063 = LATIN SMALL LETTER C" ); - Console::WriteLine( "U+0301 = COMBINING ACUTE ACCENT" ); - Console::WriteLine( "U+0327 = COMBINING CEDILLA" ); - Console::WriteLine( "U+00BE = VULGAR FRACTION THREE QUARTERS" ); - Console::WriteLine( divider ); - Console::WriteLine( "A1) Is s1 normalized to the default form (Form C)?: {0}", s1->IsNormalized() ); - Console::WriteLine( "A2) Is s1 normalized to Form C?: {0}", s1->IsNormalized( NormalizationForm::FormC ) ); - Console::WriteLine( "A3) Is s1 normalized to Form D?: {0}", s1->IsNormalized( NormalizationForm::FormD ) ); - Console::WriteLine( "A4) Is s1 normalized to Form KC?: {0}", s1->IsNormalized( NormalizationForm::FormKC ) ); - Console::WriteLine( "A5) Is s1 normalized to Form KD?: {0}", s1->IsNormalized( NormalizationForm::FormKD ) ); - Console::WriteLine( divider ); - Console::WriteLine( "Set string s2 to each normalized form of string s1." ); - Console::WriteLine(); - Console::WriteLine( "U+1E09 = LATIN SMALL LETTER C WITH CEDILLA AND ACUTE" ); - Console::WriteLine( "U+0033 = DIGIT THREE" ); - Console::WriteLine( "U+2044 = FRACTION SLASH" ); - Console::WriteLine( "U+0034 = DIGIT FOUR" ); - Console::WriteLine( divider ); - s2 = s1->Normalize(); - Console::Write( "B1) Is s2 normalized to the default form (Form C)?: " ); - Console::WriteLine( s2->IsNormalized() ); - Show( "s2", s2 ); - Console::WriteLine(); - s2 = s1->Normalize( NormalizationForm::FormC ); - Console::Write( "B2) Is s2 normalized to Form C?: " ); - Console::WriteLine( s2->IsNormalized( NormalizationForm::FormC ) ); - Show( "s2", s2 ); - Console::WriteLine(); - s2 = s1->Normalize( NormalizationForm::FormD ); - Console::Write( "B3) Is s2 normalized to Form D?: " ); - Console::WriteLine( s2->IsNormalized( NormalizationForm::FormD ) ); - Show( "s2", s2 ); - Console::WriteLine(); - s2 = s1->Normalize( NormalizationForm::FormKC ); - Console::Write( "B4) Is s2 normalized to Form KC?: " ); - Console::WriteLine( s2->IsNormalized( NormalizationForm::FormKC ) ); - Show( "s2", s2 ); - Console::WriteLine(); - s2 = s1->Normalize( NormalizationForm::FormKD ); - Console::Write( "B5) Is s2 normalized to Form KD?: " ); - Console::WriteLine( s2->IsNormalized( NormalizationForm::FormKD ) ); - Show( "s2", s2 ); - Console::WriteLine(); -} - -/* -This example produces the following results: - -Characters in string s1 = 0063 0301 0327 00BE - -U+0063 = LATIN SMALL LETTER C -U+0301 = COMBINING ACUTE ACCENT -U+0327 = COMBINING CEDILLA -U+00BE = VULGAR FRACTION THREE QUARTERS - --------------------------------------------------------------------------------- - -A1) Is s1 normalized to the default form (Form C)?: False -A2) Is s1 normalized to Form C?: False -A3) Is s1 normalized to Form D?: False -A4) Is s1 normalized to Form KC?: False -A5) Is s1 normalized to Form KD?: False - --------------------------------------------------------------------------------- - -Set string s2 to each normalized form of string s1. - -U+1E09 = LATIN SMALL LETTER C WITH CEDILLA AND ACUTE -U+0033 = DIGIT THREE -U+2044 = FRACTION SLASH -U+0034 = DIGIT FOUR - --------------------------------------------------------------------------------- - -B1) Is s2 normalized to the default form (Form C)?: True -Characters in string s2 = 1E09 00BE - -B2) Is s2 normalized to Form C?: True -Characters in string s2 = 1E09 00BE - -B3) Is s2 normalized to Form D?: True -Characters in string s2 = 0063 0327 0301 00BE - -B4) Is s2 normalized to Form KC?: True -Characters in string s2 = 1E09 0033 2044 0034 - -B5) Is s2 normalized to Form KD?: True -Characters in string s2 = 0063 0327 0301 0033 2044 0034 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.remove/CPP/r.cpp b/snippets/cpp/VS_Snippets_CLR/string.remove/CPP/r.cpp deleted file mode 100644 index a7be6a4bd78..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.remove/CPP/r.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -// -// This example demonstrates the String.Remove() method. -using namespace System; -int main() -{ - String^ s = "abc---def"; - - // - Console::WriteLine( "Index: 012345678" ); - Console::WriteLine( "1) {0}", s ); - Console::WriteLine( "2) {0}", s->Remove( 3 ) ); - Console::WriteLine( "3) {0}", s->Remove( 3, 3 ) ); -} - -/* -This example produces the following results: - -Index: 012345678 -1) abc---def -2) abc -3) abcdef - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.replace1/CPP/string.replace1.cpp b/snippets/cpp/VS_Snippets_CLR/string.replace1/CPP/string.replace1.cpp deleted file mode 100644 index 5bb7e44d58f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.replace1/CPP/string.replace1.cpp +++ /dev/null @@ -1,16 +0,0 @@ - -// -using namespace System; -int main() -{ - String^ str = "1 2 3 4 5 6 7 8 9"; - Console::WriteLine( "Original string: \"{0}\"", str ); - Console::WriteLine( "CSV string: \"{0}\"", str->Replace( ' ', ',' ) ); -} - -// -// This example produces the following output: -// Original string: "1 2 3 4 5 6 7 8 9" -// CSV string: "1,2,3,4,5,6,7,8,9" -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.split3/CPP/omit.cpp b/snippets/cpp/VS_Snippets_CLR/string.split3/CPP/omit.cpp deleted file mode 100644 index c976a43115b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.split3/CPP/omit.cpp +++ /dev/null @@ -1,76 +0,0 @@ - -// -// This example demonstrates the String.Split(Char[], Boolean) and -// String.Split(Char[], Int32, Boolean) methods -using namespace System; -void Show( array^entries ) -{ - Console::WriteLine( "The return value contains these {0} elements:", entries->Length ); - System::Collections::IEnumerator^ myEnum = entries->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - String^ entry = safe_cast(myEnum->Current); - Console::Write( "<{0}>", entry ); - } - - Console::Write( "{0}{0}", Environment::NewLine ); -} - -int main() -{ - String^ s = ",one,,,two,,,,,three,,"; - array^sep = gcnew array{ - ',' - }; - array^result; - - // - Console::WriteLine( "The original string is \"{0}\".", s ); - Console::WriteLine( "The separation character is '{0}'.", sep[ 0 ] ); - Console::WriteLine(); - - // - Console::WriteLine( "Split the string and return all elements:" ); - result = s->Split( sep, StringSplitOptions::None ); - Show( result ); - - // - Console::WriteLine( "Split the string and return all non-empty elements:" ); - result = s->Split( sep, StringSplitOptions::RemoveEmptyEntries ); - Show( result ); - - // - Console::WriteLine( "Split the string and return 2 elements:" ); - result = s->Split( sep, 2, StringSplitOptions::None ); - Show( result ); - - // - Console::WriteLine( "Split the string and return 2 non-empty elements:" ); - result = s->Split( sep, 2, StringSplitOptions::RemoveEmptyEntries ); - Show( result ); -} - -/* -This example produces the following results: - -The original string is ",one,,,two,,,,,three,,". -The separation character is ','. - -Split the string and return all elements: -The return value contains these 12 elements: -<><><><><><><><><> - -Split the string and return all non-empty elements: -The return value contains these 3 elements: - - -Split the string and return 2 elements: -The return value contains these 2 elements: -<> - -Split the string and return 2 non-empty elements: -The return value contains these 2 elements: -<,,two,,,,,three,,> - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.tolower1/CPP/tolower.cpp b/snippets/cpp/VS_Snippets_CLR/string.tolower1/CPP/tolower.cpp deleted file mode 100644 index bb7a31a327d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.tolower1/CPP/tolower.cpp +++ /dev/null @@ -1,75 +0,0 @@ - -// -// Sample for String::ToLower(CultureInfo) -using namespace System; -using namespace System::Globalization; -void CodePoints( String^ title, String^ s ) -{ - Console::Write( "{0}The code points in {1} are: {0}", Environment::NewLine, title ); - System::Collections::IEnumerator^ myEnum = s->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - UInt16 u = safe_cast(myEnum->Current); - Console::Write( "{0:x4} ", u ); - } - - Console::WriteLine(); -} - -int main() -{ - String^ str1 = "INDIGO"; - - // str2 = str1, except each 'I' is '\u0130' (Unicode LATIN CAPITAL I WITH DOT ABOVE). - array^temp = {L'\u0130',L'N',L'D',L'\u0130',L'G',L'O'}; - String^ str2 = gcnew String( temp ); - String^ str3; - String^ str4; - Console::WriteLine(); - Console::WriteLine( "str1 = '{0}'", str1 ); - Console::WriteLine(); - Console::WriteLine( "str1 is {0} to str2.", ((0 == String::CompareOrdinal( str1, str2 )) ? (String^)"equal" : "not equal") ); - CodePoints( "str1", str1 ); - CodePoints( "str2", str2 ); - Console::WriteLine(); - - // str3 is a lower case copy of str2, using English-United States culture. - Console::WriteLine( "str3 = Lower case copy of str2 using English-United States culture." ); - str3 = str2->ToLower( gcnew CultureInfo( "en-US",false ) ); - - // str4 is a lower case copy of str2, using Turkish-Turkey culture. - Console::WriteLine( "str4 = Lower case copy of str2 using Turkish-Turkey culture." ); - str4 = str2->ToLower( gcnew CultureInfo( "tr-TR",false ) ); - - // Compare the code points in str3 and str4. - Console::WriteLine(); - Console::WriteLine( "str3 is {0} to str4.", ((0 == String::CompareOrdinal( str3, str4 )) ? (String^)"equal" : "not equal") ); - CodePoints( "str3", str3 ); - CodePoints( "str4", str4 ); -} - -/* -This example produces the following results: - -str1 = 'INDIGO' - -str1 is not equal to str2. - -The code points in str1 are: -0049 004e 0044 0049 0047 004f - -The code points in str2 are: -0130 004e 0044 0130 0047 004f - -str3 = Lower case copy of str2 using English-United States culture. -str4 = Lower case copy of str2 using Turkish-Turkey culture. - -str3 is equal to str4. - -The code points in str3 are: -0069 006e 0064 0069 0067 006f - -The code points in str4 are: -0069 006e 0064 0069 0067 006f -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/string.tostring/CPP/string.tostring.cpp b/snippets/cpp/VS_Snippets_CLR/string.tostring/CPP/string.tostring.cpp deleted file mode 100644 index 389fdf3e61a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/string.tostring/CPP/string.tostring.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -int main() -{ - String^ str1 = "123"; - String^ str2 = "abc"; - Console::WriteLine( "Original str1: {0}", str1 ); - Console::WriteLine( "Original str2: {0}", str2 ); - Console::WriteLine( "str1 same as str2?: {0}", Object::ReferenceEquals( str1, str2 ) ); - str2 = str1; - Console::WriteLine(); - Console::WriteLine( "New str2: {0}", str2 ); - Console::WriteLine( "str1 same as str2?: {0}", Object::ReferenceEquals( str1, str2 ) ); -} - -/* -This code produces the following output: -Original str1: 123 -Original str2: abc -str1 same as str2?: False - -New str2: 123 -str1 same as str2?: True -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/stringconcat3/CPP/stringconcat3.cpp b/snippets/cpp/VS_Snippets_CLR/stringconcat3/CPP/stringconcat3.cpp deleted file mode 100644 index 9f50fa95027..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringconcat3/CPP/stringconcat3.cpp +++ /dev/null @@ -1,22 +0,0 @@ - -// -using namespace System; - -int main() -{ - - // Make an array of strings. Note that we have included spaces. - array^s = { "hello ", "and ", "welcome ", "to ", - "this ", "demo! "}; - - // Put all the strings together. - Console::WriteLine( String::Concat(s) ); - - // Sort the strings, and put them together. - Array::Sort( s ); - Console::WriteLine( String::Concat(s)); -} -// The example displays the following output: -// hello and welcome to this demo! -// and demo! hello this to welcome -// diff --git a/snippets/cpp/VS_Snippets_CLR/stringconcat4/CPP/stringconcat4.cpp b/snippets/cpp/VS_Snippets_CLR/stringconcat4/CPP/stringconcat4.cpp deleted file mode 100644 index a8d0614ca35..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringconcat4/CPP/stringconcat4.cpp +++ /dev/null @@ -1,23 +0,0 @@ - -// -using namespace System; -int main() -{ - - // we want to simply quickly add this person's name together - String^ fName = "Simon"; - String^ mName = "Jake"; - String^ lName = "Harrows"; - - // because we want a name to appear with a space in between each name, - // put a space on the front of the middle, and last name, allowing for - // the fact that a space may already be there - mName = String::Concat( " ", mName->Trim() ); - lName = String::Concat( " ", lName->Trim() ); - - // this line simply concatenates the two strings - Console::WriteLine( "Welcome to this page, '{0}'!", String::Concat( String::Concat( fName, mName ), lName ) ); -} -// The example displays the following output: -// Welcome to this page, 'Simon Jake Harrows'! -// diff --git a/snippets/cpp/VS_Snippets_CLR/stringcopyto/CPP/stringcopyto.cpp b/snippets/cpp/VS_Snippets_CLR/stringcopyto/CPP/stringcopyto.cpp deleted file mode 100644 index 683bae6c061..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringcopyto/CPP/stringcopyto.cpp +++ /dev/null @@ -1,31 +0,0 @@ - -// -using namespace System; -int main() -{ - - // Embed an array of characters in a string - String^ strSource = "changed"; - array^destination = {'T','h','e',' ','i','n','i','t','i','a','l',' ','a','r','r','a','y'}; - - // Print the char array - Console::WriteLine( destination ); - - // Embed the source string in the destination string - strSource->CopyTo( 0, destination, 4, strSource->Length ); - - // Print the resulting array - Console::WriteLine( destination ); - strSource = "A different string"; - - // Embed only a section of the source string in the destination - strSource->CopyTo( 2, destination, 3, 9 ); - - // Print the resulting array - Console::WriteLine( destination ); -} -// The example displays the following output: -// The initial array -// The changed array -// Thedifferentarray -// diff --git a/snippets/cpp/VS_Snippets_CLR/stringendswith/CPP/stringendswith.cpp b/snippets/cpp/VS_Snippets_CLR/stringendswith/CPP/stringendswith.cpp deleted file mode 100644 index da9802a9dc7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringendswith/CPP/stringendswith.cpp +++ /dev/null @@ -1,76 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; - -String^ StripEndTags( String^ item ) -{ - bool found = false; - - // try to find a tag at the end of the line using EndsWith - if ( item->Trim()->EndsWith( ">" ) ) - { - - // now search for the opening tag... - int lastLocation = item->LastIndexOf( "= 0 ) { - item = item->Substring( 0, lastLocation ); - found = true; - } - } - - if (found) item = StripEndTags(item); - - return item; -} - -int main() -{ - - // process an input file that contains html tags. - // this sample checks for multiple tags at the end of the line, rather than simply - // removing the last one. - // note: HTML markup tags always end in a greater than symbol (>). - array^strSource = {"This is bold text","

This is large Text

","This has multiple tags","This has embedded tags.","This line simply ends with a greater than symbol, it should not be modified>"}; - Console::WriteLine( "The following lists the items before the ends have been stripped:" ); - Console::WriteLine( "-----------------------------------------------------------------" ); - - // print out the initial array of strings - IEnumerator^ myEnum1 = strSource->GetEnumerator(); - while ( myEnum1->MoveNext() ) - { - String^ s = safe_cast(myEnum1->Current); - Console::WriteLine( s ); - } - - Console::WriteLine(); - Console::WriteLine( "The following lists the items after the ends have been stripped:" ); - Console::WriteLine( "----------------------------------------------------------------" ); - - // Display the array of strings. - IEnumerator^ myEnum2 = strSource->GetEnumerator(); - while ( myEnum2->MoveNext() ) - { - String^ s = safe_cast(myEnum2->Current); - Console::WriteLine( StripEndTags( s ) ); - } -} -// The example displays the following output: -// The following lists the items before the ends have been stripped: -// ----------------------------------------------------------------- -// This is bold text -//

This is large Text

-// This has multiple tags -// This has embedded tags. -// This line simply ends with a greater than symbol, it should not be modified> -// -// The following lists the items after the ends have been stripped: -// ---------------------------------------------------------------- -// This is bold text -//

This is large Text -// This has multiple tags -// This has embedded tags. -// This line simply ends with a greater than symbol, it should not be modified> -// diff --git a/snippets/cpp/VS_Snippets_CLR/stringexample1/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/stringexample1/CPP/source.cpp deleted file mode 100644 index 4f76320ec42..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringexample1/CPP/source.cpp +++ /dev/null @@ -1,80 +0,0 @@ - - -// This is the main project file for VC++ application project -// generated using an Application Wizard. -#define _UNICODE - -#include - -using namespace System; -using namespace System::Text; - -// This is the entry point for this application -int _tmain( void ) -{ - // - // Unicode Mathematical operators - wchar_t charArray1[4] = {L'\x2200',L'\x2202',L'\x200F',L'\x2205'}; - wchar_t * lptstr1 = &charArray1[ 0 ]; - String^ wszMathSymbols = gcnew String( lptstr1 ); - - // Unicode Letterlike Symbols - wchar_t charArray2[4] = {L'\x2111',L'\x2118',L'\x2122',L'\x2126'}; - wchar_t * lptstr2 = &charArray2[ 0 ]; - String^ wszLetterLike = gcnew String( lptstr2 ); - - // Compare Strings - the result is false - Console::WriteLine( String::Concat( L"The Strings are equal? ", (0 == String::Compare( wszLetterLike, wszMathSymbols ) ? (String^)"TRUE" : "FALSE") ) ); - // - - // - // Null terminated ASCII characters in a simple char array - char charArray3[4] = {0x41,0x42,0x43,0x00}; - char * pstr3 = &charArray3[ 0 ]; - String^ szAsciiUpper = gcnew String( pstr3 ); - char charArray4[4] = {0x61,0x62,0x63,0x00}; - char * pstr4 = &charArray4[ 0 ]; - String^ szAsciiLower = gcnew String( pstr4,0,sizeof(charArray4) ); - - // Prints "ABC abc" - Console::WriteLine( String::Concat( szAsciiUpper, " ", szAsciiLower ) ); - - // Compare Strings - the result is true - Console::WriteLine( String::Concat( "The Strings are equal when capitalized ? ", (0 == String::Compare( szAsciiUpper->ToUpper(), szAsciiLower->ToUpper() ) ? (String^)"TRUE" : "FALSE") ) ); - - // This is the effective equivalent of another Compare method, which ignores case - Console::WriteLine( String::Concat( "The Strings are equal when capitalized ? ", (0 == String::Compare( szAsciiUpper, szAsciiLower, true ) ? (String^)"TRUE" : "FALSE") ) ); - // - - // - // Create a Unicode String with 5 Greek Alpha characters - String^ szGreekAlpha = gcnew String( L'\x0391',5 ); - - // Create a Unicode String with a Greek Omega character - wchar_t charArray5[3] = {L'\x03A9',L'\x03A9',L'\x03A9'}; - String^ szGreekOmega = gcnew String( charArray5,2,1 ); - String^ szGreekLetters = String::Concat( szGreekOmega, szGreekAlpha, szGreekOmega->Clone() ); - - // Examine the result - Console::WriteLine( szGreekLetters ); - - // The first index of Alpha - int ialpha = szGreekLetters->IndexOf( L'\x0391' ); - - // The last index of Omega - int iomega = szGreekLetters->LastIndexOf( L'\x03A9' ); - Console::WriteLine( String::Concat( "The Greek letter Alpha first appears at index ", Convert::ToString( ialpha ) ) ); - Console::WriteLine( String::Concat( " and Omega last appears at index ", Convert::ToString( iomega ), " in this String." ) ); - // - - // - char asciiChars[6] = {0x51,0x52,0x53,0x54,0x54,0x56}; - char * pstr6 = &asciiChars[ 0 ]; - UTF8Encoding^ encoding = gcnew UTF8Encoding( true,true ); - String^ utfeightstring = gcnew String( pstr6,0,sizeof(asciiChars),encoding ); - - // prints "QRSTTV" - Console::WriteLine( String::Concat( "The UTF8 String is ", utfeightstring ) ); - // - return 0; -} diff --git a/snippets/cpp/VS_Snippets_CLR/stringindexof4/CPP/stringindexof4.cpp b/snippets/cpp/VS_Snippets_CLR/stringindexof4/CPP/stringindexof4.cpp deleted file mode 100644 index 9ca351899a1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringindexof4/CPP/stringindexof4.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -// -using namespace System; -int main() -{ - String^ strSource = "This is the string which we will perform the search on"; - Console::WriteLine( "The search string is: {0}\"{1}\" {0}", Environment::NewLine, strSource ); - String^ strTarget = ""; - int found = 0; - int totFinds = 0; - do - { - Console::Write( "Please enter a search value to look for in the above string (hit Enter to exit) ==> " ); - strTarget = Console::ReadLine(); - if ( !strTarget->Equals( "" ) ) - { - for ( int i = 0; i < strSource->Length; i++ ) - { - found = strSource->IndexOf( strTarget, i ); - if (found >= 0) - { - totFinds++; - i = found; - } - else - break; - - } - } - else - return 0; - Console::WriteLine( "{0}The search parameter '{1}' was found {2} times. {0}", Environment::NewLine, strTarget, totFinds ); - totFinds = 0; - } - while ( true ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/stringinsert/CPP/stringinsert.cpp b/snippets/cpp/VS_Snippets_CLR/stringinsert/CPP/stringinsert.cpp deleted file mode 100644 index 1bd127d5ce3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringinsert/CPP/stringinsert.cpp +++ /dev/null @@ -1,30 +0,0 @@ - -// -using namespace System; - -int main() -{ - String^ animal1 = "fox"; - String^ animal2 = "dog"; - String^ strTarget = String::Format( "The {0} jumps over the {1}.", animal1, animal2 ); - Console::WriteLine( "The original string is:{0}{1}{0}", Environment::NewLine, strTarget ); - Console::Write( "Enter an adjective (or group of adjectives) to describe the {0}: ==> ", animal1 ); - String^ adj1 = Console::ReadLine(); - Console::Write( "Enter an adjective (or group of adjectives) to describe the {0}: ==> ", animal2 ); - String^ adj2 = Console::ReadLine(); - adj1 = String::Concat( adj1->Trim(), " " ); - adj2 = String::Concat( adj2->Trim(), " " ); - strTarget = strTarget->Insert( strTarget->IndexOf( animal1 ), adj1 ); - strTarget = strTarget->Insert( strTarget->IndexOf( animal2 ), adj2 ); - Console::WriteLine( " {0}The final string is: {0} {1}", Environment::NewLine, strTarget ); -} -// Output from the example might appear as follows: -// The original string is: -// The fox jumps over the dog. -// -// Enter an adjective (or group of adjectives) to describe the fox: ==> bold -// Enter an adjective (or group of adjectives) to describe the dog: ==> lazy -// -// The final string is: -// The bold fox jumps over the lazy dog. -// diff --git a/snippets/cpp/VS_Snippets_CLR/stringjoin/CPP/stringjoin.cpp b/snippets/cpp/VS_Snippets_CLR/stringjoin/CPP/stringjoin.cpp deleted file mode 100644 index 8f6a431148c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringjoin/CPP/stringjoin.cpp +++ /dev/null @@ -1,24 +0,0 @@ - -// -using namespace System; -String^ MakeLine( int initVal, int multVal, String^ sep ) -{ - array^sArr = gcnew array(10); - for ( int i = initVal; i < initVal + 10; i++ ) - sArr[ i - initVal ] = String::Format( "{0, -3}", i * multVal ); - return String::Join( sep, sArr ); -} - -int main() -{ - Console::WriteLine( MakeLine( 0, 5, ", " ) ); - Console::WriteLine( MakeLine( 1, 6, " " ) ); - Console::WriteLine( MakeLine( 9, 9, ": " ) ); - Console::WriteLine( MakeLine( 4, 7, "< " ) ); -} -// The example displays the following output: -// 0 , 5 , 10 , 15 , 20 , 25 , 30 , 35 , 40 , 45 -// 6 12 18 24 30 36 42 48 54 60 -// 81 : 90 : 99 : 108: 117: 126: 135: 144: 153: 162 -// 28 < 35 < 42 < 49 < 56 < 63 < 70 < 77 < 84 < 91 -// diff --git a/snippets/cpp/VS_Snippets_CLR/stringlowerupper/CPP/stringtolower.cpp b/snippets/cpp/VS_Snippets_CLR/stringlowerupper/CPP/stringtolower.cpp deleted file mode 100644 index 4ea0b86e8aa..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringlowerupper/CPP/stringtolower.cpp +++ /dev/null @@ -1,53 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; -int main() -{ - array^info = {"Name","Title","Age","Location","Gender"}; - Console::WriteLine( "The initial values in the array are:" ); - IEnumerator^ myEnum = info->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - String^ s = safe_cast(myEnum->Current); - Console::WriteLine( s ); - } - - Console::WriteLine( " {0}The lowercase of these values is:", Environment::NewLine ); - IEnumerator^ myEnum1 = info->GetEnumerator(); - while ( myEnum1->MoveNext() ) - { - String^ s = safe_cast(myEnum1->Current); - Console::WriteLine( s->ToLower() ); - } - - Console::WriteLine( " {0}The uppercase of these values is:", Environment::NewLine ); - IEnumerator^ myEnum2 = info->GetEnumerator(); - while ( myEnum2->MoveNext() ) - { - String^ s = safe_cast(myEnum2->Current); - Console::WriteLine( s->ToUpper() ); - } -} -// The example displays the following output: -// The initial values in the array are: -// Name -// Title -// Age -// Location -// Gender -// -// The lowercase of these values is: -// name -// title -// age -// location -// gender -// -// The uppercase of these values is: -// NAME -// TITLE -// AGE -// LOCATION -// GENDER -// diff --git a/snippets/cpp/VS_Snippets_CLR/stringremove/CPP/stringremove.cpp b/snippets/cpp/VS_Snippets_CLR/stringremove/CPP/stringremove.cpp deleted file mode 100644 index 4960d17021a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringremove/CPP/stringremove.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -int main() -{ - String^ name = "Michelle Violet Banks"; - Console::WriteLine( "The entire name is '{0}'", name ); - - // remove the middle name, identified by finding the spaces in the middle of the name->->. - int foundS1 = name->IndexOf( " " ); - int foundS2 = name->IndexOf( " ", foundS1 + 1 ); - if ( foundS1 != foundS2 && foundS1 >= 0 ) - { - name = name->Remove( foundS1 + 1, foundS2 - foundS1 ); - Console::WriteLine( "After removing the middle name, we are left with '{0}'", name ); - } -} -// The example displays the following output: -// The entire name is 'Michelle Violet Banks' -// After removing the middle name, we are left with 'Michelle Banks' -// diff --git a/snippets/cpp/VS_Snippets_CLR/stringreplace/CPP/stringreplace.cpp b/snippets/cpp/VS_Snippets_CLR/stringreplace/CPP/stringreplace.cpp deleted file mode 100644 index 4d7cac7c4d1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringreplace/CPP/stringreplace.cpp +++ /dev/null @@ -1,22 +0,0 @@ - -// -using namespace System; -int main() -{ - String^ errString = "This docment uses 3 other docments to docment the docmentation"; - Console::WriteLine( "The original string is:\n'{0}'\n", errString ); - - // Correct the spelling of S"document". - String^ correctString = errString->Replace( "docment", "document" ); - Console::WriteLine( "After correcting the string, the result is:\n'{0}'", correctString ); -} -// -// This code example produces the following output: -// -// The original string is: -// 'This docment uses 3 other docments to docment the docmentation' -// -// After correcting the string, the result is: -// 'This document uses 3 other documents to document the documentation' -// -// diff --git a/snippets/cpp/VS_Snippets_CLR/stringstartswith/CPP/stringstartswith.cpp b/snippets/cpp/VS_Snippets_CLR/stringstartswith/CPP/stringstartswith.cpp deleted file mode 100644 index 66a53e4c6dc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/stringstartswith/CPP/stringstartswith.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// -using namespace System; - -String^ StripStartTags( String^ item ) -{ - // Determine whether a tag begins the string. - if (item->Trim()->StartsWith("<")) { - // Find the closing tag. - int lastLocation = item->IndexOf(">"); - - // Remove the tag. - if ( lastLocation >= 0 ) { - item = item->Substring(lastLocation+ 1); - - // Remove any additional starting tags. - item = StripStartTags(item); - } - } - - return item; -} - -int main() -{ - array^ strSource = { "This is bold text", - "

This is large Text

", - "This has multiple tags", - "This has embedded tags.", - "This is bold text
-//

This is large Text

-// This has multiple tags -// This has embedded tags. -// -// This is large Text

-// This has multiple tags -// This has embedded tags.
-// diff --git a/snippets/cpp/VS_Snippets_CLR/type_getevents1/CPP/type_getevents1.cpp b/snippets/cpp/VS_Snippets_CLR/type_getevents1/CPP/type_getevents1.cpp deleted file mode 100644 index f2daabba2aa..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/type_getevents1/CPP/type_getevents1.cpp +++ /dev/null @@ -1,38 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Reflection; -using namespace System::Security; - -int main() -{ - try - { - Type^ myType = System::Windows::Forms::Button::typeid; - array^myEvents = myType->GetEvents(); - Console::WriteLine( "The events on the Button class are: " ); - for ( int index = 0; index < myEvents->Length; index++ ) - { - Console::WriteLine( myEvents[ index ] ); - - } - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException: {0}", e->Message ); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNullException: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/type_getevents2/CPP/type_getevents2.cpp b/snippets/cpp/VS_Snippets_CLR/type_getevents2/CPP/type_getevents2.cpp deleted file mode 100644 index 2c09a6f7f39..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/type_getevents2/CPP/type_getevents2.cpp +++ /dev/null @@ -1,41 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Reflection; -using namespace System::Security; - -int main() -{ - try - { - - // Create a bitmask based on BindingFlags. - BindingFlags myBindingFlags = static_cast(BindingFlags::Instance | BindingFlags::Public); - Type^ myTypeEvent = System::Windows::Forms::Button::typeid; - array^myEventsBindingFlags = myTypeEvent->GetEvents( myBindingFlags ); - Console::WriteLine( "\nThe events on the Button class with the specified BindingFlags are:" ); - for ( int index = 0; index < myEventsBindingFlags->Length; index++ ) - { - Console::WriteLine( myEventsBindingFlags[ index ] ); - - } - } - catch ( SecurityException^ e ) - { - Console::WriteLine( "SecurityException: {0}", e->Message ); - } - catch ( ArgumentNullException^ e ) - { - Console::WriteLine( "ArgumentNullException: {0}", e->Message ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/System.Convert UUEncodeDecode functions/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/System.Convert UUEncodeDecode functions/CPP/class1.cpp deleted file mode 100644 index 5b668e808cd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/System.Convert UUEncodeDecode functions/CPP/class1.cpp +++ /dev/null @@ -1,317 +0,0 @@ -using namespace System; -using namespace System::IO; - -ref class Coder -{ -private: - String^ inputFileName; - String^ outputFileName; - -public: - Coder( String^ inFile, String^ outFile ) - { - inputFileName = (String^)(inFile->Clone()); - outputFileName = (String^)(outFile->Clone()); - } - - // -public: - void EncodeWithString() - { - FileStream^ inFile; - array^ binaryData; - - try - { - inFile = gcnew FileStream( inputFileName, - FileMode::Open, - FileAccess::Read ); - binaryData = gcnew array((int)(inFile->Length)); - long bytesRead = inFile->Read( binaryData, 0, - (int)inFile->Length ); - inFile->Close(); - } - catch ( Exception^ exp ) - { - // Error creating stream or reading from it. - Console::WriteLine( " {0}", exp->Message ); - return; - } - - // Convert the binary input into Base64 UUEncoded output. - String^ base64String; - try - { - base64String = Convert::ToBase64String( binaryData, - 0, - binaryData->Length ); - } - catch ( ArgumentNullException^ ) - { - Console::WriteLine( "Binary data array is null." ); - return; - } - - // Write the UUEncoded version to the output file. - StreamWriter^ outFile; - try - { - outFile = gcnew StreamWriter( outputFileName, - false, - Text::Encoding::ASCII ); - outFile->Write( base64String ); - outFile->Close(); - } - catch ( Exception^ exp ) - { - - // Error creating stream or writing to it. - Console::WriteLine( " {0}", exp->Message ); - } - } - // - - // -public: - void EncodeWithCharArray() - { - FileStream^ inFile; - array^binaryData; - - try - { - inFile = gcnew FileStream( inputFileName, - FileMode::Open, - FileAccess::Read ); - binaryData = gcnew array((int)(inFile->Length)); - long bytesRead = inFile->Read( binaryData, 0, - (int)inFile->Length ); - inFile->Close(); - } - catch ( Exception^ exp ) - { - // Error creating stream or reading from it. - Console::WriteLine( "{0}", exp->Message ); - return; - } - - // Convert the binary input into Base64 UUEncoded output. - // Each 3 Byte sequence in the source data becomes a 4 Byte - // sequence in the character array. - long arrayLength = (long)((4.0 / 3.0) * binaryData->Length); - - // If array length is not divisible by 4, go up to the next - // multiple of 4. - if ( arrayLength % 4 != 0 ) - { - arrayLength += 4 - arrayLength % 4; - } - - array^ base64CharArray = gcnew array(arrayLength); - try - { - Convert::ToBase64CharArray( binaryData, - 0, - binaryData->Length, - base64CharArray, 0 ); - } - catch ( ArgumentNullException^ ) - { - Console::WriteLine( "Binary data array is null." ); - return; - } - catch ( ArgumentOutOfRangeException^ ) - { - Console::WriteLine( "Char Array is not large enough." ); - return; - } - - // Write the UUEncoded version to the output file. - StreamWriter^ outFile; - try - { - outFile = gcnew StreamWriter( outputFileName, - false, - Text::Encoding::ASCII ); - outFile->Write( base64CharArray ); - outFile->Close(); - } - catch ( Exception^ exp ) - { - // Error creating stream or writing to it. - Console::WriteLine( " {0}", exp->Message ); - } - } - // - - // -public: - void DecodeWithCharArray() - { - StreamReader^ inFile; - array^base64CharArray; - try - { - inFile = gcnew StreamReader( inputFileName, - Text::Encoding::ASCII ); - base64CharArray = gcnew array((int)(inFile->BaseStream->Length)); - inFile->Read( base64CharArray, 0, (int)inFile->BaseStream->Length ); - inFile->Close(); - } - catch ( Exception^ exp ) - { - - // Error creating stream or reading from it. - Console::WriteLine( "{0}", exp->Message ); - return; - } - - // Convert the Base64 UUEncoded input into binary output. - array^binaryData; - try - { - binaryData = Convert::FromBase64CharArray( base64CharArray, - 0, - base64CharArray->Length ); - } - catch ( ArgumentNullException^ ) - { - Console::WriteLine( "Base 64 character array is null." ); - return; - } - catch ( FormatException^ ) - { - Console::WriteLine( "Base 64 Char Array length is not " + - "4 or is not an even multiple of 4." ); - return; - } - - // Write out the decoded data. - FileStream^ outFile; - try - { - outFile = gcnew FileStream( outputFileName, - FileMode::Create, - FileAccess::Write ); - outFile->Write( binaryData, 0, binaryData->Length ); - outFile->Close(); - } - catch ( Exception^ exp ) - { - // Error creating stream or writing to it. - Console::WriteLine( "{0}", exp->Message ); - } - } - // - - // -public: - void DecodeWithString() - { - StreamReader^ inFile; - String^ base64String; - try - { - array^base64CharArray; - inFile = gcnew StreamReader( inputFileName, - Text::Encoding::ASCII ); - base64CharArray = gcnew array((int)(inFile->BaseStream->Length)); - inFile->Read( base64CharArray, 0, (int)inFile->BaseStream->Length ); - base64String = gcnew String( base64CharArray ); - } - catch ( Exception^ exp ) - { - // Error creating stream or reading from it. - Console::WriteLine( "{0}", exp->Message ); - return; - } - - // Convert the Base64 UUEncoded input into binary output. - array^binaryData; - try - { - binaryData = Convert::FromBase64String( base64String ); - } - catch ( ArgumentNullException^ ) - { - Console::WriteLine( "Base 64 String^ is null." ); - return; - } - catch ( FormatException^ ) - { - Console::WriteLine( "Base 64 String^ length is not " + - "4 or is not an even multiple of 4." ); - return; - } - - // Write out the decoded data. - FileStream^ outFile; - try - { - outFile = gcnew FileStream( outputFileName, - FileMode::Create, - FileAccess::Write ); - outFile->Write( binaryData, 0, binaryData->Length ); - outFile->Close(); - } - catch ( Exception^ exp ) - { - // Error creating stream or writing to it. - Console::WriteLine( "{0}", exp->Message ); - } - } - // -}; - -void main() -{ - array^ args = Environment::GetCommandLineArgs(); - if ( args->Length != 5 ) - { - Console::WriteLine( "Usage: UUCodeC -d | -e " + - "-s | -c inputFile outputFile" ); - return; - } - - String^ inputFileName = args[ 3 ]; - String^ outputFileName = args[ 4 ]; - Coder^ coder = gcnew Coder( inputFileName,outputFileName ); - - if ( args[ 1 ] == "-d" ) - { - if ( args[ 2 ] == "-s" ) - { - coder->DecodeWithString(); - } - else if ( args[ 2 ] == "-c" ) - { - coder->DecodeWithCharArray(); - } - else - { - Console::WriteLine( "Second arg must be -s or -c" ); - return; - } - } - else - if ( args[ 1 ] == "-e" ) - { - if ( args[ 2 ] == "-s" ) - { - coder->EncodeWithString(); - } - else if ( args[ 2 ] == "-c" ) - { - coder->EncodeWithCharArray(); - } - else - { - Console::WriteLine( "Second arg must be -s or -c" ); - return; - } - } - else - { - Console::WriteLine( "First arg must be -d or -e" ); - } -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.Others/CPP/cfromchar.cpp b/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.Others/CPP/cfromchar.cpp deleted file mode 100644 index a03e6c881a2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.Others/CPP/cfromchar.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// -using namespace System; - -void main() -{ - // Define an array of Char values. - array^ values = { L'\0', L' ', L'*', L'A', L'a', - L'{', L'Æ' }; - - // Convert each Char value to a Decimal. - for each (wchar_t value in values) { - Decimal decValue = value; - Console::WriteLine("'{0}' ({1}) --> {2} ({3})", value, - value.GetType()->Name, decValue, - decValue.GetType()->Name); - } -} -// This example displays the following output: -// ' ' (Decimal) --> 0 (Decimal) -// ' ' (Decimal) --> 32 (Decimal) -// '*' (Decimal) --> 42 (Decimal) -// 'A' (Decimal) --> 65 (Decimal) -// 'a' (Decimal) --> 97 (Decimal) -// '{' (Decimal) --> 123 (Decimal) -// 'A' (Decimal) --> 195 (Decimal) -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.Others/CPP/cfromdouble.cpp b/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.Others/CPP/cfromdouble.cpp deleted file mode 100644 index f923cdfb25d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.Others/CPP/cfromdouble.cpp +++ /dev/null @@ -1,66 +0,0 @@ - -// -// Example of the explicit conversion from double to Decimal. -using namespace System; -#define formatter "{0,25:E16}{1,33}" - -// Get the exception type name; remove the namespace prefix. -String^ GetExceptionType( Exception^ ex ) -{ - String^ exceptionType = ex->GetType()->ToString(); - return exceptionType->Substring( exceptionType->LastIndexOf( '.' ) + 1 ); -} - - -// Convert the double argument; catch exceptions that are thrown. -void DecimalFromDouble( double argument ) -{ - Object^ decValue; - - // Convert the double argument to a Decimal value. - try - { - decValue = (Decimal)argument; - } - catch ( Exception^ ex ) - { - decValue = GetExceptionType( ex ); - } - - Console::WriteLine( formatter, argument, decValue ); -} - -int main() -{ - Console::WriteLine( "This example of the explicit conversion from double " - "to Decimal \ngenerates the following output.\n" ); - Console::WriteLine( formatter, "double argument", "Decimal value" ); - Console::WriteLine( formatter, "---------------", "-------------" ); - - // Convert double values and display the results. - DecimalFromDouble( 1.234567890123E-30 ); - DecimalFromDouble( 1.2345678901234E-25 ); - DecimalFromDouble( 1.23456789012345E-20 ); - DecimalFromDouble( 1.234567890123456E-10 ); - DecimalFromDouble( 1.2345678901234567 ); - DecimalFromDouble( 1.23456789012345678E+12 ); - DecimalFromDouble( 1.234567890123456789E+28 ); - DecimalFromDouble( 1.234567890123456789E+30 ); -} - -/* -This example of the explicit conversion from double to Decimal -generates the following output. - - double argument Decimal value - --------------- ------------- - 1.2345678901230000E-030 0 - 1.2345678901233999E-025 0.0000000000000000000000001235 - 1.2345678901234499E-020 0.0000000000000000000123456789 - 1.2345678901234560E-010 0.000000000123456789012346 - 1.2345678901234567E+000 1.23456789012346 - 1.2345678901234568E+012 1234567890123.46 - 1.2345678901234568E+028 12345678901234600000000000000 - 1.2345678901234569E+030 OverflowException -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.Others/CPP/cfromsingle.cpp b/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.Others/CPP/cfromsingle.cpp deleted file mode 100644 index 2b8674f5b9b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.Others/CPP/cfromsingle.cpp +++ /dev/null @@ -1,66 +0,0 @@ - -// -// Example of the explicit conversion from float to Decimal. -using namespace System; -#define formatter "{0,16:E7}{1,33}" - -// Get the exception type name; remove the namespace prefix. -String^ GetExceptionType( Exception^ ex ) -{ - String^ exceptionType = ex->GetType()->ToString(); - return exceptionType->Substring( exceptionType->LastIndexOf( '.' ) + 1 ); -} - - -// Convert the float argument; catch exceptions that are thrown. -void DecimalFromSingle( float argument ) -{ - Object^ decValue; - - // Convert the float argument to a Decimal value. - try - { - decValue = (Decimal)argument; - } - catch ( Exception^ ex ) - { - decValue = GetExceptionType( ex ); - } - - Console::WriteLine( formatter, argument, decValue ); -} - -int main() -{ - Console::WriteLine( "This example of the explicit conversion from float " - "to Decimal \ngenerates the following output.\n" ); - Console::WriteLine( formatter, "float argument", "Decimal value" ); - Console::WriteLine( formatter, "--------------", "-------------" ); - - // Convert float values and display the results. - DecimalFromSingle( 1.2345E-30F ); - DecimalFromSingle( 1.2345E-26F ); - DecimalFromSingle( 1.23456E-22F ); - DecimalFromSingle( 1.23456E-12F ); - DecimalFromSingle( 1.234567F ); - DecimalFromSingle( 1.234567E+12F ); - DecimalFromSingle( 1.2345678E+28F ); - DecimalFromSingle( 1.2345678E+30F ); -} - -/* -This example of the explicit conversion from float to Decimal -generates the following output. - - float argument Decimal value - -------------- ------------- - 1.2345000E-030 0 - 1.2345000E-026 0.0000000000000000000000000123 - 1.2345600E-022 0.000000000000000000000123456 - 1.2345600E-012 0.00000000000123456 - 1.2345671E+000 1.234567 - 1.2345670E+012 1234567000000 - 1.2345678E+028 12345680000000000000000000000 - 1.2345678E+030 OverflowException -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.SInts/CPP/cfromint16.cpp b/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.SInts/CPP/cfromint16.cpp deleted file mode 100644 index 6d1843e5d96..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.SInts/CPP/cfromint16.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// -using namespace System; - -void main() -{ - // Define an array of 16-bit integer values. - array^ values = { Int16::MinValue, Int16::MaxValue, - 0xFFF, 12345, -10000 }; - // Convert each value to a Decimal. - for each (Int16 value in values) { - Decimal decValue = value; - Console::WriteLine("{0} ({1}) --> {2} ({3})", value, - value.GetType()->Name, decValue, - decValue.GetType()->Name); - } -} -// The example displays the following output: -// -32768 (Int16) --> -32768 (Decimal) -// 32767 (Int16) --> 32767 (Decimal) -// 4095 (Int16) --> 4095 (Decimal) -// 12345 (Int16) --> 12345 (Decimal) -// -10000 (Int16) --> -10000 (Decimal) -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.SInts/CPP/cfromint32.cpp b/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.SInts/CPP/cfromint32.cpp deleted file mode 100644 index 02af50b7b64..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.SInts/CPP/cfromint32.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// -using namespace System; - -void main() -{ - // Define an array of 32-bit integer values. - array^ values = { Int32::MinValue, Int32::MaxValue, - 0xFFFFFF, 123456789, -1000000000 }; - // Convert each value to a Decimal. - for each (Int32 value in values) { - Decimal decValue = value; - Console::WriteLine("{0} ({1}) --> {2} ({3})", value, - value.GetType()->Name, decValue, - decValue.GetType()->Name); - } -} -// The example displays the following output: -// -2147483648 (Int32) --> -2147483648 (Decimal) -// 2147483647 (Int32) --> 2147483647 (Decimal) -// 16777215 (Int32) --> 16777215 (Decimal) -// 123456789 (Int32) --> 123456789 (Decimal) -// -1000000000 (Int32) --> -1000000000 (Decimal) -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.SInts/CPP/cfromint64.cpp b/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.SInts/CPP/cfromint64.cpp deleted file mode 100644 index 6276b339c09..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.SInts/CPP/cfromint64.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// -using namespace System; - -void main() -{ - // Define an array of 64-bit integer values. - array^ values = { Int64::MinValue, Int64::MaxValue, - 0xFFFFFFFFFFFF, 123456789123456789, - -1000000000000000 }; - // Convert each value to a Decimal. - for each (Int64 value in values) { - Decimal decValue = value; - Console::WriteLine("{0} ({1}) --> {2} ({3})", value, - value.GetType()->Name, decValue, - decValue.GetType()->Name); - } -} -// The example displays the following output: -// -9223372036854775808 (Int64) --> -9223372036854775808 (Decimal) -// 9223372036854775807 (Int64) --> 9223372036854775807 (Decimal) -// 281474976710655 (Int64) --> 281474976710655 (Decimal) -// 123456789123456789 (Int64) --> 123456789123456789 (Decimal) -// -1000000000000000 (Int64) --> -1000000000000000 (Decimal) -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.SInts/CPP/cfromsbyte.cpp b/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.SInts/CPP/cfromsbyte.cpp deleted file mode 100644 index 7dc5e10fb54..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.SInts/CPP/cfromsbyte.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// -using namespace System; - -void main() -{ - // Define an array of 8-bit signed integer values. - array^ values = { SByte::MinValue, SByte::MaxValue, - 0x3F, 123, -100 }; - // Convert each value to a Decimal. - for each (SByte value in values) { - Decimal decValue = value; - Console::WriteLine("{0} ({1}) --> {2} ({3})", value, - value.GetType()->Name, decValue, - decValue.GetType()->Name); - } -} -// The example displays the following output: -// -128 (SByte) --> -128 (Decimal) -// 127 (SByte) --> 127 (Decimal) -// 63 (SByte) --> 63 (Decimal) -// 123 (SByte) --> 123 (Decimal) -// -100 (SByte) --> -100 (Decimal) -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.UInts/CPP/cfrombyte.cpp b/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.UInts/CPP/cfrombyte.cpp deleted file mode 100644 index f1aeb921e60..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.UInts/CPP/cfrombyte.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// -using namespace System; - -void main() -{ - // Define an array of byte values. - array^ values = { Byte::MinValue, Byte::MaxValue, - 0x3F, 123, 200 }; - // Convert each value to a Decimal. - for each (Byte value in values) { - Decimal decValue = value; - Console::WriteLine("{0} ({1}) --> {2} ({3})", value, - value.GetType()->Name, decValue, - decValue.GetType()->Name); - } -} -// The example displays the following output: -// 0 (Byte) --> 0 (Decimal) -// 255 (Byte) --> 255 (Decimal) -// 63 (Byte) --> 63 (Decimal) -// 123 (Byte) --> 123 (Decimal) -// 200 (Byte) --> 200 (Decimal) -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.UInts/CPP/cfromuint16.cpp b/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.UInts/CPP/cfromuint16.cpp deleted file mode 100644 index 05b5707b713..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.UInts/CPP/cfromuint16.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// -using namespace System; - -void main() -{ - // Define an array of 16-bit unsigned integer values. - array^ values = { UInt16::MinValue, UInt16::MaxValue, - 0xFFF, 12345, 40000 }; - // Convert each value to a Decimal. - for each (UInt16 value in values) { - Decimal decValue = value; - Console::WriteLine("{0} ({1}) --> {2} ({3})", value, - value.GetType()->Name, decValue, - decValue.GetType()->Name); - } -} -// The example displays the following output: -// 0 (UInt16) --> 0 (Decimal) -// 65535 (UInt16) --> 65535 (Decimal) -// 4095 (UInt16) --> 4095 (Decimal) -// 12345 (UInt16) --> 12345 (Decimal) -// 40000 (UInt16) --> 40000 (Decimal) -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.UInts/CPP/cfromuint32.cpp b/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.UInts/CPP/cfromuint32.cpp deleted file mode 100644 index 66304c49b67..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.UInts/CPP/cfromuint32.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// -using namespace System; - -void main() -{ - // Define an array of 32-bit unsigned integer values. - array^ values = { UInt32::MinValue, UInt32::MaxValue, - 0xFFFFFF, 123456789, 4000000000 }; - // Convert each value to a Decimal. - for each (UInt32 value in values) { - Decimal decValue = value; - Console::WriteLine("{0} ({1}) --> {2} ({3})", value, - value.GetType()->Name, decValue, - decValue.GetType()->Name); - } -} -// The example displays the following output: -// 0 (UInt32) --> 0 (Decimal) -// 4294967295 (UInt32) --> 4294967295 (Decimal) -// 16777215 (UInt32) --> 16777215 (Decimal) -// 123456789 (UInt32) --> 123456789 (Decimal) -// 4000000000 (UInt32) --> 4000000000 (Decimal) -// - diff --git a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.UInts/CPP/cfromuint64.cpp b/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.UInts/CPP/cfromuint64.cpp deleted file mode 100644 index 83f40b676ed..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.UInts/CPP/cfromuint64.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// -using namespace System; - -void main() -{ - // Define an array of 64-bit unsigned integer values. - array^ values = { UInt64::MinValue, UInt64::MaxValue, - 0xFFFFFFFFFFFF, 123456789123456789, - 1000000000000000 }; - // Convert each value to a Decimal. - for each (UInt64 value in values) { - Decimal decValue = value; - Console::WriteLine("{0} ({1}) --> {2} ({3})", value, - value.GetType()->Name, decValue, - decValue.GetType()->Name); - } -} -// The example displays the following output: -// 0 (UInt64) --> 0 (Decimal) -// 18446744073709551615 (UInt64) --> 18446744073709551615 (Decimal) -// 281474976710655 (UInt64) --> 281474976710655 (Decimal) -// 123456789123456789 (UInt64) --> 123456789123456789 (Decimal) -// 1000000000000000 (UInt64) --> 1000000000000000 (Decimal) -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvTo/CPP/ctos_byte.cpp b/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvTo/CPP/ctos_byte.cpp deleted file mode 100644 index b129d97d402..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvTo/CPP/ctos_byte.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// -using namespace System; - -void main() -{ - // Define an array of decimal values. - array^ values = { Decimal::Parse("78"), - Decimal(78000,0,0,false,3), - Decimal::Parse("78.999"), - Decimal::Parse("255.999"), - Decimal::Parse("256"), - Decimal::Parse("127.999"), - Decimal::Parse("128"), - Decimal::Parse("-0.999"), - Decimal::Parse("-1"), - Decimal::Parse("-128.999"), - Decimal::Parse("-129") }; - for each (Decimal value in values) { - try { - Byte byteValue = (Byte) value; - Console::WriteLine("{0} ({1}) --> {2} ({3})", value, - value.GetType()->Name, byteValue, - byteValue.GetType()->Name); - } - catch (OverflowException^ e) { - Console::WriteLine("OverflowException: Cannot convert {0}", - value); - } - } -} -// The example displays the following output: -// 78 (Decimal) --> 78 (Byte) -// 78.000 (Decimal) --> 78 (Byte) -// 78.999 (Decimal) --> 78 (Byte) -// 255.999 (Decimal) --> 255 (Byte) -// OverflowException: Cannot convert 256 -// 127.999 (Decimal) --> 127 (Byte) -// 128 (Decimal) --> 128 (Byte) -// -0.999 (Decimal) --> 0 (Byte) -// OverflowException: Cannot convert -1 -// OverflowException: Cannot convert -128.999 -// OverflowException: Cannot convert -129 -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvTo/CPP/ctosgl_dbl.cpp b/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvTo/CPP/ctosgl_dbl.cpp deleted file mode 100644 index b9c5dfa766d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvTo/CPP/ctosgl_dbl.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// -using namespace System; - -void main() -{ - // Define an array of Decimal values. - array^ values = { Decimal::Parse("0.0000000000000000000000000001"), - Decimal::Parse("0.0000000000123456789123456789"), - Decimal::Parse("123"), - Decimal(123000000, 0, 0, false, 6), - Decimal::Parse("123456789.123456789"), - Decimal::Parse("123456789123456789123456789"), - Decimal::MinValue, Decimal::MaxValue }; - // Convert each value to a double. - for each (Decimal value in values) { - double dblValue = (double) value; - Console::WriteLine("{0} ({1}) --> {2} ({3})", value, - value.GetType()->Name, dblValue, - dblValue.GetType()->Name); - } -} -// The example displays the following output: -// 0.0000000000000000000000000001 (Decimal) --> 1E-28 (Double) -// 0.0000000000123456789123456789 (Decimal) --> 1.23456789123457E-11 (Double) -// 123 (Decimal) --> 123 (Double) -// 123.000000 (Decimal) --> 123 (Double) -// 123456789.123456789 (Decimal) --> 123456789.123457 (Double) -// 123456789123456789123456789 (Decimal) --> 1.23456789123457E+26 (Double) -// -79228162514264337593543950335 (Decimal) --> -7.92281625142643E+28 (Double) -// 79228162514264337593543950335 (Decimal) --> 7.92281625142643E+28 (Double) -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvTo/CPP/ctou_int16.cpp b/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvTo/CPP/ctou_int16.cpp deleted file mode 100644 index ba9c3b99b99..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvTo/CPP/ctou_int16.cpp +++ /dev/null @@ -1,88 +0,0 @@ - -// -// Example of the explicit conversions from Decimal to short and -// Decimal to unsigned short. -using namespace System; -#define formatter "{0,16}{1,19}{2,19}" - -// Get the exception type name; remove the namespace prefix. -String^ GetExceptionType( Exception^ ex ) -{ - String^ exceptionType = ex->GetType()->ToString(); - return exceptionType->Substring( exceptionType->LastIndexOf( '.' ) + 1 ); -} - - -// Convert the Decimal argument; catch exceptions that are thrown. -void DecimalToU_Int16( Decimal argument ) -{ - Object^ Int16Value; - Object^ UInt16Value; - - // Convert the argument to a short value. - try - { - Int16Value = (short)argument; - } - catch ( Exception^ ex ) - { - Int16Value = GetExceptionType( ex ); - } - - - // Convert the argument to an unsigned short value. - try - { - UInt16Value = (unsigned short)argument; - } - catch ( Exception^ ex ) - { - UInt16Value = GetExceptionType( ex ); - } - - Console::WriteLine( formatter, argument, Int16Value, UInt16Value ); -} - -int main() -{ - Console::WriteLine( "This example of the explicit conversions from Decimal to " - "short \nand Decimal to unsigned short generates the " - "following output. \nIt displays several converted Decimal " - "values.\n" ); - Console::WriteLine( formatter, "Decimal argument", "short", "unsigned short" ); - Console::WriteLine( formatter, "----------------", "-----", "--------------" ); - - // Convert Decimal values and display the results. - DecimalToU_Int16( Decimal::Parse( "123" ) ); - DecimalToU_Int16( Decimal(123000,0,0,false,3) ); - DecimalToU_Int16( Decimal::Parse( "123.999" ) ); - DecimalToU_Int16( Decimal::Parse( "65535.999" ) ); - DecimalToU_Int16( Decimal::Parse( "65536" ) ); - DecimalToU_Int16( Decimal::Parse( "32767.999" ) ); - DecimalToU_Int16( Decimal::Parse( "32768" ) ); - DecimalToU_Int16( Decimal::Parse( "-0.999" ) ); - DecimalToU_Int16( Decimal::Parse( "-1" ) ); - DecimalToU_Int16( Decimal::Parse( "-32768.999" ) ); - DecimalToU_Int16( Decimal::Parse( "-32769" ) ); -} - -/* -This example of the explicit conversions from Decimal to short -and Decimal to unsigned short generates the following output. -It displays several converted Decimal values. - -Decimal argument short unsigned short ----------------- ----- -------------- - 123 123 123 - 123.000 123 123 - 123.999 123 123 - 65535.999 OverflowException 65535 - 65536 OverflowException OverflowException - 32767.999 32767 32767 - 32768 OverflowException 32768 - -0.999 0 0 - -1 -1 OverflowException - -32768.999 -32768 OverflowException - -32769 OverflowException OverflowException -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvTo/CPP/ctou_int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvTo/CPP/ctou_int32.cpp deleted file mode 100644 index 02cb0e6339f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvTo/CPP/ctou_int32.cpp +++ /dev/null @@ -1,88 +0,0 @@ - -// -// Example of the explicit conversions from Decimal to int and -// Decimal to unsigned int. -using namespace System; -#define formatter "{0,17}{1,19}{2,19}" - -// Get the exception type name; remove the namespace prefix. -String^ GetExceptionType( Exception^ ex ) -{ - String^ exceptionType = ex->GetType()->ToString(); - return exceptionType->Substring( exceptionType->LastIndexOf( '.' ) + 1 ); -} - - -// Convert the Decimal argument; catch exceptions that are thrown. -void DecimalToU_Int32( Decimal argument ) -{ - Object^ Int32Value; - Object^ UInt32Value; - - // Convert the argument to an int value. - try - { - Int32Value = (int)argument; - } - catch ( Exception^ ex ) - { - Int32Value = GetExceptionType( ex ); - } - - - // Convert the argument to an unsigned int value. - try - { - UInt32Value = (unsigned int)argument; - } - catch ( Exception^ ex ) - { - UInt32Value = GetExceptionType( ex ); - } - - Console::WriteLine( formatter, argument, Int32Value, UInt32Value ); -} - -int main() -{ - Console::WriteLine( "This example of the explicit conversions from Decimal to " - "int \nand Decimal to unsigned int generates the " - "following output. \nIt displays several converted Decimal " - "values.\n" ); - Console::WriteLine( formatter, "Decimal argument", "int", "unsigned int" ); - Console::WriteLine( formatter, "----------------", "---", "------------" ); - - // Convert Decimal values and display the results. - DecimalToU_Int32( Decimal::Parse( "123" ) ); - DecimalToU_Int32( Decimal(123000,0,0,false,3) ); - DecimalToU_Int32( Decimal::Parse( "123.999" ) ); - DecimalToU_Int32( Decimal::Parse( "4294967295.999" ) ); - DecimalToU_Int32( Decimal::Parse( "4294967296" ) ); - DecimalToU_Int32( Decimal::Parse( "2147483647.999" ) ); - DecimalToU_Int32( Decimal::Parse( "2147483648" ) ); - DecimalToU_Int32( Decimal::Parse( "-0.999" ) ); - DecimalToU_Int32( Decimal::Parse( "-1" ) ); - DecimalToU_Int32( Decimal::Parse( "-2147483648.999" ) ); - DecimalToU_Int32( Decimal::Parse( "-2147483649" ) ); -} - -/* -This example of the explicit conversions from Decimal to int -and Decimal to unsigned int generates the following output. -It displays several converted Decimal values. - - Decimal argument int unsigned int - ---------------- --- ------------ - 123 123 123 - 123.000 123 123 - 123.999 123 123 - 4294967295.999 OverflowException 4294967295 - 4294967296 OverflowException OverflowException - 2147483647.999 2147483647 2147483647 - 2147483648 OverflowException 2147483648 - -0.999 0 0 - -1 -1 OverflowException - -2147483648.999 -2147483648 OverflowException - -2147483649 OverflowException OverflowException -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvTo/CPP/ctou_int64.cpp b/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvTo/CPP/ctou_int64.cpp deleted file mode 100644 index 5beaab71f7f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvTo/CPP/ctou_int64.cpp +++ /dev/null @@ -1,88 +0,0 @@ - -// -// Example of the explicit conversions from Decimal to __int64 and -// Decimal to unsigned __int64. -using namespace System; -#define formatter "{0,25}{1,22}{2,22}" - -// Get the exception type name; remove the namespace prefix. -String^ GetExceptionType( Exception^ ex ) -{ - String^ exceptionType = ex->GetType()->ToString(); - return exceptionType->Substring( exceptionType->LastIndexOf( '.' ) + 1 ); -} - - -// Convert the Decimal argument; catch exceptions that are thrown. -void DecimalToU_Int64( Decimal argument ) -{ - Object^ Int64Value; - Object^ UInt64Value; - - // Convert the argument to an __int64 value. - try - { - Int64Value = (__int64)argument; - } - catch ( Exception^ ex ) - { - Int64Value = GetExceptionType( ex ); - } - - - // Convert the argument to an unsigned __int64 value. - try - { - UInt64Value = (unsigned __int64)argument; - } - catch ( Exception^ ex ) - { - UInt64Value = GetExceptionType( ex ); - } - - Console::WriteLine( formatter, argument, Int64Value, UInt64Value ); -} - -int main() -{ - Console::WriteLine( "This example of the explicit conversions from Decimal to " - "__int64 \nand Decimal to unsigned __int64 generates the " - "following output. \nIt displays several converted Decimal " - "values.\n" ); - Console::WriteLine( formatter, "Decimal argument", "__int64", "unsigned __int64" ); - Console::WriteLine( formatter, "----------------", "-------", "----------------" ); - - // Convert Decimal values and display the results. - DecimalToU_Int64( Decimal::Parse( "123" ) ); - DecimalToU_Int64( Decimal(123000,0,0,false,3) ); - DecimalToU_Int64( Decimal::Parse( "123.999" ) ); - DecimalToU_Int64( Decimal::Parse( "18446744073709551615.999" ) ); - DecimalToU_Int64( Decimal::Parse( "18446744073709551616" ) ); - DecimalToU_Int64( Decimal::Parse( "9223372036854775807.999" ) ); - DecimalToU_Int64( Decimal::Parse( "9223372036854775808" ) ); - DecimalToU_Int64( Decimal::Parse( "-0.999" ) ); - DecimalToU_Int64( Decimal::Parse( "-1" ) ); - DecimalToU_Int64( Decimal::Parse( "-9223372036854775808.999" ) ); - DecimalToU_Int64( Decimal::Parse( "-9223372036854775809" ) ); -} - -/* -This example of the explicit conversions from Decimal to __int64 -and Decimal to unsigned __int64 generates the following output. -It displays several converted Decimal values. - - Decimal argument __int64 unsigned __int64 - ---------------- ------- ---------------- - 123 123 123 - 123.000 123 123 - 123.999 123 123 - 18446744073709551615.999 OverflowException 18446744073709551615 - 18446744073709551616 OverflowException OverflowException - 9223372036854775807.999 9223372036854775807 9223372036854775807 - 9223372036854775808 OverflowException 9223372036854775808 - -0.999 0 0 - -1 -1 OverflowException - -9223372036854775808.999 -9223372036854775808 OverflowException - -9223372036854775809 OverflowException OverflowException -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/System.String.Substring/cpp/Substring10.cpp b/snippets/cpp/VS_Snippets_CLR_System/System.String.Substring/cpp/Substring10.cpp deleted file mode 100644 index ffc578df28f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/System.String.Substring/cpp/Substring10.cpp +++ /dev/null @@ -1,35 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; - -int main() -{ - array^info = { "Name: Felica Walker", "Title: Mz.", - "Age: 47", "Location: Paris", "Gender: F"}; - int found = 0; - Console::WriteLine("The initial values in the array are:"); - for each (String^ s in info) - Console::WriteLine(s); - - Console::WriteLine("\nWe want to retrieve only the key information. That is:"); - for each (String^ s in info) { - found = s->IndexOf(": "); - Console::WriteLine(" {0}", s->Substring(found + 2)); - } -} -// The example displays the following output: -// The initial values in the array are: -// Name: Felica Walker -// Title: Mz. -// Age: 47 -// Location: Paris -// Gender: F -// -// We want to retrieve only the key information. That is: -// Felica Walker -// Mz. -// 47 -// Paris -// F -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Action/cpp/action.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Action/cpp/action.cpp deleted file mode 100644 index df9aa3a8a84..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Action/cpp/action.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// Action.cpp : main project file. - -//#include "stdafx.h" - -// -#using - -using namespace System; -using namespace System::Windows::Forms; - -public ref class Name -{ -private: - String^ instanceName; - -public: - Name(String^ name) - { - instanceName = name; - } - - void DisplayToConsole() - { - Console::WriteLine(this->instanceName); - } - - void DisplayToWindow() - { - MessageBox::Show(this->instanceName); - } -}; - - -int main() -{ - Name^ testName = gcnew Name(L"Koani"); - System::Action^ showMethod; - showMethod += gcnew Action(testName, &Name::DisplayToWindow); - showMethod(); - return 0; -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Action~1/cpp/action`1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Action~1/cpp/action`1.cpp deleted file mode 100644 index c593825b090..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Action~1/cpp/action`1.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// Action`1.cpp : main project file. - -//#include "stdafx.h" - -// -#using - -using namespace System; -using namespace System::Windows::Forms; - -namespace ActionExample -{ - public ref class Message - { - public: - static void ShowWindowsMessage(String^ message) - { - MessageBox::Show(message); - } - }; -} - -int main() -{ - Action^ messageTarget; - - if (Environment::GetCommandLineArgs()->Length > 1) - messageTarget = gcnew Action(&ActionExample::Message::ShowWindowsMessage); - else - messageTarget = gcnew Action(&Console::WriteLine); - - messageTarget("Hello, World!"); - return 0; -} -// - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Action~1/cpp/delegate.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Action~1/cpp/delegate.cpp deleted file mode 100644 index 143680f77d9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Action~1/cpp/delegate.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// Delegate.cpp : main project file. - -//#include "stdafx.h" - -// -#using - -using namespace System; -using namespace System::Windows::Forms; - -public delegate void DisplayMessage(String^ message); - -public ref class TestCustomDelegate -{ -public: - static void ShowWindowsMessage(String^ message) - { - MessageBox::Show(message); - } -}; - -int main() -{ - DisplayMessage^ messageTarget; - - if (Environment::GetCommandLineArgs()->Length > 1) - messageTarget = gcnew DisplayMessage(&TestCustomDelegate::ShowWindowsMessage); - else - messageTarget = gcnew DisplayMessage(&Console::WriteLine); - - messageTarget(L"Hello World!"); - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Array.AsReadOnly/CPP/arrayasreadonly.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Array.AsReadOnly/CPP/arrayasreadonly.cpp deleted file mode 100644 index bc76d292564..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Array.AsReadOnly/CPP/arrayasreadonly.cpp +++ /dev/null @@ -1,116 +0,0 @@ -// The following example wraps an array in a read-only IList. -#using - -// -using namespace System; -using namespace System::Collections::Generic; - -namespace Samples -{ - public ref class SamplesArray - { - public: - static void Work() - { - - // Create and initialize a new string array. - array ^ textArray = - {"The", "quick", "brown", "fox"}; - - // Display the values of the array. - Console::WriteLine("The string array initially contains " - "the following values:"); - PrintIndexAndValues(textArray); - - // Create a read-only IList wrapper around the array. - IList ^ textList = Array::AsReadOnly(textArray); - - // Display the values of the read-only IList. - Console::WriteLine("The read-only IList contains " - "the following values:"); - PrintIndexAndValues(textList); - - // Attempt to change a value through the wrapper. - try - { - textList[3] = "CAT"; - } - catch (NotSupportedException^ ex) - { - Console::WriteLine("{0} - {1}", ex->GetType(), - ex->Message); - Console::WriteLine(); - } - - - // Change a value in the original array. - textArray[2] = "RED"; - - // Display the values of the array. - Console::WriteLine("After changing the third element," - "the string array contains the following values:"); - PrintIndexAndValues(textArray); - - // Display the values of the read-only IList. - Console::WriteLine("After changing the third element, the" - " read-only IList contains the following values:"); - PrintIndexAndValues(textList); - } - - static void PrintIndexAndValues(array^ textArray) - { - for (int i = 0; i < textArray->Length; i++) - { - Console::WriteLine(" [{0}] : {1}", i, textArray[i]); - } - Console::WriteLine(); - } - - static void PrintIndexAndValues(IList^ textList) - { - for (int i = 0; i < textList->Count; i++) - { - Console::WriteLine(" [{0}] : {1}", i, textList[i]); - } - Console::WriteLine(); - } - }; -} - -int main() -{ - Samples::SamplesArray::Work(); - -} - -/* -This code produces the following output. - -The string array initially contains the following values: -[0] : The -[1] : quick -[2] : brown -[3] : fox - -The read-only IList contains the following values: -[0] : The -[1] : quick -[2] : brown -[3] : fox - -System.NotSupportedException - Collection is read-only. - -After changing the third element, the string array contains the following values: -[0] : The -[1] : quick -[2] : RED -[3] : fox - -After changing the third element, the read-only IList contains the following values: -[0] : The -[1] : quick -[2] : RED -[3] : fox - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Array.Clone/CPP/arrayclone.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Array.Clone/CPP/arrayclone.cpp deleted file mode 100644 index cbcd2d14244..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Array.Clone/CPP/arrayclone.cpp +++ /dev/null @@ -1,73 +0,0 @@ - -// The following code example clones a CultureInfo array and demonstrates the behavior of a shallow copy. -// -using namespace System; -using namespace System::Globalization; -void PrintIndexAndValues( Array^ myArray ); -int main() -{ - - // Create and initialize a new CultureInfo array. - CultureInfo^ ci0 = gcnew CultureInfo( "ar-SA",false ); - CultureInfo^ ci1 = gcnew CultureInfo( "en-US",false ); - CultureInfo^ ci2 = gcnew CultureInfo( "fr-FR",false ); - CultureInfo^ ci3 = gcnew CultureInfo( "ja-JP",false ); - array^arrCI = {ci0,ci1,ci2,ci3}; - - // Create a clone of the CultureInfo array. - array^arrCIClone = (array^)arrCI->Clone(); - - // Replace an element in the clone array. - CultureInfo^ ci4 = gcnew CultureInfo( "th-TH",false ); - arrCIClone[ 0 ] = ci4; - - // Display the contents of the original array. - Console::WriteLine( "The original array contains the following values:" ); - PrintIndexAndValues( arrCI ); - - // Display the contents of the clone array. - Console::WriteLine( "The clone array contains the following values:" ); - PrintIndexAndValues( arrCIClone ); - - // Display the DateTimeFormatInfo.DateSeparator for the fourth element in both arrays. - Console::WriteLine( "Before changes to the clone:" ); - Console::WriteLine( " Original: The DateTimeFormatInfo->DateSeparator for {0} is {1}.", arrCI[ 3 ]->Name, arrCI[ 3 ]->DateTimeFormat->DateSeparator ); - Console::WriteLine( " Clone: The DateTimeFormatInfo->DateSeparator for {0} is {1}.", arrCIClone[ 3 ]->Name, arrCIClone[ 3 ]->DateTimeFormat->DateSeparator ); - - // Replace the DateTimeFormatInfo.DateSeparator for the fourth element in the clone array. - arrCIClone[ 3 ]->DateTimeFormat->DateSeparator = "-"; - - // Display the DateTimeFormatInfo.DateSeparator for the fourth element in both arrays. - Console::WriteLine( "After changes to the clone:" ); - Console::WriteLine( " Original: The DateTimeFormatInfo->DateSeparator for {0} is {1}.", arrCI[ 3 ]->Name, arrCI[ 3 ]->DateTimeFormat->DateSeparator ); - Console::WriteLine( " Clone: The DateTimeFormatInfo->DateSeparator for {0} is {1}.", arrCIClone[ 3 ]->Name, arrCIClone[ 3 ]->DateTimeFormat->DateSeparator ); -} - -void PrintIndexAndValues( Array^ myArray ) -{ - for ( int i = myArray->GetLowerBound( 0 ); i <= myArray->GetUpperBound( 0 ); i++ ) - Console::WriteLine( "\t[{0}]:\t{1}", i, myArray->GetValue( i ) ); -} - -/* -This code produces the following output. - -The original array contains the following values: - [0]: ar-SA - [1]: en-US - [2]: fr-FR - [3]: ja-JP -The clone array contains the following values: - [0]: th-TH - [1]: en-US - [2]: fr-FR - [3]: ja-JP -Before changes to the clone: - Original: The DateTimeFormatInfo.DateSeparator for ja-JP is /. - Clone: The DateTimeFormatInfo.DateSeparator for ja-JP is /. -After changes to the clone: - Original: The DateTimeFormatInfo.DateSeparator for ja-JP is -. - Clone: The DateTimeFormatInfo.DateSeparator for ja-JP is -. - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Array.Resize/CPP/System.Array.Resize.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Array.Resize/CPP/System.Array.Resize.cpp deleted file mode 100644 index 3bba94a2dc6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Array.Resize/CPP/System.Array.Resize.cpp +++ /dev/null @@ -1,83 +0,0 @@ - -// The following example shows how resizing affects the array. -// -using namespace System; -static void PrintIndexAndValues(array^myArr) -{ - for(int i = 0; i < myArr->Length; i++) - { - Console::WriteLine(L" [{0}] : {1}", i, myArr[i]); - } - Console::WriteLine(); -} - -int main() -{ - - // Create and initialize a new string array. - array^myArr = {L"The", L"quick", L"brown", L"fox", - L"jumps", L"over", L"the", L"lazy", L"dog"}; - - // Display the values of the array. - Console::WriteLine( - L"The string array initially contains the following values:"); - PrintIndexAndValues(myArr); - - // Resize the array to a bigger size (five elements larger). - Array::Resize(myArr, myArr->Length + 5); - - // Display the values of the array. - Console::WriteLine(L"After resizing to a larger size, "); - Console::WriteLine(L"the string array contains the following values:"); - PrintIndexAndValues(myArr); - - // Resize the array to a smaller size (four elements). - Array::Resize(myArr, 4); - - // Display the values of the array. - Console::WriteLine(L"After resizing to a smaller size, "); - Console::WriteLine(L"the string array contains the following values:"); - PrintIndexAndValues(myArr); - return 1; -} - -/* -This code produces the following output. - -The string array initially contains the following values: - [0] : The - [1] : quick - [2] : brown - [3] : fox - [4] : jumps - [5] : over - [6] : the - [7] : lazy - [8] : dog - -After resizing to a larger size, -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 - [9] : - [10] : - [11] : - [12] : - [13] : - -After resizing to a smaller size, -the string array contains the following values: - [0] : The - [1] : quick - [2] : brown - [3] : fox - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Array.Sort/CPP/arraysort.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Array.Sort/CPP/arraysort.cpp deleted file mode 100644 index a3cb3dea791..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Array.Sort/CPP/arraysort.cpp +++ /dev/null @@ -1,119 +0,0 @@ - -// The following example shows how to sort the values in an array using the default comparer -// and a custom comparer that reverses the sort order. - -// -using namespace System; -using namespace System::Collections; - -public ref class ReverseComparer : IComparer -{ -public: - // Call CaseInsensitiveComparer::Compare with the parameters reversed. - virtual int Compare(Object^ x, Object^ y) = IComparer::Compare - { - return ((gcnew CaseInsensitiveComparer)->Compare(y, x)); - } -}; - -void DisplayValues(array^ arr) -{ - for (int i = arr->GetLowerBound(0); i <= arr->GetUpperBound(0); i++) - Console::WriteLine( " [{0}] : {1}", i, arr[ i ] ); - - Console::WriteLine(); -} - -int main() -{ - // Create and initialize a new array. and a new custom comparer. - array^ words = { "The","QUICK","BROWN","FOX","jumps", - "over","the","lazy","dog" }; - // Instantiate the reverse comparer. - IComparer^ revComparer = gcnew ReverseComparer(); - - // Display the values of the Array. - Console::WriteLine( "The original order of elements in the array:" ); - DisplayValues(words); - - // Sort a section of the array using the default comparer. - Array::Sort(words, 1, 3); - Console::WriteLine( "After sorting elements 1-3 by using the default comparer:"); - DisplayValues(words); - - // Sort a section of the array using the reverse case-insensitive comparer. - Array::Sort(words, 1, 3, revComparer); - Console::WriteLine( "After sorting elements 1-3 by using the reverse case-insensitive comparer:"); - DisplayValues(words); - - // Sort the entire array using the default comparer. - Array::Sort(words); - Console::WriteLine( "After sorting the entire array by using the default comparer:"); - DisplayValues(words); - - // Sort the entire array by using the reverse case-insensitive comparer. - Array::Sort(words, revComparer); - Console::WriteLine( "After sorting the entire array using the reverse case-insensitive comparer:"); - DisplayValues(words); -} - -/* -This code produces the following output. - -The Array 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 a section of the Array using the default comparer: - [0] : The - [1] : BROWN - [2] : FOX - [3] : QUICK - [4] : jumps - [5] : over - [6] : the - [7] : lazy - [8] : dog - -After sorting a section of the Array using the reverse case-insensitive comparer: - [0] : The - [1] : QUICK - [2] : FOX - [3] : BROWN - [4] : jumps - [5] : over - [6] : the - [7] : lazy - [8] : dog - -After sorting the entire Array using the default comparer: - [0] : BROWN - [1] : dog - [2] : FOX - [3] : jumps - [4] : lazy - [5] : over - [6] : QUICK - [7] : the - [8] : The - -After sorting the entire Array using 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.Array.Sort2/CPP/arraysort2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Array.Sort2/CPP/arraysort2.cpp deleted file mode 100644 index ef9afc50bc2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Array.Sort2/CPP/arraysort2.cpp +++ /dev/null @@ -1,109 +0,0 @@ -// The following example shows how to sort two associated arrays -// where the first array contains the keys and the second array contains the values. -// Sorts are done using the default comparer and a custom comparer that reverses the sort order. - -// -using namespace System; -using namespace System::Collections; - -public 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 )); - } -}; - -void PrintKeysAndValues( array^myKeys, array^myValues ) -{ - for ( int i = 0; i < myKeys->Length; i++ ) - { - Console::WriteLine( " {0, -10}: {1}", myKeys[ i ], myValues[ i ] ); - } - Console::WriteLine(); -} - -int main() -{ - // Creates and initializes a new Array and a new custom comparer. - array^myKeys = {"red","GREEN","YELLOW","BLUE","purple","black","orange"}; - array^myValues = {"strawberries","PEARS","LIMES","BERRIES","grapes","olives","cantaloupe"}; - IComparer^ myComparer = gcnew myReverserClass; - - // Displays the values of the Array. - Console::WriteLine( "The Array initially contains the following values:" ); - PrintKeysAndValues( myKeys, myValues ); - - // Sorts a section of the Array using the default comparer. - Array::Sort( myKeys, myValues, 1, 3 ); - Console::WriteLine( "After sorting a section of the Array using the default comparer:" ); - - // Sorts a section of the Array using the reverse case-insensitive comparer. - Array::Sort( myKeys, myValues, 1, 3, myComparer ); - Console::WriteLine( "After sorting a section of the Array using the reverse case-insensitive comparer:" ); - PrintKeysAndValues( myKeys, myValues ); - - // Sorts the entire Array using the default comparer. - Array::Sort( myKeys, myValues ); - Console::WriteLine( "After sorting the entire Array using the default comparer:" ); - PrintKeysAndValues( myKeys, myValues ); - - // Sorts the entire Array using the reverse case-insensitive comparer. - Array::Sort( myKeys, myValues, myComparer ); - Console::WriteLine( "After sorting the entire Array using the reverse case-insensitive comparer:" ); - PrintKeysAndValues( myKeys, myValues ); -} - -/* -This code produces the following output. - -The Array initially contains the following values: - red : strawberries - GREEN : PEARS - YELLOW : LIMES - BLUE : BERRIES - purple : grapes - black : olives - orange : cantaloupe - -After sorting a section of the Array using the default comparer: - red : strawberries - BLUE : BERRIES - GREEN : PEARS - YELLOW : LIMES - purple : grapes - black : olives - orange : cantaloupe - -After sorting a section of the Array using the reverse case-insensitive comparer: - red : strawberries - YELLOW : LIMES - GREEN : PEARS - BLUE : BERRIES - purple : grapes - black : olives - orange : cantaloupe - -After sorting the entire Array using the default comparer: - black : olives - BLUE : BERRIES - GREEN : PEARS - orange : cantaloupe - purple : grapes - red : strawberries - YELLOW : LIMES - -After sorting the entire Array using the reverse case-insensitive comparer: - YELLOW : LIMES - red : strawberries - purple : grapes - orange : cantaloupe - GREEN : PEARS - BLUE : BERRIES - black : olives - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Array.SyncRoot/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Array.SyncRoot/cpp/source.cpp deleted file mode 100644 index 8133ae99134..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Array.SyncRoot/cpp/source.cpp +++ /dev/null @@ -1,22 +0,0 @@ -using namespace System; -using namespace System::Threading; - -int main() -{ -// - Array^ myArray = gcnew array { 1, 2, 4 }; - try - { - Monitor::Enter(myArray->SyncRoot); - - for each (Int32 item in myArray) - Console::WriteLine(item); - } - finally - { - Monitor::Exit(myArray->SyncRoot); - } -// - - return 1; -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.ArraySegment/CPP/arraysegment.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.ArraySegment/CPP/arraysegment.cpp deleted file mode 100644 index f8fd837a057..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.ArraySegment/CPP/arraysegment.cpp +++ /dev/null @@ -1,126 +0,0 @@ -// The following code example passes an ArraySegment to a method. - -// -using namespace System; - - -namespace Sample -{ - public ref class SampleArray - { - public: - static void Work() - { - - // Create and initialize a new string array. - array ^ words = {"The", "quick", "brown", - "fox", "jumps", "over", "the", "lazy", "dog"}; - - // Display the initial contents of the array. - Console::WriteLine("The first array segment" - " (with all the array's elements) contains:"); - PrintIndexAndValues(words); - - // Define an array segment that contains the entire array. - ArraySegment segment(words); - - // Display the contents of the ArraySegment. - Console::WriteLine("The first array segment" - " (with all the array's elements) contains:"); - PrintIndexAndValues(segment); - - // Define an array segment that contains the middle five - // values of the array. - ArraySegment middle(words, 2, 5); - - // Display the contents of the ArraySegment. - Console::WriteLine("The second array segment" - " (with the middle five elements) contains:"); - PrintIndexAndValues(middle); - - // Modify the fourth element of the first array - // segment - segment.Array[3] = "LION"; - - // Display the contents of the second array segment - // middle. Note that the value of its second element - // also changed. - Console::WriteLine("After the first array segment" - " is modified,the second array segment" - " now contains:"); - PrintIndexAndValues(middle); - Console::ReadLine(); - } - - static void PrintIndexAndValues(ArraySegment^ segment) - { - for (int i = segment->Offset; - i < (segment->Offset + segment->Count); i++) - { - Console::WriteLine(" [{0}] : {1}", i, - segment->Array[i]); - } - Console::WriteLine(); - } - - static void PrintIndexAndValues(array^ words) - { - for (int i = 0; i < words->Length; i++) - { - Console::WriteLine(" [{0}] : {1}", i, - words[i]); - } - Console::WriteLine(); - } - }; -} - -int main() -{ - Sample::SampleArray::Work(); - return 0; -} - - - /* - This code produces the following output. - - The original array initially contains: - [0] : The - [1] : quick - [2] : brown - [3] : fox - [4] : jumps - [5] : over - [6] : the - [7] : lazy - [8] : dog - - The first array segment (with all the array's elements) contains: - [0] : The - [1] : quick - [2] : brown - [3] : fox - [4] : jumps - [5] : over - [6] : the - [7] : lazy - [8] : dog - - The second array segment (with the middle five elements) contains: - [2] : brown - [3] : fox - [4] : jumps - [5] : over - [6] : the - - After the first array segment is modified, the second array segment now contains: - [2] : brown - [3] : LION - [4] : jumps - [5] : over - [6] : the - - */ - - // diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.ArrayTypeMismatch/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.ArrayTypeMismatch/CPP/class1.cpp deleted file mode 100644 index 2f0f4ea3c86..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.ArrayTypeMismatch/CPP/class1.cpp +++ /dev/null @@ -1,68 +0,0 @@ - -// -using namespace System; -int main() -{ - array^names = { "Dog", "Cat", "Fish"}; - array^objs = dynamic_cast^>(names); - try - { - objs[ 2 ] = (Object^)"Mouse"; - for ( Int32 i = 0; i < objs->Length; i++ ) - { - Console::WriteLine( objs[ i ] ); - - } - } - catch ( System::ArrayTypeMismatchException^ ) - { - - // Not reached, "Mouse" is of the correct type - Console::WriteLine( "Exception Thrown" ); - } - - try - { - Object^ obj = 13; - objs[ 2 ] = obj; - } - catch ( System::ArrayTypeMismatchException^ ) - { - - // Always reached, 13 is not a string. - Console::WriteLine( "New element is not of the correct type" ); - } - - - // Set obj to an array of objects instead of an array of strings - array^objs2 = gcnew array(3); - try - { - objs2[ 0 ] = (Object^)"Turtle"; - objs2[ 1 ] = 12; - objs2[ 2 ] = 2.341; - for ( Int32 i = 0; i < objs->Length; i++ ) - { - Console::WriteLine( objs2[ i ] ); - - } - } - catch ( System::ArrayTypeMismatchException^ ) - { - - // ArrayTypeMismatchException is not thrown this time. - Console::WriteLine( "Exception Thrown" ); - } - -} - -/*expected return values: -Dog -Cat -Mouse -New element is not of the correct type -Turtle -12 -2.341 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Array_GetEnumerator/CPP/array_getenumerator.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Array_GetEnumerator/CPP/array_getenumerator.cpp deleted file mode 100644 index 63f0c9c330c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Array_GetEnumerator/CPP/array_getenumerator.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// The following example shows how to use GetEnumerator to list the elements of an array. -// -using namespace System; - -int main() -{ - // Creates and initializes a new Array. - array^myArr = gcnew array(10); - myArr[ 0 ] = "The"; - myArr[ 1 ] = "quick"; - myArr[ 2 ] = "brown"; - myArr[ 3 ] = "fox"; - myArr[ 4 ] = "jumps"; - myArr[ 5 ] = "over"; - myArr[ 6 ] = "the"; - myArr[ 7 ] = "lazy"; - myArr[ 8 ] = "dog"; - - // Displays the values of the Array. - int i = 0; - System::Collections::IEnumerator^ myEnumerator = myArr->GetEnumerator(); - Console::WriteLine( "The Array contains the following values:" ); - while ( (myEnumerator->MoveNext()) && (myEnumerator->Current != nullptr) ) - Console::WriteLine( "[{0}] {1}", i++, myEnumerator->Current ); -} - -/* -This code produces the following output. - -The 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.Array_GetSetValue/CPP/array_getsetvalue.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Array_GetSetValue/CPP/array_getsetvalue.cpp deleted file mode 100644 index bdfd647373c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Array_GetSetValue/CPP/array_getsetvalue.cpp +++ /dev/null @@ -1,47 +0,0 @@ - -// The following code example demonstrates how to set and get a specific value in a one-dimensional or multidimensional array. -// -using namespace System; -int main() -{ - - // Creates and initializes a one-dimensional array. - array^myArr1 = gcnew array(5); - - // Sets the element at index 3. - myArr1->SetValue( "three", 3 ); - Console::WriteLine( "[3]: {0}", myArr1->GetValue( 3 ) ); - - // Creates and initializes a two-dimensional array. - array^myArr2 = gcnew array(5,5); - - // Sets the element at index 1,3. - myArr2->SetValue( "one-three", 1, 3 ); - Console::WriteLine( "[1,3]: {0}", myArr2->GetValue( 1, 3 ) ); - - // Creates and initializes a three-dimensional array. - array^myArr3 = gcnew array(5,5,5); - - // Sets the element at index 1,2,3. - myArr3->SetValue( "one-two-three", 1, 2, 3 ); - Console::WriteLine( "[1,2,3]: {0}", myArr3->GetValue( 1, 2, 3 ) ); - - // Creates and initializes a seven-dimensional array. - array^myArr7 = gcnew array(5,5,5,5,5,5,5); - - // Sets the element at index 1,2,3,0,1,2,3. - array^myIndices = {1,2,3,0,1,2,3}; - myArr7->SetValue( "one-two-three-zero-one-two-three", myIndices ); - Console::WriteLine( "[1,2,3,0,1,2,3]: {0}", myArr7->GetValue( myIndices ) ); -} - -/* -This code produces the following output. - -[3]: three -[1,3]: one-three -[1,2,3]: one-two-three -[1,2,3,0,1,2,3]: one-two-three-zero-one-two-three - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Attribute.Equals/CPP/equals.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Attribute.Equals/CPP/equals.cpp deleted file mode 100644 index e14da9f2add..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Attribute.Equals/CPP/equals.cpp +++ /dev/null @@ -1,124 +0,0 @@ - -using namespace System; -using namespace System::Reflection; - - // Define a custom parameter attribute that takes a single message argument. - -[AttributeUsage(AttributeTargets::Parameter)] -public ref class ArgumentUsageAttribute: public Attribute -{ - protected: - // usageMsg is storage for the attribute message. - String^ usageMsg; - - public: - // This is the attribute constructor. - ArgumentUsageAttribute( String^ UsageMsg ) - { - this->usageMsg = UsageMsg; - } - - - // Override ToString() to append the message to what the base generates. - virtual String^ ToString() override - { - return String::Concat( Attribute::ToString(), ":", usageMsg ); - } -} ; - - - // Define a custom parameter attribute that generates a GUID for each instance. -[AttributeUsage(AttributeTargets::Parameter)] -public ref class ArgumentIDAttribute : Attribute -{ - protected: - // instanceGUID is storage for the generated GUID. - Guid instanceGUID; - - public: - // This is the attribute constructor, which generates the GUID. - ArgumentIDAttribute() - { - this->instanceGUID = Guid::NewGuid(); - } - - // Override ToString() to append the GUID to what the base generates. - virtual String^ ToString() override - { - return String::Concat( Attribute::ToString(), ".", instanceGUID.ToString() ); - } -}; - -public ref class TestClass -{ - public: - // Assign an ArgumentID attribute to each parameter. - // Assign an ArgumentUsage attribute to each parameter. - void TestMethod( [ArgumentID][ArgumentUsage("Must pass an array here.")]array^strArray, - [ArgumentID][ArgumentUsage("Can pass param list or array here.")]array^strList ){} -}; - -int main() -{ - // Get the class type, and then get the MethodInfo object - // for TestMethod to access its metadata. - Type^ clsType = TestClass::typeid; - MethodInfo^ mInfo = clsType->GetMethod( "TestMethod" ); - - // There will be two elements in pInfoArray, one for each parameter. - array^pInfoArray = mInfo->GetParameters(); - if (pInfoArray != nullptr) - { - // Create an instance of the argument usage attribute on strArray. - ArgumentUsageAttribute^ arrayUsageAttr1 = static_cast(Attribute::GetCustomAttribute( pInfoArray[ 0 ], ArgumentUsageAttribute::typeid )); - - // Create another instance of the argument usage attribute on strArray. - ArgumentUsageAttribute^ arrayUsageAttr2 = static_cast(Attribute::GetCustomAttribute( pInfoArray[ 0 ], ArgumentUsageAttribute::typeid )); - - // Create an instance of the argument usage attribute on strList. - ArgumentUsageAttribute^ listUsageAttr = static_cast(Attribute::GetCustomAttribute( pInfoArray[ 1 ], ArgumentUsageAttribute::typeid )); - - // Create an instance of the argument ID attribute on strArray. - ArgumentIDAttribute^ arrayIDAttr1 = static_cast(Attribute::GetCustomAttribute( pInfoArray[ 0 ], ArgumentIDAttribute::typeid )); - - // Create another instance of the argument ID attribute on strArray. - ArgumentIDAttribute^ arrayIDAttr2 = static_cast(Attribute::GetCustomAttribute( pInfoArray[ 0 ], ArgumentIDAttribute::typeid )); - - // Create an instance of the argument ID attribute on strList. - ArgumentIDAttribute^ listIDAttr = static_cast(Attribute::GetCustomAttribute( pInfoArray[ 1 ], ArgumentIDAttribute::typeid )); - - // Compare various pairs of attributes for equality. - Console::WriteLine( "\nCompare a usage attribute instance to " - "another instance of the same attribute:" ); - Console::WriteLine( " \"{0}\" == \n \"{1}\" ? {2}", arrayUsageAttr1->ToString(), arrayUsageAttr2->ToString(), arrayUsageAttr1->Equals( arrayUsageAttr2 ) ); - Console::WriteLine( "\nCompare a usage attribute to another usage attribute:" ); - Console::WriteLine( " \"{0}\" == \n \"{1}\" ? {2}", arrayUsageAttr1->ToString(), listUsageAttr->ToString(), arrayUsageAttr1->Equals( listUsageAttr ) ); - Console::WriteLine( "\nCompare an ID attribute instance to " - "another instance of the same attribute:" ); - Console::WriteLine( " \"{0}\" == \n \"{1}\" ? {2}", arrayIDAttr1->ToString(), arrayIDAttr2->ToString(), arrayIDAttr1->Equals( arrayIDAttr2 ) ); - Console::WriteLine( "\nCompare an ID attribute to another ID attribute:" ); - Console::WriteLine( " \"{0}\" == \n \"{1}\" ? {2}", arrayIDAttr1->ToString(), listIDAttr->ToString(), arrayIDAttr1->Equals( listIDAttr ) ); - } - else - { - Console::WriteLine( "The parameters information could not be retrieved for method {0}.", mInfo->Name ); - } -} -/* -The example displays an output similar to the following: - Compare a usage attribute instance to another instance of the same attribute: - "ArgumentUsageAttribute:Must pass an array here." == - "ArgumentUsageAttribute:Must pass an array here." ? True - - Compare a usage attribute to another usage attribute: - "ArgumentUsageAttribute:Must pass an array here." == - "ArgumentUsageAttribute:Can pass param list or array here." ? False - - Compare an ID attribute instance to another instance of the same attribute: - "ArgumentIDAttribute.22d1a176-4aca-427b-8230-0c1563e13187" == - "ArgumentIDAttribute.7fa94bba-c290-48e1-a0de-e22f6c1e64f1" ? False - - Compare an ID attribute to another ID attribute: - "ArgumentIDAttribute.22d1a176-4aca-427b-8230-0c1563e13187" == - "ArgumentIDAttribute.b9eea70d-9c0f-459e-a984-19c46b6c8789" ? False -*/ diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/CPP/getcustattrparam.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/CPP/getcustattrparam.cpp deleted file mode 100644 index b5764d952ba..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/CPP/getcustattrparam.cpp +++ /dev/null @@ -1,130 +0,0 @@ - -// -// Example for the Attribute::GetCustomAttribute( ParameterInfo*, Type* ) -// method. -using namespace System; -using namespace System::Collections; -using namespace System::Reflection; - -namespace NDP_UE_CPP -{ - - // - // Define a custom parameter attribute that takes a single message argument. - - [AttributeUsage(AttributeTargets::Parameter)] - public ref class ArgumentUsageAttribute: public Attribute - { - protected: - - // usageMsg is storage for the attribute message. - String^ usageMsg; - - public: - - // This is the attribute constructor. - ArgumentUsageAttribute( String^ UsageMsg ) - { - this->usageMsg = UsageMsg; - } - - - property String^ Message - { - // This is the Message property for the attribute. - String^ get() - { - return usageMsg; - } - - void set( String^ value ) - { - this->usageMsg = value; - } - } - }; - // - - public ref class BaseClass - { - public: - - // Assign an ArgumentUsage attribute to the strArray parameter. - // Assign a ParamArray attribute to strList. - virtual void TestMethod( [ArgumentUsage("Must pass an array here.")]array^strArray, - ...array^strList ){} - }; - - public ref class DerivedClass: public BaseClass - { - public: - - // Assign an ArgumentUsage attributes to the strList parameter. - virtual void TestMethod( array^strArray, [ArgumentUsage( - "Can pass a parameter list or array here.")]array^strList ) override {} - }; -} - -int main() -{ - Console::WriteLine( "This example of Attribute::GetCustomAttribute( Param" - "eterInfo*, Type* )\ngenerates the following output." ); - - // Get the class type, and then get the MethodInfo object - // for TestMethod to access its metadata. - Type^ clsType = NDP_UE_CPP::DerivedClass::typeid; - MethodInfo^ mInfo = clsType->GetMethod( "TestMethod" ); - - // Iterate through the ParameterInfo array for the method parameters. - array^pInfoArray = mInfo->GetParameters(); - if ( pInfoArray != nullptr ) - { - // This implements foreach( ParameterInfo* paramInfo in pInfoArray ). - IEnumerator^ myEnum = pInfoArray->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - ParameterInfo^ paramInfo = safe_cast(myEnum->Current); - - // See if the ParamArray attribute is defined. - bool isDef = Attribute::IsDefined( paramInfo, ParamArrayAttribute::typeid ); - if ( isDef ) - Console::WriteLine( "\nThe ParamArray attribute is defined for \n" - "parameter {0} of method {1}.", paramInfo->Name, mInfo->Name ); - - // See if ParamUsageAttribute is defined. - // If so, display a message. - NDP_UE_CPP::ArgumentUsageAttribute^ usageAttr = static_cast(Attribute::GetCustomAttribute( paramInfo, NDP_UE_CPP::ArgumentUsageAttribute::typeid )); - if ( usageAttr != nullptr ) - { - Console::WriteLine( "\nThe ArgumentUsage attribute is defined for \n" - "parameter {0} of method {1}.", paramInfo->Name, mInfo->Name ); - Console::WriteLine( "\n The usage " - "message for {0} is:\n \"{1}\".", paramInfo->Name, usageAttr->Message ); - } - } - } - else - Console::WriteLine( "The parameters information could " - "not be retrieved for method {0}.", mInfo->Name ); -} - -/* -This example of Attribute::GetCustomAttribute( ParameterInfo*, Type* ) -generates the following output. - -The ArgumentUsage attribute is defined for -parameter strArray of method TestMethod. - - The usage message for strArray is: - "Must pass an array here.". - -The ParamArray attribute is defined for -parameter strList of method TestMethod. - -The ArgumentUsage attribute is defined for -parameter strList of method TestMethod. - - The usage message for strList is: - "Can pass a parameter list or array here.". -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/CPP/getcustattrprminh.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/CPP/getcustattrprminh.cpp deleted file mode 100644 index 8197cb5c956..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/CPP/getcustattrprminh.cpp +++ /dev/null @@ -1,152 +0,0 @@ - -// -// Example for the Attribute::GetCustomAttribute( ParameterInfo*, Type*, bool ) -// method. -using namespace System; -using namespace System::Collections; -using namespace System::Reflection; - -namespace NDP_UE_CPP -{ - // Define a custom parameter attribute that takes a single message argument. - - [AttributeUsage(AttributeTargets::Parameter)] - public ref class ArgumentUsageAttribute: public Attribute - { - protected: - - // usageMsg is storage for the attribute message. - String^ usageMsg; - - public: - - // This is the attribute constructor. - ArgumentUsageAttribute( String^ UsageMsg ) - { - this->usageMsg = UsageMsg; - } - - property String^ Message - { - // This is the Message property for the attribute. - String^ get() - { - return usageMsg; - } - - void set( String^ value ) - { - this->usageMsg = value; - } - } - }; - - public ref class BaseClass - { - public: - - // Assign an ArgumentUsage attribute to the strArray parameter. - // Assign a ParamArray attribute to strList. - virtual void TestMethod( [ArgumentUsage("Must pass an array here.")]array^strArray, - ...array^strList ){} - }; - - public ref class DerivedClass: public BaseClass - { - public: - - // Assign an ArgumentUsage attributes to the strList parameter. - virtual void TestMethod( array^strArray, [ArgumentUsage( - "Can pass a parameter list or array here.")]array^strList ) override {} - - }; - - void DisplayParameterAttributes( MethodInfo^ mInfo, array^pInfoArray, bool includeInherited ) - { - Console::WriteLine( "\nParameter attribute information for method \"{0}" - "\"\nincludes inheritance from base class: {1}.", mInfo->Name, includeInherited ? (String^)"Yes" : "No" ); - - // This implements foreach( ParameterInfo* paramInfo in pInfoArray ). - IEnumerator^ myEnum = pInfoArray->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - ParameterInfo^ paramInfo = safe_cast(myEnum->Current); - - // See if the ParamArray attribute is defined. - bool isDef = Attribute::IsDefined( paramInfo, ParamArrayAttribute::typeid ); - if ( isDef ) - Console::WriteLine( "\n The ParamArray attribute is defined " - "for \n parameter {0} of method {1}.", paramInfo->Name, mInfo->Name ); - - // See if ParamUsageAttribute is defined. - // If so, display a message. - ArgumentUsageAttribute^ usageAttr = static_cast(Attribute::GetCustomAttribute( paramInfo, ArgumentUsageAttribute::typeid, includeInherited )); - if ( usageAttr != nullptr ) - { - Console::WriteLine( "\n The ArgumentUsage attribute is defined " - "for \n parameter {0} of method {1}.", paramInfo->Name, mInfo->Name ); - Console::WriteLine( "\n The usage " - "message for {0} is:\n \"{1}\".", paramInfo->Name, usageAttr->Message ); - } - } - } - -} - -int main() -{ - Console::WriteLine( "This example of Attribute::GetCustomAttribute( ParameterInfo*, " - "Type*, bool )\ngenerates the following output." ); - - // Get the class type, and then get the MethodInfo object - // for TestMethod to access its metadata. - Type^ clsType = NDP_UE_CPP::DerivedClass::typeid; - MethodInfo^ mInfo = clsType->GetMethod( "TestMethod" ); - - // Iterate through the ParameterInfo array for the method parameters. - array^pInfoArray = mInfo->GetParameters(); - if ( pInfoArray != nullptr ) - { - NDP_UE_CPP::DisplayParameterAttributes( mInfo, pInfoArray, false ); - NDP_UE_CPP::DisplayParameterAttributes( mInfo, pInfoArray, true ); - } - else - Console::WriteLine( "The parameters information could " - "not be retrieved for method {0}.", mInfo->Name ); -} - -/* -This example of Attribute::GetCustomAttribute( ParameterInfo*, Type*, bool ) -generates the following output. - -Parameter attribute information for method "TestMethod" -includes inheritance from base class: No. - - The ParamArray attribute is defined for - parameter strList of method TestMethod. - - The ArgumentUsage attribute is defined for - parameter strList of method TestMethod. - - The usage message for strList is: - "Can pass a parameter list or array here.". - -Parameter attribute information for method "TestMethod" -includes inheritance from base class: Yes. - - The ArgumentUsage attribute is defined for - parameter strArray of method TestMethod. - - The usage message for strArray is: - "Must pass an array here.". - - The ParamArray attribute is defined for - parameter strList of method TestMethod. - - The ArgumentUsage attribute is defined for - parameter strList of method TestMethod. - - The usage message for strList is: - "Can pass a parameter list or array here.". -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Attribute.TypeId/CPP/typeid.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Attribute.TypeId/CPP/typeid.cpp deleted file mode 100644 index 9cfaa32643e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Attribute.TypeId/CPP/typeid.cpp +++ /dev/null @@ -1,136 +0,0 @@ - -// -// Example for the Attribute::TypeId property. -using namespace System; -using namespace System::Reflection; - -namespace NDP_UE_CPP -{ - - // Define a custom parameter attribute that takes a single message argument. - - [AttributeUsage(AttributeTargets::Parameter)] - public ref class ArgumentUsageAttribute: public Attribute - { - protected: - - // This is storage for the attribute message and unique ID. - String^ usageMsg; - Guid instanceGUID; - - public: - - // The constructor saves the message and creates a unique identifier. - ArgumentUsageAttribute( String^ UsageMsg ) - { - this->usageMsg = UsageMsg; - this->instanceGUID = Guid::NewGuid(); - } - - property String^ Message - { - // This is the Message property for the attribute. - String^ get() - { - return usageMsg; - } - - void set( String^ value ) - { - this->usageMsg = value; - } - } - - property Object^ TypeId - { - // Override TypeId to provide a unique identifier for the instance. - virtual Object^ get() override - { - return instanceGUID; - } - } - - // Override ToString() to append the message to - // what the base generates. - virtual String^ ToString() override - { - return String::Concat( Attribute::ToString(), ":", usageMsg ); - } - }; - - public ref class TestClass - { - public: - - // Assign an ArgumentUsage attribute to each parameter. - // Assign a ParamArray attribute to strList. - void TestMethod( [ArgumentUsage("Must pass an array here.")]array^strArray, - [ArgumentUsage("Can pass a param list or array here.")]array^strList ){} - }; - - static void ShowAttributeTypeIds() - { - // Get the class type, and then get the MethodInfo object - // for TestMethod to access its metadata. - Type^ clsType = TestClass::typeid; - MethodInfo^ mInfo = clsType->GetMethod( "TestMethod" ); - - // There will be two elements in pInfoArray, one for each parameter. - array^pInfoArray = mInfo->GetParameters(); - if ( pInfoArray != nullptr ) - { - // Create an instance of the param array attribute on strList. - ParamArrayAttribute^ listArrayAttr = static_cast(Attribute::GetCustomAttribute( pInfoArray[ 1 ], ParamArrayAttribute::typeid )); - - // Create an instance of the argument usage attribute on strArray. - ArgumentUsageAttribute^ arrayUsageAttr1 = static_cast(Attribute::GetCustomAttribute( pInfoArray[ 0 ], ArgumentUsageAttribute::typeid )); - - // Create another instance of the argument usage attribute - // on strArray. - ArgumentUsageAttribute^ arrayUsageAttr2 = static_cast(Attribute::GetCustomAttribute( pInfoArray[ 0 ], ArgumentUsageAttribute::typeid )); - - // Create an instance of the argument usage attribute on strList. - ArgumentUsageAttribute^ listUsageAttr = static_cast(Attribute::GetCustomAttribute( pInfoArray[ 1 ], ArgumentUsageAttribute::typeid )); - - // Display the attributes and corresponding TypeId values. - Console::WriteLine( "\n\"{0}\" \nTypeId: {1}", listArrayAttr->ToString(), listArrayAttr->TypeId ); - Console::WriteLine( "\n\"{0}\" \nTypeId: {1}", arrayUsageAttr1->ToString(), arrayUsageAttr1->TypeId ); - Console::WriteLine( "\n\"{0}\" \nTypeId: {1}", arrayUsageAttr2->ToString(), arrayUsageAttr2->TypeId ); - Console::WriteLine( "\n\"{0}\" \nTypeId: {1}", listUsageAttr->ToString(), listUsageAttr->TypeId ); - } - else - Console::WriteLine( "The parameters information could " - "not be retrieved for method {0}.", mInfo->Name ); - } -} - -int main() -{ - Console::WriteLine( "This example of the Attribute::TypeId property\n" - "generates the following output." ); - Console::WriteLine( "\nCreate instances from a derived Attribute " - "class that implements TypeId, \nand then " - "display the attributes and corresponding TypeId values:" ); - NDP_UE_CPP::ShowAttributeTypeIds(); -} - -/* -This example of the Attribute::TypeId property -generates output similar to the following: - -Create instances from a derived Attribute class that implements TypeId, -and then display the attributes and corresponding TypeId values: - -"System.ParamArrayAttribute" -TypeId: System.ParamArrayAttribute - -"NDP_UE_CPP.ArgumentUsageAttribute:Must pass an array here." -TypeId: 9316015d-1219-4ce1-b317-e71efb23d42e - -"NDP_UE_CPP.ArgumentUsageAttribute:Must pass an array here." -TypeId: ebc1ba23-2573-4c1f-aea6-90515e733796 - -"NDP_UE_CPP.ArgumentUsageAttribute:Can pass a param list or array here." -TypeId: 624af10b-9bba-4403-a97e-46927e7385fb -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.Class/CPP/bitconv.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.Class/CPP/bitconv.cpp deleted file mode 100644 index b6498b4a22a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.Class/CPP/bitconv.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// -// Example of BitConverter class methods. -using namespace System; -int main() -{ - String^ formatter = "{0,25}{1,30}"; - double aDoubl = 0.1111111111111111111; - float aSingl = 0.1111111111111111111F; - __int64 aLong = 1111111111111111111; - int anInt = 1111111111; - short aShort = 11111; - __wchar_t aChar = L'*'; - bool aBool = true; - Console::WriteLine( "This example of methods of the BitConverter class" - "\ngenerates the following output.\n" ); - Console::WriteLine( formatter, "argument", "byte array" ); - Console::WriteLine( formatter, "--------", "----------" ); - - // Convert values to Byte arrays and display them. - Console::WriteLine( formatter, aDoubl, BitConverter::ToString( BitConverter::GetBytes( aDoubl ) ) ); - Console::WriteLine( formatter, aSingl, BitConverter::ToString( BitConverter::GetBytes( aSingl ) ) ); - Console::WriteLine( formatter, aLong, BitConverter::ToString( BitConverter::GetBytes( aLong ) ) ); - Console::WriteLine( formatter, anInt, BitConverter::ToString( BitConverter::GetBytes( anInt ) ) ); - Console::WriteLine( formatter, aShort, BitConverter::ToString( BitConverter::GetBytes( aShort ) ) ); - Console::WriteLine( formatter, aChar, BitConverter::ToString( BitConverter::GetBytes( aChar ) ) ); - Console::WriteLine( formatter, aBool, BitConverter::ToString( BitConverter::GetBytes( aBool ) ) ); -} - -/* -This example of methods of the BitConverter class -generates the following output. - - argument byte array - -------- ---------- - 0.111111111111111 1C-C7-71-1C-C7-71-BC-3F - 0.1111111 39-8E-E3-3D - 1111111111111111111 C7-71-C4-2B-AB-75-6B-0F - 1111111111 C7-35-3A-42 - 11111 67-2B - * 2A-00 - True 01 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.Class/CPP/littleend.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.Class/CPP/littleend.cpp deleted file mode 100644 index 57627564464..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.Class/CPP/littleend.cpp +++ /dev/null @@ -1,19 +0,0 @@ - -// -// Example of the BitConverter::IsLittleEndian field. -using namespace System; -int main() -{ - Console::WriteLine( "This example of the BitConverter::IsLittleEndian field " - "generates \nthe following output when run on " - "x86-class computers.\n" ); - Console::WriteLine( "IsLittleEndian: {0}", BitConverter::IsLittleEndian ); -} - -/* -This example of the BitConverter::IsLittleEndian field generates -the following output when run on x86-class computers. - -IsLittleEndian: True -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.DoubleInt64/CPP/bitstodbl.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.DoubleInt64/CPP/bitstodbl.cpp deleted file mode 100644 index 011dda5201d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.DoubleInt64/CPP/bitstodbl.cpp +++ /dev/null @@ -1,67 +0,0 @@ - -// -// Example of the BitConverter::Int64BitsToDouble method. -using namespace System; - -// Reinterpret the __int64 argument as a double. -void LongBitsToDouble( __int64 argument ) -{ - double doubleValue; - doubleValue = BitConverter::Int64BitsToDouble( argument ); - - // Display the argument in hexadecimal. - Console::WriteLine( "{0,20}{1,27:E16}", String::Format( "0x{0:X16}", argument ), doubleValue ); -} - -int main() -{ - Console::WriteLine( "This example of the BitConverter::Int64BitsToDouble( " - "__int64 ) \nmethod generates the following output.\n" ); - Console::WriteLine( "{0,20}{1,27:E16}", "__int64 argument", "double value" ); - Console::WriteLine( "{0,20}{1,27:E16}", "----------------", "------------" ); - - // Convert __int64 values and display the results. - LongBitsToDouble( 0 ); - LongBitsToDouble( 0x3FF0000000000000 ); - LongBitsToDouble( 0x402E000000000000 ); - LongBitsToDouble( 0x406FE00000000000 ); - LongBitsToDouble( 0x41EFFFFFFFE00000 ); - LongBitsToDouble( 0x3F70000000000000 ); - LongBitsToDouble( 0x3DF0000000000000 ); - LongBitsToDouble( 0x0000000000000001 ); - LongBitsToDouble( 0x000000000000FFFF ); - LongBitsToDouble( 0x0000FFFFFFFFFFFF ); - LongBitsToDouble( 0xFFFFFFFFFFFFFFFF ); - LongBitsToDouble( 0xFFF0000000000000 ); - LongBitsToDouble( 0x7FF0000000000000 ); - LongBitsToDouble( 0xFFEFFFFFFFFFFFFF ); - LongBitsToDouble( 0x7FEFFFFFFFFFFFFF ); - LongBitsToDouble( Int64::MinValue ); - LongBitsToDouble( Int64::MaxValue ); -} - -/* -This example of the BitConverter::Int64BitsToDouble( __int64 ) -method generates the following output. - - __int64 argument double value - ---------------- ------------ - 0x0000000000000000 0.0000000000000000E+000 - 0x3FF0000000000000 1.0000000000000000E+000 - 0x402E000000000000 1.5000000000000000E+001 - 0x406FE00000000000 2.5500000000000000E+002 - 0x41EFFFFFFFE00000 4.2949672950000000E+009 - 0x3F70000000000000 3.9062500000000000E-003 - 0x3DF0000000000000 2.3283064365386963E-010 - 0x0000000000000001 4.9406564584124654E-324 - 0x000000000000FFFF 3.2378592100206092E-319 - 0x0000FFFFFFFFFFFF 1.3906711615669959E-309 - 0xFFFFFFFFFFFFFFFF NaN - 0xFFF0000000000000 -Infinity - 0x7FF0000000000000 Infinity - 0xFFEFFFFFFFFFFFFF -1.7976931348623157E+308 - 0x7FEFFFFFFFFFFFFF 1.7976931348623157E+308 - 0x8000000000000000 0.0000000000000000E+000 - 0x7FFFFFFFFFFFFFFF NaN -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.DoubleInt64/CPP/dbltobits.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.DoubleInt64/CPP/dbltobits.cpp deleted file mode 100644 index 347acebc505..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.DoubleInt64/CPP/dbltobits.cpp +++ /dev/null @@ -1,71 +0,0 @@ - -// -// Example of the BitConverter::DoubleToInt64Bits method. -using namespace System; - -// Reinterpret the double argument as an __int64. -void DoubleToLongBits( double argument ) -{ - __int64 longValue; - longValue = BitConverter::DoubleToInt64Bits( argument ); - - // Display the resulting __int64 in hexadecimal. - Console::WriteLine( "{0,25:E16}{1,23:X16}", argument, longValue ); -} - -int main() -{ - Console::WriteLine( "This example of the BitConverter::DoubleToInt64Bits( " - "double ) \nmethod generates the following output.\n" ); - Console::WriteLine( "{0,25:E16}{1,23:X16}", "double argument", "hexadecimal value" ); - Console::WriteLine( "{0,25:E16}{1,23:X16}", "---------------", "-----------------" ); - - // Convert double values and display the results. - DoubleToLongBits( 1.0 ); - DoubleToLongBits( 15.0 ); - DoubleToLongBits( 255.0 ); - DoubleToLongBits( 4294967295.0 ); - DoubleToLongBits( 0.00390625 ); - DoubleToLongBits( 0.00000000023283064365386962890625 ); - DoubleToLongBits( 1.234567890123E-300 ); - DoubleToLongBits( 1.23456789012345E-150 ); - DoubleToLongBits( 1.2345678901234565 ); - DoubleToLongBits( 1.2345678901234567 ); - DoubleToLongBits( 1.2345678901234569 ); - DoubleToLongBits( 1.23456789012345678E+150 ); - DoubleToLongBits( 1.234567890123456789E+300 ); - DoubleToLongBits( Double::MinValue ); - DoubleToLongBits( Double::MaxValue ); - DoubleToLongBits( Double::Epsilon ); - DoubleToLongBits( Double::NaN ); - DoubleToLongBits( Double::NegativeInfinity ); - DoubleToLongBits( Double::PositiveInfinity ); -} - -/* -This example of the BitConverter::DoubleToInt64Bits( double ) -method generates the following output. - - double argument hexadecimal value - --------------- ----------------- - 1.0000000000000000E+000 3FF0000000000000 - 1.5000000000000000E+001 402E000000000000 - 2.5500000000000000E+002 406FE00000000000 - 4.2949672950000000E+009 41EFFFFFFFE00000 - 3.9062500000000000E-003 3F70000000000000 - 2.3283064365386963E-010 3DF0000000000000 - 1.2345678901230000E-300 01AA74FE1C1E7E45 - 1.2345678901234500E-150 20D02A36586DB4BB - 1.2345678901234565E+000 3FF3C0CA428C59FA - 1.2345678901234567E+000 3FF3C0CA428C59FB - 1.2345678901234569E+000 3FF3C0CA428C59FC - 1.2345678901234569E+150 5F182344CD3CDF9F - 1.2345678901234569E+300 7E3D7EE8BCBBD352 - -1.7976931348623157E+308 FFEFFFFFFFFFFFFF - 1.7976931348623157E+308 7FEFFFFFFFFFFFFF - 4.9406564584124654E-324 0000000000000001 - NaN FFF8000000000000 - -Infinity FFF0000000000000 - Infinity 7FF0000000000000 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.Others/CPP/bytesbool.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.Others/CPP/bytesbool.cpp deleted file mode 100644 index d6d4ad9fb47..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.Others/CPP/bytesbool.cpp +++ /dev/null @@ -1,23 +0,0 @@ - -// -using namespace System; - -int main() -{ - // Define Boolean true and false values. - array^ values = { true, false }; - - // Display the value and its corresponding byte array. - Console::WriteLine("{0,10}{1,16}\n", "Boolean", "Bytes"); - for each (Byte value in values) { - array^ bytes = BitConverter::GetBytes(value); - Console::WriteLine("{0,10}{1,16}", value, - BitConverter::ToString(bytes)); - } -} -// This example displays the following output: -// Boolean Bytes -// -// True 01 -// False 00 -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.Others/CPP/byteschar.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.Others/CPP/byteschar.cpp deleted file mode 100644 index 47d776fe8a2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.Others/CPP/byteschar.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -// -// Example of the BitConverter::GetBytes( __wchar_t ) method. -using namespace System; - -// Convert a __wchar_t argument to a byte array and display it. -void GetBytesChar( __wchar_t argument ) -{ - array^byteArray = BitConverter::GetBytes( argument ); - Console::WriteLine( "{0,10}{1,16}", argument, BitConverter::ToString( byteArray ) ); -} - -int main() -{ - Console::WriteLine( "This example of the BitConverter::GetBytes( __wchar_t ) " - "\nmethod generates the following output.\n" ); - Console::WriteLine( "{0,10}{1,16}", "__wchar_t", "byte array" ); - Console::WriteLine( "{0,10}{1,16}", "---------", "----------" ); - - // Convert __wchar_t values and display the results. - GetBytesChar( L'\0' ); - GetBytesChar( L' ' ); - GetBytesChar( L'*' ); - GetBytesChar( L'3' ); - GetBytesChar( L'A' ); - GetBytesChar( L'[' ); - GetBytesChar( L'a' ); - GetBytesChar( L'{' ); -} - -/* -This example of the BitConverter::GetBytes( __wchar_t ) -method generates the following output. - - __wchar_t byte array - --------- ---------- - 00-00 - 20-00 - * 2A-00 - 3 33-00 - A 41-00 - [ 5B-00 - a 61-00 - { 7B-00 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.Others/CPP/bytesdouble.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.Others/CPP/bytesdouble.cpp deleted file mode 100644 index 000a26b3a68..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.Others/CPP/bytesdouble.cpp +++ /dev/null @@ -1,64 +0,0 @@ - -// -// Example of the BitConverter::GetBytes( double ) method. -using namespace System; - -// Convert a double argument to a byte array and display it. -void GetBytesDouble( double argument ) -{ - array^byteArray = BitConverter::GetBytes( argument ); - Console::WriteLine( "{0,25:E16}{1,30}", argument, BitConverter::ToString( byteArray ) ); -} - -int main() -{ - Console::WriteLine( "This example of the BitConverter::GetBytes( double ) " - "\nmethod generates the following output.\n" ); - Console::WriteLine( "{0,25:E16}{1,30}", "double", "byte array" ); - Console::WriteLine( "{0,25:E16}{1,30}", "------", "----------" ); - - // Convert double values and display the results. - GetBytesDouble( 0.0 ); - GetBytesDouble( 1.0 ); - GetBytesDouble( 255.0 ); - GetBytesDouble( 4294967295.0 ); - GetBytesDouble( 0.00390625 ); - GetBytesDouble( 0.00000000023283064365386962890625 ); - GetBytesDouble( 1.23456789012345E-300 ); - GetBytesDouble( 1.2345678901234565 ); - GetBytesDouble( 1.2345678901234567 ); - GetBytesDouble( 1.2345678901234569 ); - GetBytesDouble( 1.23456789012345678E+300 ); - GetBytesDouble( Double::MinValue ); - GetBytesDouble( Double::MaxValue ); - GetBytesDouble( Double::Epsilon ); - GetBytesDouble( Double::NaN ); - GetBytesDouble( Double::NegativeInfinity ); - GetBytesDouble( Double::PositiveInfinity ); -} - -/* -This example of the BitConverter::GetBytes( double ) -method generates the following output. - - double byte array - ------ ---------- - 0.0000000000000000E+000 00-00-00-00-00-00-00-00 - 1.0000000000000000E+000 00-00-00-00-00-00-F0-3F - 2.5500000000000000E+002 00-00-00-00-00-E0-6F-40 - 4.2949672950000000E+009 00-00-E0-FF-FF-FF-EF-41 - 3.9062500000000000E-003 00-00-00-00-00-00-70-3F - 2.3283064365386963E-010 00-00-00-00-00-00-F0-3D - 1.2345678901234500E-300 DF-88-1E-1C-FE-74-AA-01 - 1.2345678901234565E+000 FA-59-8C-42-CA-C0-F3-3F - 1.2345678901234567E+000 FB-59-8C-42-CA-C0-F3-3F - 1.2345678901234569E+000 FC-59-8C-42-CA-C0-F3-3F - 1.2345678901234569E+300 52-D3-BB-BC-E8-7E-3D-7E - -1.7976931348623157E+308 FF-FF-FF-FF-FF-FF-EF-FF - 1.7976931348623157E+308 FF-FF-FF-FF-FF-FF-EF-7F - 4.9406564584124654E-324 01-00-00-00-00-00-00-00 - NaN 00-00-00-00-00-00-F8-FF - -Infinity 00-00-00-00-00-00-F0-FF - Infinity 00-00-00-00-00-00-F0-7F -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.Others/CPP/bytessingle.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.Others/CPP/bytessingle.cpp deleted file mode 100644 index c9dbcc43471..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.Others/CPP/bytessingle.cpp +++ /dev/null @@ -1,64 +0,0 @@ - -// -// Example of the BitConverter::GetBytes( float ) method. -using namespace System; - -// Convert a float argument to a byte array and display it. -void GetBytesSingle( float argument ) -{ - array^byteArray = BitConverter::GetBytes( argument ); - Console::WriteLine( "{0,16:E7}{1,20}", argument, BitConverter::ToString( byteArray ) ); -} - -int main() -{ - Console::WriteLine( "This example of the BitConverter::GetBytes( float ) " - "\nmethod generates the following output.\n" ); - Console::WriteLine( "{0,16:E7}{1,20}", "float", "byte array" ); - Console::WriteLine( "{0,16:E7}{1,20}", "-----", "----------" ); - - // Convert float values and display the results. - GetBytesSingle( 0.0F ); - GetBytesSingle( 1.0F ); - GetBytesSingle( 15.0F ); - GetBytesSingle( 65535.0F ); - GetBytesSingle( 0.00390625F ); - GetBytesSingle( 0.00000000023283064365386962890625F ); - GetBytesSingle( 1.2345E-35F ); - GetBytesSingle( 1.2345671F ); - GetBytesSingle( 1.2345673F ); - GetBytesSingle( 1.2345677F ); - GetBytesSingle( 1.23456789E+35F ); - GetBytesSingle( Single::MinValue ); - GetBytesSingle( Single::MaxValue ); - GetBytesSingle( Single::Epsilon ); - GetBytesSingle( Single::NaN ); - GetBytesSingle( Single::NegativeInfinity ); - GetBytesSingle( Single::PositiveInfinity ); -} - -/* -This example of the BitConverter::GetBytes( float ) -method generates the following output. - - float byte array - ----- ---------- - 0.0000000E+000 00-00-00-00 - 1.0000000E+000 00-00-80-3F - 1.5000000E+001 00-00-70-41 - 6.5535000E+004 00-FF-7F-47 - 3.9062500E-003 00-00-80-3B - 2.3283064E-010 00-00-80-2F - 1.2345000E-035 49-46-83-05 - 1.2345671E+000 4B-06-9E-3F - 1.2345673E+000 4D-06-9E-3F - 1.2345676E+000 50-06-9E-3F - 1.2345679E+035 1E-37-BE-79 - -3.4028235E+038 FF-FF-7F-FF - 3.4028235E+038 FF-FF-7F-7F - 1.4012985E-045 01-00-00-00 - NaN 00-00-C0-FF - -Infinity 00-00-80-FF - Infinity 00-00-80-7F -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.SInts/CPP/bytesint16.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.SInts/CPP/bytesint16.cpp deleted file mode 100644 index 85dfd8f960e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.SInts/CPP/bytesint16.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -using namespace System; - -void main() -{ - // Define an array of integers. - array^ values = { 0, 15, -15, 10000, -10000, - Int16::MinValue, Int16::MaxValue}; - - // Convert each integer to a byte array. - Console::WriteLine("{0,16}{1,10}{2,17}", "Integer", - "Endian", "Byte Array"); - Console::WriteLine("{0,16}{1,10}{2,17}", "---", "------", - "----------"); - for each (int value in values) { - array^ byteArray = BitConverter::GetBytes(value); - Console::WriteLine("{0,16}{1,10}{2,17}", value, - BitConverter::IsLittleEndian ? "Little" : " Big", - BitConverter::ToString(byteArray)); - } -} -// This example displays output like the following: -// Integer Endian Byte Array -// --- ------ ---------- -// 0 Little 00-00 -// 15 Little 0F-00 -// -15 Little F1-FF -// 10000 Little 10-27 -// -10000 Little F0-D8 -// -32768 Little 00-80 -// 32767 Little FF-7F -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.SInts/CPP/bytesint32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.SInts/CPP/bytesint32.cpp deleted file mode 100644 index f1a781ff180..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.SInts/CPP/bytesint32.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// -using namespace System; - -void main() -{ - // Define an array of integers. - array^ values = { 0, 15, -15, 0x100000, -0x100000, 1000000000, - -1000000000, Int32::MinValue, Int32::MaxValue }; - - // Convert each integer to a byte array. - Console::WriteLine("{0,16}{1,10}{2,17}", "Integer", - "Endian", "Byte Array"); - Console::WriteLine("{0,16}{1,10}{2,17}", "---", "------", - "----------" ); - for each (int value in values) { - array^ byteArray = BitConverter::GetBytes(value); - Console::WriteLine("{0,16}{1,10}{2,17}", value, - BitConverter::IsLittleEndian ? "Little" : " Big", - BitConverter::ToString(byteArray)); - } -} -// This example displays output like the following: -// Integer Endian Byte Array -// --- ------ ---------- -// 0 Little 00-00-00-00 -// 15 Little 0F-00-00-00 -// -15 Little F1-FF-FF-FF -// 1048576 Little 00-00-10-00 -// -1048576 Little 00-00-F0-FF -// 1000000000 Little 00-CA-9A-3B -// -1000000000 Little 00-36-65-C4 -// -2147483648 Little 00-00-00-80 -// 2147483647 Little FF-FF-FF-7F -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.SInts/CPP/bytesint64.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.SInts/CPP/bytesint64.cpp deleted file mode 100644 index dace2c6c7a2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.SInts/CPP/bytesint64.cpp +++ /dev/null @@ -1,42 +0,0 @@ - -// -using namespace System; - -void main() -{ - // Define an array of Int64 values. - array^ values = { 0, 0xFFFFFF, -0xFFFFFF, 1000000000, -1000000000, - 0x100000000, -0x100000000, 0xAAAAAAAAAAAA, - -0xAAAAAAAAAAAA, 1000000000000000000, - -1000000000000000000, Int64::MinValue, - Int64::MaxValue}; - - Console::WriteLine( "{0,22}{1,10}{2,30}", "Int64", "Endian", "Byte Array"); - Console::WriteLine( "{0,22}{1,10}{2,30}", "----", "------", "----------"); - - for each (Int64 value in values) { - // Convert each Int64 value to a byte array. - array^ byteArray = BitConverter::GetBytes(value); - // Display the result. - Console::WriteLine("{0,22}{1,10}{2,30}", value, - BitConverter::IsLittleEndian ? "Little" : " Big", - BitConverter::ToString(byteArray)); - } -} -// The example displays output like the following: -// Int64 Endian Byte Array -// ---- ------ ---------- -// 0 Little 00-00-00-00-00-00-00-00 -// 16777215 Little FF-FF-FF-00-00-00-00-00 -// -16777215 Little 01-00-00-FF-FF-FF-FF-FF -// 1000000000 Little 00-CA-9A-3B-00-00-00-00 -// -1000000000 Little 00-36-65-C4-FF-FF-FF-FF -// 4294967296 Little 00-00-00-00-01-00-00-00 -// -4294967296 Little 00-00-00-00-FF-FF-FF-FF -// 187649984473770 Little AA-AA-AA-AA-AA-AA-00-00 -// -187649984473770 Little 56-55-55-55-55-55-FF-FF -// 1000000000000000000 Little 00-00-64-A7-B3-B6-E0-0D -// -1000000000000000000 Little 00-00-9C-58-4C-49-1F-F2 -// -9223372036854775808 Little 00-00-00-00-00-00-00-80 -// 9223372036854775807 Little FF-FF-FF-FF-FF-FF-FF-7F -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.UInts/CPP/bytesuint16.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.UInts/CPP/bytesuint16.cpp deleted file mode 100644 index 5ec8af9b911..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.UInts/CPP/bytesuint16.cpp +++ /dev/null @@ -1,42 +0,0 @@ - -// -// Example of the BitConverter::GetBytes( unsigned short ) method. -using namespace System; - -// Convert an unsigned short argument to a byte array and display it. -void GetBytesUInt16( unsigned short argument ) -{ - array^byteArray = BitConverter::GetBytes( argument ); - Console::WriteLine( "{0,14}{1,13}", argument, BitConverter::ToString( byteArray ) ); -} - -int main() -{ - Console::WriteLine( "This example of the BitConverter::GetBytes( unsigned " - "short ) \nmethod generates the following output.\n" ); - Console::WriteLine( "{0,14}{1,13}", "unsigned short", "byte array" ); - Console::WriteLine( "{0,14}{1,13}", "--------------", "----------" ); - - // Convert unsigned short values and display the results. - GetBytesUInt16( 15 ); - GetBytesUInt16( 1023 ); - GetBytesUInt16( 10000 ); - GetBytesUInt16( UInt16::MinValue ); - GetBytesUInt16( Int16::MaxValue ); - GetBytesUInt16( UInt16::MaxValue ); -} - -/* -This example of the BitConverter::GetBytes( unsigned short ) -method generates the following output. - -unsigned short byte array --------------- ---------- - 15 0F-00 - 1023 FF-03 - 10000 10-27 - 0 00-00 - 32767 FF-7F - 65535 FF-FF -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.UInts/CPP/bytesuint32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.UInts/CPP/bytesuint32.cpp deleted file mode 100644 index e7017024141..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.UInts/CPP/bytesuint32.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -// -// Example of the BitConverter::GetBytes( unsigned int ) method. -using namespace System; - -// Convert an unsigned int argument to a byte array and display it. -void GetBytesUInt32( unsigned int argument ) -{ - array^byteArray = BitConverter::GetBytes( argument ); - Console::WriteLine( "{0,16}{1,20}", argument, BitConverter::ToString( byteArray ) ); -} - -int main() -{ - Console::WriteLine( "This example of the BitConverter::GetBytes( unsigned " - "int ) \nmethod generates the following output.\n" ); - Console::WriteLine( "{0,16}{1,20}", "unsigned int", "byte array" ); - Console::WriteLine( "{0,16}{1,20}", "------------", "----------" ); - - // Convert unsigned int values and display the results. - GetBytesUInt32( 15 ); - GetBytesUInt32( 1023 ); - GetBytesUInt32( 0x100000 ); - GetBytesUInt32( 1000000000 ); - GetBytesUInt32( UInt32::MinValue ); - GetBytesUInt32( Int32::MaxValue ); - GetBytesUInt32( UInt32::MaxValue ); -} - -/* -This example of the BitConverter::GetBytes( unsigned int ) -method generates the following output. - - unsigned int byte array - ------------ ---------- - 15 0F-00-00-00 - 1023 FF-03-00-00 - 1048576 00-00-10-00 - 1000000000 00-CA-9A-3B - 0 00-00-00-00 - 2147483647 FF-FF-FF-7F - 4294967295 FF-FF-FF-FF -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.UInts/CPP/bytesuint64.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.UInts/CPP/bytesuint64.cpp deleted file mode 100644 index 7c94f1c6895..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.UInts/CPP/bytesuint64.cpp +++ /dev/null @@ -1,48 +0,0 @@ - -// -// Example of the BitConverter::GetBytes( unsigned __int64 ) method. -using namespace System; - -// Convert an unsigned __int64 argument to a byte array and display it. -void GetBytesUInt64( unsigned __int64 argument ) -{ - array^byteArray = BitConverter::GetBytes( argument ); - Console::WriteLine( "{0,22}{1,30}", argument, BitConverter::ToString( byteArray ) ); -} - -int main() -{ - Console::WriteLine( "This example of the BitConverter::GetBytes( unsigned " - "__int64 ) \nmethod generates the following output.\n" ); - Console::WriteLine( "{0,22}{1,30}", "unsigned __int64", "byte array" ); - Console::WriteLine( "{0,22}{1,30}", "----------------", "----------" ); - - // Convert unsigned __int64 values and display the results. - GetBytesUInt64( 0xFFFFFF ); - GetBytesUInt64( 1000000000 ); - GetBytesUInt64( 0x100000000 ); - GetBytesUInt64( 0xAAAAAAAAAAAA ); - GetBytesUInt64( 1000000000000000000 ); - GetBytesUInt64( 10000000000000000000 ); - GetBytesUInt64( UInt64::MinValue ); - GetBytesUInt64( Int64::MaxValue ); - GetBytesUInt64( UInt64::MaxValue ); -} - -/* -This example of the BitConverter::GetBytes( unsigned __int64 ) -method generates the following output. - - unsigned __int64 byte array - ---------------- ---------- - 16777215 FF-FF-FF-00-00-00-00-00 - 1000000000 00-CA-9A-3B-00-00-00-00 - 4294967296 00-00-00-00-01-00-00-00 - 187649984473770 AA-AA-AA-AA-AA-AA-00-00 - 1000000000000000000 00-00-64-A7-B3-B6-E0-0D - 10000000000000000000 00-00-E8-89-04-23-C7-8A - 0 00-00-00-00-00-00-00-00 - 9223372036854775807 FF-FF-FF-FF-FF-FF-FF-7F - 18446744073709551615 FF-FF-FF-FF-FF-FF-FF-FF -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToString/CPP/batostring.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToString/CPP/batostring.cpp deleted file mode 100644 index 6be5740936b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToString/CPP/batostring.cpp +++ /dev/null @@ -1,51 +0,0 @@ - -// -// Example of the BitConverter::ToString( unsigned char[ ] ) method. -using namespace System; - -// Display a byte array with a name. -void WriteByteArray( array^bytes, String^ name ) -{ - String^ underLine = "--------------------------------"; - Console::WriteLine( name ); - Console::WriteLine( underLine->Substring( 0, Math::Min( name->Length, underLine->Length ) ) ); - Console::WriteLine( BitConverter::ToString( bytes ) ); - Console::WriteLine(); -} - -int main() -{ - array^arrayOne = {0,1,2,4,8,16,32,64,128,255}; - array^arrayTwo = {32,0,0,42,0,65,0,125,0,197,0,168,3,41,4,172,32}; - array^arrayThree = {15,0,0,128,16,39,240,216,241,255,127}; - array^arrayFour = {15,0,0,0,0,16,0,255,3,0,0,202,154,59,255,255,255,255,127}; - Console::WriteLine( "This example of the " - "BitConverter::ToString( unsigned char[ ] ) \n" - "method generates the following output.\n" ); - WriteByteArray( arrayOne, "arrayOne" ); - WriteByteArray( arrayTwo, "arrayTwo" ); - WriteByteArray( arrayThree, "arrayThree" ); - WriteByteArray( arrayFour, "arrayFour" ); -} - -/* -This example of the BitConverter::ToString( unsigned char[ ] ) -method generates the following output. - -arrayOne --------- -00-01-02-04-08-10-20-40-80-FF - -arrayTwo --------- -20-00-00-2A-00-41-00-7D-00-C5-00-A8-03-29-04-AC-20 - -arrayThree ----------- -0F-00-00-80-10-27-F0-D8-F1-FF-7F - -arrayFour ---------- -0F-00-00-00-00-10-00-FF-03-00-00-CA-9A-3B-FF-FF-FF-FF-7F -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToString/CPP/batostringii.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToString/CPP/batostringii.cpp deleted file mode 100644 index a35ba6d8dc5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToString/CPP/batostringii.cpp +++ /dev/null @@ -1,65 +0,0 @@ - -// -// Example of some BitConverter::ToString( ) method overloads. -using namespace System; - -// Display a byte array, using multiple lines if necessary. -void WriteMultiLineByteArray( array^bytes, String^ name ) -{ - const int rowSize = 20; - String^ underLine = "--------------------------------"; - int iter; - Console::WriteLine( name ); - Console::WriteLine( underLine->Substring( 0, Math::Min( name->Length, underLine->Length ) ) ); - for ( iter = 0; iter < bytes->Length - rowSize; iter += rowSize ) - { - Console::Write( BitConverter::ToString( bytes, iter, rowSize ) ); - Console::WriteLine( "-" ); - - } - Console::WriteLine( BitConverter::ToString( bytes, iter ) ); - Console::WriteLine(); -} - -int main() -{ - array^arrayOne = {0,0,0,0,128,63,0,0,112,65,0,255,127,71,0,0,128,59,0,0,128,47,73,70,131,5,75,6,158,63,77,6,158,63,80,6,158,63,30,55,190,121,255,255,127,255,255,127,127,1,0,0,0,192,255,0,0,128,255,0,0,128,127}; - array^arrayTwo = {255,255,255,0,0,20,0,33,0,0,0,1,0,0,0,100,167,179,182,224,13,0,202,154,59,0,143,91,0,170,170,170,170,170,170,0,0,232,137,4,35,199,138,255,232,244,255,252,205,255,255,129}; - array^arrayThree = {0,222,0,0,0,224,111,64,0,0,224,255,255,255,239,65,0,0,131,0,0,0,112,63,0,143,0,100,0,0,240,61,223,136,30,28,254,116,170,1,250,89,140,66,202,192,243,63,251,89,140,66,202,192,243,63,252,89,140,66,202,192,243,63,82,211,187,188,232,126,255,255,255,244,255,239,127,1,0,0,0,10,17,0,0,248,255,0,88,0,91,0,0,240,255,0,0,240,157}; - Console::WriteLine( "This example of the\n" - " BitConverter::ToString( unsigned char[ ], int ) and \n" - " BitConverter::ToString( unsigned char[ ], int, int ) \n" - "methods generates the following output.\n" ); - WriteMultiLineByteArray( arrayOne, "arrayOne" ); - WriteMultiLineByteArray( arrayTwo, "arrayTwo" ); - WriteMultiLineByteArray( arrayThree, "arrayThree" ); -} - -/* -This example of the - BitConverter::ToString( unsigned char[ ], int ) and - BitConverter::ToString( unsigned char[ ], int, int ) -methods generates the following output. - -arrayOne --------- -00-00-00-00-80-3F-00-00-70-41-00-FF-7F-47-00-00-80-3B-00-00- -80-2F-49-46-83-05-4B-06-9E-3F-4D-06-9E-3F-50-06-9E-3F-1E-37- -BE-79-FF-FF-7F-FF-FF-7F-7F-01-00-00-00-C0-FF-00-00-80-FF-00- -00-80-7F - -arrayTwo --------- -FF-FF-FF-00-00-14-00-21-00-00-00-01-00-00-00-64-A7-B3-B6-E0- -0D-00-CA-9A-3B-00-8F-5B-00-AA-AA-AA-AA-AA-AA-00-00-E8-89-04- -23-C7-8A-FF-E8-F4-FF-FC-CD-FF-FF-81 - -arrayThree ----------- -00-DE-00-00-00-E0-6F-40-00-00-E0-FF-FF-FF-EF-41-00-00-83-00- -00-00-70-3F-00-8F-00-64-00-00-F0-3D-DF-88-1E-1C-FE-74-AA-01- -FA-59-8C-42-CA-C0-F3-3F-FB-59-8C-42-CA-C0-F3-3F-FC-59-8C-42- -CA-C0-F3-3F-52-D3-BB-BC-E8-7E-FF-FF-FF-F4-FF-EF-7F-01-00-00- -00-0A-11-00-00-F8-FF-00-58-00-5B-00-00-F0-FF-00-00-F0-9D -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.Others/CPP/batobool.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.Others/CPP/batobool.cpp deleted file mode 100644 index d867bc4145f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.Others/CPP/batobool.cpp +++ /dev/null @@ -1,30 +0,0 @@ - -// -// Example of the BitConverter::ToBoolean method. -using namespace System; - -int main() -{ - // Define an array of byte values. - array^ bytes = { 0, 1, 2, 4, 8, 16, 32, 64, 128, 255 }; - - Console::WriteLine("{0,5}{1,16}{2,10}\n", "index", "array element", "bool" ); - // Convert each array element to a Boolean value. - for (int index = 0; index < bytes->Length; index++) - Console::WriteLine("{0,5}{1,16:X2}{2,10}", index, bytes[index], - BitConverter::ToBoolean(bytes, index)); -} -// The example displays the following output: -// index array element bool -// -// 0 00 False -// 1 01 True -// 2 02 True -// 3 04 True -// 4 08 True -// 5 10 True -// 6 20 True -// 7 40 True -// 8 80 True -// 9 FF True -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.Others/CPP/batochar.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.Others/CPP/batochar.cpp deleted file mode 100644 index cfade12139f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.Others/CPP/batochar.cpp +++ /dev/null @@ -1,59 +0,0 @@ - -// -// Example of the BitConverter::ToChar method. -using namespace System; - -// Convert two byte array elements to a __wchar_t and display it. -void BAToChar( array^bytes, int index ) -{ - __wchar_t value = BitConverter::ToChar( bytes, index ); - Console::WriteLine( "{0,5}{1,17}{2,11}", index, BitConverter::ToString( bytes, index, 2 ), value ); -} - -int main() -{ - array^byteArray = {32,0,0,42,0,65,0,125,0,197,0,168,3,41,4,172,32}; - Console::WriteLine( "This example of the BitConverter::ToChar( unsigned " - "char[ ], int ) \nmethod generates the following output. It " - "converts elements of a \nbyte array to __wchar_t values.\n" ); - Console::WriteLine( "initial unsigned char array" ); - Console::WriteLine( "---------------------------" ); - Console::WriteLine( BitConverter::ToString( byteArray ) ); - Console::WriteLine(); - Console::WriteLine( "{0,5}{1,17}{2,11}", "index", "array elements", "__wchar_t" ); - Console::WriteLine( "{0,5}{1,17}{2,11}", "-----", "--------------", "---------" ); - - // Convert byte array elements to __wchar_t values. - BAToChar( byteArray, 0 ); - BAToChar( byteArray, 1 ); - BAToChar( byteArray, 3 ); - BAToChar( byteArray, 5 ); - BAToChar( byteArray, 7 ); - BAToChar( byteArray, 9 ); - BAToChar( byteArray, 11 ); - BAToChar( byteArray, 13 ); - BAToChar( byteArray, 15 ); -} - -/* -This example of the BitConverter::ToChar(unsigned char[ ], int) -method generates the following output. It converts elements of a -byte array to __wchar_t values. - -initial unsigned char array ---------------------------- -20-00-00-2A-00-41-00-7D-00-C5-00-A8-03-29-04-AC-20 - -index array elements __wchar_t ------ -------------- --------- - 0 20-00 - 1 00-00 - 3 2A-00 * - 5 41-00 A - 7 7D-00 } - 9 C5-00 Ã… - 11 A8-03 Ψ - 13 29-04 Щ - 15 AC-20 € -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.Others/CPP/batodouble.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.Others/CPP/batodouble.cpp deleted file mode 100644 index 9e797cb8ced..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.Others/CPP/batodouble.cpp +++ /dev/null @@ -1,96 +0,0 @@ - -// -// Example of the BitConverter::ToDouble method. -using namespace System; - -// Convert eight byte array elements to a double and display it. -void BAToDouble( array^bytes, int index ) -{ - double value = BitConverter::ToDouble( bytes, index ); - Console::WriteLine( "{0,5}{1,27}{2,27:E16}", index, BitConverter::ToString( bytes, index, 8 ), value ); -} - - -// Display a byte array, using multiple lines if necessary. -void WriteMultiLineByteArray( array^bytes ) -{ - const int rowSize = 20; - int iter; - Console::WriteLine( "initial unsigned char array" ); - Console::WriteLine( "---------------------------" ); - for ( iter = 0; iter < bytes->Length - rowSize; iter += rowSize ) - { - Console::Write( BitConverter::ToString( bytes, iter, rowSize ) ); - Console::WriteLine( "-" ); - - } - Console::WriteLine( BitConverter::ToString( bytes, iter ) ); - Console::WriteLine(); -} - -int main() -{ - array^byteArray = {0,0,0,0,0,0,0,0,240,63,0,0,0,0,0,224,111,64,0,0,224,255,255,255,239,65,0,0,0,0,0,0,112,63,0,0,0,0,0,0,240,61,223,136,30,28,254,116,170,1,250,89,140,66,202,192,243,63,251,89,140,66,202,192,243,63,252,89,140,66,202,192,243,63,82,211,187,188,232,126,61,126,255,255,255,255,255,255,239,255,255,255,255,255,255,239,127,1,0,0,0,0,0,0,0,248,255,0,0,0,0,0,0,240,255,0,0,0,0,0,0,240,127}; - Console::WriteLine( "This example of the BitConverter::ToDouble( unsigned " - "char[ ], int ) \nmethod generates the following output. It " - "converts elements of a \nbyte array to double values.\n" ); - WriteMultiLineByteArray( byteArray ); - Console::WriteLine( "{0,5}{1,27}{2,27:E16}", "index", "array elements", "double" ); - Console::WriteLine( "{0,5}{1,27}{2,27:E16}", "-----", "--------------", "------" ); - - // Convert byte array elements to double values. - BAToDouble( byteArray, 0 ); - BAToDouble( byteArray, 2 ); - BAToDouble( byteArray, 10 ); - BAToDouble( byteArray, 18 ); - BAToDouble( byteArray, 26 ); - BAToDouble( byteArray, 34 ); - BAToDouble( byteArray, 42 ); - BAToDouble( byteArray, 50 ); - BAToDouble( byteArray, 58 ); - BAToDouble( byteArray, 66 ); - BAToDouble( byteArray, 74 ); - BAToDouble( byteArray, 82 ); - BAToDouble( byteArray, 89 ); - BAToDouble( byteArray, 97 ); - BAToDouble( byteArray, 99 ); - BAToDouble( byteArray, 107 ); - BAToDouble( byteArray, 115 ); -} - -/* -This example of the BitConverter.ToDouble( byte( ), int ) -method generates the following output. It converts elements -of a byte array to double values. - -initial byte array ------------------- -00-00-00-00-00-00-00-00-F0-3F-00-00-00-00-00-E0-6F-40-00-00- -E0-FF-FF-FF-EF-41-00-00-00-00-00-00-70-3F-00-00-00-00-00-00- -F0-3D-DF-88-1E-1C-FE-74-AA-01-FA-59-8C-42-CA-C0-F3-3F-FB-59- -8C-42-CA-C0-F3-3F-FC-59-8C-42-CA-C0-F3-3F-52-D3-BB-BC-E8-7E- -3D-7E-FF-FF-FF-FF-FF-FF-EF-FF-FF-FF-FF-FF-FF-EF-7F-01-00-00- -00-00-00-00-00-F8-FF-00-00-00-00-00-00-F0-FF-00-00-00-00-00- -00-F0-7F - -index array elements double ------ -------------- ------ - 0 00-00-00-00-00-00-00-00 0.0000000000000000E+000 - 2 00-00-00-00-00-00-F0-3F 1.0000000000000000E+000 - 10 00-00-00-00-00-E0-6F-40 2.5500000000000000E+002 - 18 00-00-E0-FF-FF-FF-EF-41 4.2949672950000000E+009 - 26 00-00-00-00-00-00-70-3F 3.9062500000000000E-003 - 34 00-00-00-00-00-00-F0-3D 2.3283064365386963E-010 - 42 DF-88-1E-1C-FE-74-AA-01 1.2345678901234500E-300 - 50 FA-59-8C-42-CA-C0-F3-3F 1.2345678901234565E+000 - 58 FB-59-8C-42-CA-C0-F3-3F 1.2345678901234567E+000 - 66 FC-59-8C-42-CA-C0-F3-3F 1.2345678901234569E+000 - 74 52-D3-BB-BC-E8-7E-3D-7E 1.2345678901234569E+300 - 82 FF-FF-FF-FF-FF-FF-EF-FF -1.7976931348623157E+308 - 89 FF-FF-FF-FF-FF-FF-EF-7F 1.7976931348623157E+308 - 97 01-00-00-00-00-00-00-00 4.9406564584124654E-324 - 99 00-00-00-00-00-00-F8-FF NaN - 107 00-00-00-00-00-00-F0-FF -Infinity - 115 00-00-00-00-00-00-F0-7F Infinity -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.Others/CPP/batosingle.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.Others/CPP/batosingle.cpp deleted file mode 100644 index bd457501a14..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.Others/CPP/batosingle.cpp +++ /dev/null @@ -1,93 +0,0 @@ - -// -// Example of the BitConverter::ToSingle method. -using namespace System; - -// Convert four byte array elements to a float and display it. -void BAToSingle( array^bytes, int index ) -{ - float value = BitConverter::ToSingle( bytes, index ); - Console::WriteLine( "{0,5}{1,17}{2,18:E7}", index, BitConverter::ToString( bytes, index, 4 ), value ); -} - - -// Display a byte array, using multiple lines if necessary. -void WriteMultiLineByteArray( array^bytes ) -{ - const int rowSize = 20; - int iter; - Console::WriteLine( "initial unsigned char array" ); - Console::WriteLine( "---------------------------" ); - for ( iter = 0; iter < bytes->Length - rowSize; iter += rowSize ) - { - Console::Write( BitConverter::ToString( bytes, iter, rowSize ) ); - Console::WriteLine( "-" ); - - } - Console::WriteLine( BitConverter::ToString( bytes, iter ) ); - Console::WriteLine(); -} - -int main() -{ - array^byteArray = {0,0,0,0,128,63,0,0,112,65,0,255,127,71,0,0,128,59,0,0,128,47,73,70,131,5,75,6,158,63,77,6,158,63,80,6,158,63,30,55,190,121,255,255,127,255,255,127,127,1,0,0,0,192,255,0,0,128,255,0,0,128,127}; - Console::WriteLine( "This example of the BitConverter::ToSingle( unsigned " - "char[ ], int ) \nmethod generates the following output. It " - "converts elements of a \nbyte array to float values.\n" ); - WriteMultiLineByteArray( byteArray ); - Console::WriteLine( "{0,5}{1,17}{2,18:E7}", "index", "array elements", "float" ); - Console::WriteLine( "{0,5}{1,17}{2,18:E7}", "-----", "--------------", "-----" ); - - // Convert byte array elements to float values. - BAToSingle( byteArray, 0 ); - BAToSingle( byteArray, 2 ); - BAToSingle( byteArray, 6 ); - BAToSingle( byteArray, 10 ); - BAToSingle( byteArray, 14 ); - BAToSingle( byteArray, 18 ); - BAToSingle( byteArray, 22 ); - BAToSingle( byteArray, 26 ); - BAToSingle( byteArray, 30 ); - BAToSingle( byteArray, 34 ); - BAToSingle( byteArray, 38 ); - BAToSingle( byteArray, 42 ); - BAToSingle( byteArray, 45 ); - BAToSingle( byteArray, 49 ); - BAToSingle( byteArray, 51 ); - BAToSingle( byteArray, 55 ); - BAToSingle( byteArray, 59 ); -} - -/* -This example of the BitConverter::ToSingle( unsigned char[ ], int ) -method generates the following output. It converts elements of a -byte array to float values. - -initial unsigned char array ---------------------------- -00-00-00-00-80-3F-00-00-70-41-00-FF-7F-47-00-00-80-3B-00-00- -80-2F-49-46-83-05-4B-06-9E-3F-4D-06-9E-3F-50-06-9E-3F-1E-37- -BE-79-FF-FF-7F-FF-FF-7F-7F-01-00-00-00-C0-FF-00-00-80-FF-00- -00-80-7F - -index array elements float ------ -------------- ----- - 0 00-00-00-00 0.0000000E+000 - 2 00-00-80-3F 1.0000000E+000 - 6 00-00-70-41 1.5000000E+001 - 10 00-FF-7F-47 6.5535000E+004 - 14 00-00-80-3B 3.9062500E-003 - 18 00-00-80-2F 2.3283064E-010 - 22 49-46-83-05 1.2345000E-035 - 26 4B-06-9E-3F 1.2345671E+000 - 30 4D-06-9E-3F 1.2345673E+000 - 34 50-06-9E-3F 1.2345676E+000 - 38 1E-37-BE-79 1.2345679E+035 - 42 FF-FF-7F-FF -3.4028235E+038 - 45 FF-FF-7F-7F 3.4028235E+038 - 49 01-00-00-00 1.4012985E-045 - 51 00-00-C0-FF NaN - 55 00-00-80-FF -Infinity - 59 00-00-80-7F Infinity -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.SInts/CPP/batoint16.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.SInts/CPP/batoint16.cpp deleted file mode 100644 index 92c948b4d19..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.SInts/CPP/batoint16.cpp +++ /dev/null @@ -1,55 +0,0 @@ - -// -// Example of the BitConverter::ToInt16 method. -using namespace System; - -// Convert two byte array elements to a short and display it. -void BAToInt16( array^bytes, int index ) -{ - short value = BitConverter::ToInt16( bytes, index ); - Console::WriteLine( "{0,5}{1,17}{2,10}", index, BitConverter::ToString( bytes, index, 2 ), value ); -} - -int main() -{ - array^byteArray = {15,0,0,128,16,39,240,216,241,255,127}; - Console::WriteLine( "This example of the BitConverter::ToInt16( unsigned " - "char[ ], int ) \nmethod generates the following output. It " - "converts elements of a \nbyte array to short values.\n" ); - Console::WriteLine( "initial byte array" ); - Console::WriteLine( "------------------" ); - Console::WriteLine( BitConverter::ToString( byteArray ) ); - Console::WriteLine(); - Console::WriteLine( "{0,5}{1,17}{2,10}", "index", "array elements", "short" ); - Console::WriteLine( "{0,5}{1,17}{2,10}", "-----", "--------------", "-----" ); - - // Convert byte array elements to short values. - BAToInt16( byteArray, 1 ); - BAToInt16( byteArray, 0 ); - BAToInt16( byteArray, 8 ); - BAToInt16( byteArray, 4 ); - BAToInt16( byteArray, 6 ); - BAToInt16( byteArray, 9 ); - BAToInt16( byteArray, 2 ); -} - -/* -This example of the BitConverter::ToInt16( unsigned char[ ], int ) -method generates the following output. It converts elements of a -byte array to short values. - -initial byte array ------------------- -0F-00-00-80-10-27-F0-D8-F1-FF-7F - -index array elements short ------ -------------- ----- - 1 00-00 0 - 0 0F-00 15 - 8 F1-FF -15 - 4 10-27 10000 - 6 F0-D8 -10000 - 9 FF-7F 32767 - 2 00-80 -32768 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.SInts/CPP/batoint64.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.SInts/CPP/batoint64.cpp deleted file mode 100644 index d3e8f559b3c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.SInts/CPP/batoint64.cpp +++ /dev/null @@ -1,85 +0,0 @@ - -// -// Example of the BitConverter::ToInt64 method. -using namespace System; - -// Convert eight byte array elements to an __int64 and display it. -void BAToInt64( array^bytes, int index ) -{ - __int64 value = BitConverter::ToInt64( bytes, index ); - Console::WriteLine( "{0,5}{1,27}{2,24}", index, BitConverter::ToString( bytes, index, 8 ), value ); -} - - -// Display a byte array, using multiple lines if necessary. -void WriteMultiLineByteArray( array^bytes ) -{ - const int rowSize = 20; - int iter; - Console::WriteLine( "initial unsigned char array" ); - Console::WriteLine( "---------------------------" ); - for ( iter = 0; iter < bytes->Length - rowSize; iter += rowSize ) - { - Console::Write( BitConverter::ToString( bytes, iter, rowSize ) ); - Console::WriteLine( "-" ); - - } - Console::WriteLine( BitConverter::ToString( bytes, iter ) ); - Console::WriteLine(); -} - -int main() -{ - array^byteArray = {0,54,101,196,255,255,255,255,0,0,0,0,0,0,0,0,128,0,202,154,59,0,0,0,0,1,0,0,0,0,255,255,255,255,1,0,0,255,255,255,255,255,255,255,127,86,85,85,85,85,85,255,255,170,170,170,170,170,170,0,0,100,167,179,182,224,13,0,0,156,88,76,73,31,242}; - Console::WriteLine( "This example of the BitConverter::ToInt64( unsigned " - "char[ ], int ) \nmethod generates the following output. It " - "converts elements of a \nbyte array to __int64 values.\n" ); - WriteMultiLineByteArray( byteArray ); - Console::WriteLine( "{0,5}{1,27}{2,24}", "index", "array elements", "__int64" ); - Console::WriteLine( "{0,5}{1,27}{2,24}", "-----", "--------------", "-------" ); - - // Convert byte array elements to __int64 values. - BAToInt64( byteArray, 8 ); - BAToInt64( byteArray, 5 ); - BAToInt64( byteArray, 34 ); - BAToInt64( byteArray, 17 ); - BAToInt64( byteArray, 0 ); - BAToInt64( byteArray, 21 ); - BAToInt64( byteArray, 26 ); - BAToInt64( byteArray, 53 ); - BAToInt64( byteArray, 45 ); - BAToInt64( byteArray, 59 ); - BAToInt64( byteArray, 67 ); - BAToInt64( byteArray, 37 ); - BAToInt64( byteArray, 9 ); -} - -/* -This example of the BitConverter::ToInt64( unsigned char[ ], int ) -method generates the following output. It converts elements of a -byte array to __int64 values. - -initial unsigned char array ---------------------------- -00-36-65-C4-FF-FF-FF-FF-00-00-00-00-00-00-00-00-80-00-CA-9A- -3B-00-00-00-00-01-00-00-00-00-FF-FF-FF-FF-01-00-00-FF-FF-FF- -FF-FF-FF-FF-7F-56-55-55-55-55-55-FF-FF-AA-AA-AA-AA-AA-AA-00- -00-64-A7-B3-B6-E0-0D-00-00-9C-58-4C-49-1F-F2 - -index array elements __int64 ------ -------------- ------- - 8 00-00-00-00-00-00-00-00 0 - 5 FF-FF-FF-00-00-00-00-00 16777215 - 34 01-00-00-FF-FF-FF-FF-FF -16777215 - 17 00-CA-9A-3B-00-00-00-00 1000000000 - 0 00-36-65-C4-FF-FF-FF-FF -1000000000 - 21 00-00-00-00-01-00-00-00 4294967296 - 26 00-00-00-00-FF-FF-FF-FF -4294967296 - 53 AA-AA-AA-AA-AA-AA-00-00 187649984473770 - 45 56-55-55-55-55-55-FF-FF -187649984473770 - 59 00-00-64-A7-B3-B6-E0-0D 1000000000000000000 - 67 00-00-9C-58-4C-49-1F-F2 -1000000000000000000 - 37 FF-FF-FF-FF-FF-FF-FF-7F 9223372036854775807 - 9 00-00-00-00-00-00-00-80 -9223372036854775808 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.UInts/CPP/batouint16.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.UInts/CPP/batouint16.cpp deleted file mode 100644 index c882255558e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.UInts/CPP/batouint16.cpp +++ /dev/null @@ -1,54 +0,0 @@ - -// -// Example of the BitConverter::ToUInt16 method. -using namespace System; - -// Convert two byte array elements to an unsigned short and display it. -void BAToUInt16( array^bytes, int index ) -{ - unsigned short value = BitConverter::ToUInt16( bytes, index ); - Console::WriteLine( "{0,5}{1,17}{2,16}", index, BitConverter::ToString( bytes, index, 2 ), value ); -} - -int main() -{ - array^byteArray = {15,0,0,255,3,16,39,255,255,127}; - Console::WriteLine( "This example of the BitConverter::ToUInt16( unsigned " - "char[ ], int ) \nmethod generates the following output. It " - "converts elements of a \nbyte array to unsigned short " - "values.\n" ); - Console::WriteLine( "initial byte array" ); - Console::WriteLine( "------------------" ); - Console::WriteLine( BitConverter::ToString( byteArray ) ); - Console::WriteLine(); - Console::WriteLine( "{0,5}{1,17}{2,16}", "index", "array elements", "unsigned short" ); - Console::WriteLine( "{0,5}{1,17}{2,16}", "-----", "--------------", "--------------" ); - - // Convert byte array elements to unsigned short values. - BAToUInt16( byteArray, 1 ); - BAToUInt16( byteArray, 0 ); - BAToUInt16( byteArray, 3 ); - BAToUInt16( byteArray, 5 ); - BAToUInt16( byteArray, 8 ); - BAToUInt16( byteArray, 7 ); -} - -/* -This example of the BitConverter::ToUInt16( unsigned char[ ], int ) -method generates the following output. It converts elements of a -byte array to unsigned short values. - -initial byte array ------------------- -0F-00-00-FF-03-10-27-FF-FF-7F - -index array elements unsigned short ------ -------------- -------------- - 1 00-00 0 - 0 0F-00 15 - 3 FF-03 1023 - 5 10-27 10000 - 8 FF-7F 32767 - 7 FF-FF 65535 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.UInts/CPP/batouint32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.UInts/CPP/batouint32.cpp deleted file mode 100644 index ea1eb361eda..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.UInts/CPP/batouint32.cpp +++ /dev/null @@ -1,56 +0,0 @@ - -// -// Example of the BitConverter::ToUInt32 method. -using namespace System; - -// Convert four byte array elements to an unsigned int and display it. -void BAToUInt32( array^bytes, int index ) -{ - unsigned int value = BitConverter::ToUInt32( bytes, index ); - Console::WriteLine( "{0,5}{1,17}{2,15}", index, BitConverter::ToString( bytes, index, 4 ), value ); -} - -int main() -{ - array^byteArray = {15,0,0,0,0,16,0,255,3,0,0,202,154,59,255,255,255,255,127}; - Console::WriteLine( "This example of the BitConverter::ToUInt32( unsigned " - "char[ ], int ) \nmethod generates the following output. It " - "converts elements of a \nbyte array to unsigned int " - "values.\n" ); - Console::WriteLine( "initial byte array" ); - Console::WriteLine( "------------------" ); - Console::WriteLine( BitConverter::ToString( byteArray ) ); - Console::WriteLine(); - Console::WriteLine( "{0,5}{1,17}{2,15}", "index", "array elements", "unsigned int" ); - Console::WriteLine( "{0,5}{1,17}{2,15}", "-----", "--------------", "------------" ); - - // Convert byte array elements to unsigned int values. - BAToUInt32( byteArray, 1 ); - BAToUInt32( byteArray, 0 ); - BAToUInt32( byteArray, 7 ); - BAToUInt32( byteArray, 3 ); - BAToUInt32( byteArray, 10 ); - BAToUInt32( byteArray, 15 ); - BAToUInt32( byteArray, 14 ); -} - -/* -This example of the BitConverter::ToUInt32( unsigned char[ ], int ) -method generates the following output. It converts elements of a -byte array to unsigned int values. - -initial byte array ------------------- -0F-00-00-00-00-10-00-FF-03-00-00-CA-9A-3B-FF-FF-FF-FF-7F - -index array elements unsigned int ------ -------------- ------------ - 1 00-00-00-00 0 - 0 0F-00-00-00 15 - 7 FF-03-00-00 1023 - 3 00-00-10-00 1048576 - 10 00-CA-9A-3B 1000000000 - 15 FF-FF-FF-7F 2147483647 - 14 FF-FF-FF-FF 4294967295 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.UInts/CPP/batouint64.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.UInts/CPP/batouint64.cpp deleted file mode 100644 index 102a5ced116..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.UInts/CPP/batouint64.cpp +++ /dev/null @@ -1,78 +0,0 @@ - -// -// Example of the BitConverter::ToUInt64 method. -using namespace System; - -// Convert eight byte array elements to an unsigned __int64 value and -// display it. -void BAToUInt64( array^bytes, int index ) -{ - unsigned __int64 value = BitConverter::ToUInt64( bytes, index ); - Console::WriteLine( "{0,5}{1,27}{2,24}", index, BitConverter::ToString( bytes, index, 8 ), value ); -} - - -// Display a byte array, using multiple lines if necessary. -void WriteMultiLineByteArray( array^bytes ) -{ - const int rowSize = 20; - int iter; - Console::WriteLine( "initial unsigned char array" ); - Console::WriteLine( "---------------------------" ); - for ( iter = 0; iter < bytes->Length - rowSize; iter += rowSize ) - { - Console::Write( BitConverter::ToString( bytes, iter, rowSize ) ); - Console::WriteLine( "-" ); - - } - Console::WriteLine( BitConverter::ToString( bytes, iter ) ); - Console::WriteLine(); -} - -int main() -{ - array^byteArray = {255,255,255,0,0,0,0,0,0,0,0,1,0,0,0,100,167,179,182,224,13,0,202,154,59,0,0,0,0,170,170,170,170,170,170,0,0,232,137,4,35,199,138,255,255,255,255,255,255,255,255,127}; - Console::WriteLine( "This example of the BitConverter::ToUInt64( unsigned " - "char[ ], int ) \nmethod generates the following output. It " - "converts elements of a \nbyte array to unsigned __int64 " - "values.\n" ); - WriteMultiLineByteArray( byteArray ); - Console::WriteLine( "{0,5}{1,27}{2,24}", "index", "array elements", "unsigned __int64" ); - Console::WriteLine( "{0,5}{1,27}{2,24}", "-----", "--------------", "----------------" ); - - // Convert byte array elements to unsigned __int64 values. - BAToUInt64( byteArray, 3 ); - BAToUInt64( byteArray, 0 ); - BAToUInt64( byteArray, 21 ); - BAToUInt64( byteArray, 7 ); - BAToUInt64( byteArray, 29 ); - BAToUInt64( byteArray, 13 ); - BAToUInt64( byteArray, 35 ); - BAToUInt64( byteArray, 44 ); - BAToUInt64( byteArray, 43 ); -} - -/* -This example of the BitConverter::ToUInt64( unsigned char[ ], int ) -method generates the following output. It converts elements of a -byte array to unsigned __int64 values. - -initial unsigned char array ---------------------------- -FF-FF-FF-00-00-00-00-00-00-00-00-01-00-00-00-64-A7-B3-B6-E0- -0D-00-CA-9A-3B-00-00-00-00-AA-AA-AA-AA-AA-AA-00-00-E8-89-04- -23-C7-8A-FF-FF-FF-FF-FF-FF-FF-FF-7F - -index array elements unsigned __int64 ------ -------------- ---------------- - 3 00-00-00-00-00-00-00-00 0 - 0 FF-FF-FF-00-00-00-00-00 16777215 - 21 00-CA-9A-3B-00-00-00-00 1000000000 - 7 00-00-00-00-01-00-00-00 4294967296 - 29 AA-AA-AA-AA-AA-AA-00-00 187649984473770 - 13 00-00-64-A7-B3-B6-E0-0D 1000000000000000000 - 35 00-00-E8-89-04-23-C7-8A 10000000000000000000 - 44 FF-FF-FF-FF-FF-FF-FF-7F 9223372036854775807 - 43 FF-FF-FF-FF-FF-FF-FF-FF 18446744073709551615 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Boolean/CPP/booleanmembers.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Boolean/CPP/booleanmembers.cpp deleted file mode 100644 index 32b17db75b6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Boolean/CPP/booleanmembers.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -using namespace System; -int main() -{ - - // - Boolean raining = false; - Boolean busLate = true; - Console::WriteLine( "raining->ToString() returns {0}", raining.ToString() ); - Console::WriteLine( "busLate->ToString() returns {0}", busLate.ToString() ); - // The example displays the following output: - // raining.ToString() returns False - // busLate.ToString() returns True - // - - // - Boolean val; - String^ input; - input = Boolean::TrueString; - val = Boolean::Parse( input ); - Console::WriteLine( "'{0}' parsed as {1}", input, val ); - // The example displays the following output: - // 'True' parsed as True - // -} - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Buffer.BlockCopy/CPP/bcopy.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Buffer.BlockCopy/CPP/bcopy.cpp deleted file mode 100644 index 2ece40209b1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Buffer.BlockCopy/CPP/bcopy.cpp +++ /dev/null @@ -1,137 +0,0 @@ -// Buffer.BlockCopy2.cpp : main project file. - -// -using namespace System; - -// Display the individual bytes in the array in hexadecimal. -void DisplayArray(System::Array^ arr, String^ name) -{ - Console::WindowWidth = 120; - Console::Write("{0,11}:", name); - for (int ctr = 0; ctr < arr->Length; ctr++) - { - array^ bytes; - if (arr->GetType() == array::typeid) - bytes = BitConverter::GetBytes((Int64) arr->GetValue(ctr)); - else - bytes = BitConverter::GetBytes((Int16) arr->GetValue(ctr)); - - for each (Byte byteValue in bytes) - Console::Write(" {0:X2}", byteValue); - } - Console::WriteLine(); -} - -// Display the individual array element values in hexadecimal. -void DisplayArrayValues(Array^ arr, String^ name) -{ - // Get the length of one element in the array. - int elementLength = Buffer::ByteLength(arr) / arr->Length; - String^ formatString = String::Format(" {{0:X{0}}}", 2 * elementLength); - Console::Write( "{0,11}:", name); - for (int ctr = 0; ctr < arr->Length; ctr++) - Console::Write(formatString, arr->GetValue(ctr)); - - Console::WriteLine(); -} - -void main() -{ - // These are the source and destination arrays for BlockCopy. - array^ src = gcnew array { 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270 }; - array^ dest = gcnew array { 17, 18, 19, 20 }; - - // Display the initial value of the arrays in memory. - Console::WriteLine( "Initial values of arrays:"); - Console::WriteLine(" Array values as Bytes:"); - DisplayArray(src, "src" ); - DisplayArray(dest, "dest"); - Console::WriteLine(" Array values:"); - DisplayArrayValues(src, "src"); - DisplayArrayValues(dest, "dest"); - Console::WriteLine(); - - // Copy bytes 5-10 from source to index 7 in destination and display the result. - Buffer::BlockCopy(src, 5, dest, 7, 6); - Console::WriteLine("Buffer::BlockCopy(src, 5, dest, 7, 6 )"); - Console::WriteLine(" Array values as Bytes:"); - DisplayArray(src, "src"); - DisplayArray(dest, "dest"); - Console::WriteLine(" Array values:"); - DisplayArrayValues(src, "src"); - DisplayArrayValues(dest, "dest"); - Console::WriteLine(); - - // Copy bytes 16-20 from source to index 22 in destination and display the result. - Buffer::BlockCopy(src, 16, dest, 22, 5); - Console::WriteLine("Buffer.BlockCopy(src, 16, dest, 22, 5)"); - Console::WriteLine(" Array values as Bytes:"); - DisplayArray(src, "src"); - DisplayArray(dest, "dest"); - Console::WriteLine(" Array values:"); - DisplayArrayValues(src, "src"); - DisplayArrayValues(dest, "dest"); - Console::WriteLine(); - - // Copy overlapping range of bytes 4-10 to index 5 in source. - Buffer::BlockCopy(src, 4, src, 5, 7 ); - Console::WriteLine("Buffer.BlockCopy( src, 4, src, 5, 7)"); - Console::WriteLine(" Array values as Bytes:"); - DisplayArray(src, "src"); - DisplayArray(dest, "dest"); - Console::WriteLine(" Array values:"); - DisplayArrayValues(src, "src"); - DisplayArrayValues(dest, "dest"); - Console::WriteLine(); - - // Copy overlapping range of bytes 16-22 to index 15 in source. - Buffer::BlockCopy(src, 16, src, 15, 7); - Console::WriteLine("Buffer.BlockCopy( src, 16, src, 15, 7)"); - Console::WriteLine(" Array values as Bytes:"); - DisplayArray(src, "src"); - DisplayArray(dest, "dest"); - Console::WriteLine(" Array values:"); - DisplayArrayValues(src, "src"); -} -// The example displays the following output: -// Initial values of arrays: -// Array values as Bytes: -// src: 02 01 03 01 04 01 05 01 06 01 07 01 08 01 09 01 0A 01 0B 01 0C 01 0D 01 0E 01 -// dest: 11 00 00 00 00 00 00 00 12 00 00 00 00 00 00 00 13 00 00 00 00 00 00 00 14 00 00 00 00 00 00 00 -// Array values: -// src: 0102 0103 0104 0105 0106 0107 0108 0109 010A 010B 010C 010D 010E -// dest: 0000000000000011 0000000000000012 0000000000000013 0000000000000014 -// -// Buffer.BlockCopy(src, 5, dest, 7, 6 ) -// Array values as Bytes: -// src: 02 01 03 01 04 01 05 01 06 01 07 01 08 01 09 01 0A 01 0B 01 0C 01 0D 01 0E 01 -// dest: 11 00 00 00 00 00 00 01 05 01 06 01 07 00 00 00 13 00 00 00 00 00 00 00 14 00 00 00 00 00 00 00 -// Array values: -// src: 0102 0103 0104 0105 0106 0107 0108 0109 010A 010B 010C 010D 010E -// dest: 0100000000000011 0000000701060105 0000000000000013 0000000000000014 -// -// Buffer.BlockCopy(src, 16, dest, 22, 5) -// Array values as Bytes: -// src: 02 01 03 01 04 01 05 01 06 01 07 01 08 01 09 01 0A 01 0B 01 0C 01 0D 01 0E 01 -// dest: 11 00 00 00 00 00 00 01 05 01 06 01 07 00 00 00 13 00 00 00 00 00 0A 01 0B 01 0C 00 00 00 00 00 -// Array values: -// src: 0102 0103 0104 0105 0106 0107 0108 0109 010A 010B 010C 010D 010E -// dest: 0100000000000011 0000000701060105 010A000000000013 00000000000C010B -// -// Buffer.BlockCopy( src, 4, src, 5, 7) -// Array values as Bytes: -// src: 02 01 03 01 04 04 01 05 01 06 01 07 08 01 09 01 0A 01 0B 01 0C 01 0D 01 0E 01 -// dest: 11 00 00 00 00 00 00 01 05 01 06 01 07 00 00 00 13 00 00 00 00 00 0A 01 0B 01 0C 00 00 00 00 00 -// Array values: -// src: 0102 0103 0404 0501 0601 0701 0108 0109 010A 010B 010C 010D 010E -// dest: 0100000000000011 0000000701060105 010A000000000013 00000000000C010B -// -// Buffer.BlockCopy( src, 16, src, 15, 7) -// Array values as Bytes: -// src: 02 01 03 01 04 04 01 05 01 06 01 07 08 01 09 0A 01 0B 01 0C 01 0D 0D 01 0E 01 -// dest: 11 00 00 00 00 00 00 01 05 01 06 01 07 00 00 00 13 00 00 00 00 00 0A 01 0B 01 0C 00 00 00 00 00 -// Array values: -// src: 0102 0103 0404 0501 0601 0701 0108 0A09 0B01 0C01 0D01 010D 010E -// dest: 0100000000000011 0000000701060105 010A000000000013 00000000000C010B -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Buffer.BlockCopy/CPP/buffer.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Buffer.BlockCopy/CPP/buffer.cpp deleted file mode 100644 index 2ce360f905c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Buffer.BlockCopy/CPP/buffer.cpp +++ /dev/null @@ -1,62 +0,0 @@ - -// -// Example of the Buffer class methods. -using namespace System; - -// Display the array elements from right to left in hexadecimal. -void DisplayArray( array^arr ) -{ - Console::Write( " arr:" ); - for ( int loopX = arr->Length - 1; loopX >= 0; loopX-- ) - Console::Write( " {0:X4}", arr[ loopX ] ); - Console::WriteLine(); -} - -int main() -{ - - // This array is to be modified and displayed. - array^arr = {258,259,260,261,262,263,264,265,266,267,268,269,270,271}; - Console::WriteLine( "This example of the Buffer class " - "methods generates the following output.\n" - "Note: The array is displayed from right to left.\n" ); - Console::WriteLine( "Initial values of array:\n" ); - - // Display the initial array values and ByteLength. - DisplayArray( arr ); - Console::WriteLine( "\nBuffer::ByteLength( arr ): {0}", Buffer::ByteLength( arr ) ); - - // Copy a region of the array; set a byte within the array. - Console::WriteLine( "\nCall these methods: \n" - " Buffer::BlockCopy( arr, 5, arr, 16, 9 ),\n" - " Buffer::SetByte( arr, 7, 170 ).\n" ); - Buffer::BlockCopy( arr, 5, arr, 16, 9 ); - Buffer::SetByte( arr, 7, 170 ); - - // Display the array and a byte within the array. - Console::WriteLine( "Final values of array:\n" ); - DisplayArray( arr ); - Console::WriteLine( "\nBuffer::GetByte( arr, 26 ): {0}", Buffer::GetByte( arr, 26 ) ); -} - -/* -This example of the Buffer class methods generates the following output. -Note: The array is displayed from right to left. - -Initial values of array: - - arr: 010F 010E 010D 010C 010B 010A 0109 0108 0107 0106 0105 0104 0103 0102 - -Buffer::ByteLength( arr ): 28 - -Call these methods: - Buffer::BlockCopy( arr, 5, arr, 16, 9 ), - Buffer::SetByte( arr, 7, 170 ). - -Final values of array: - - arr: 010F 0101 0801 0701 0601 0501 0109 0108 0107 0106 AA05 0104 0103 0102 - -Buffer::GetByte( arr, 26 ): 15 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Buffer.BlockCopy/CPP/overlap1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Buffer.BlockCopy/CPP/overlap1.cpp deleted file mode 100644 index 01bfe45c621..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Buffer.BlockCopy/CPP/overlap1.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// Buffer.BlockCopy.cpp : main project file. - -using namespace System; - -void CopyExample1() -{ - // - const int INT_SIZE = 4; - array^ arr = gcnew array { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 }; - Buffer::BlockCopy(arr, 0 * INT_SIZE, arr, 3 * INT_SIZE, 4 * INT_SIZE); - for each (int value in arr) - Console::Write("{0} ", value); - // The example displays the following output: - // 2 4 6 2 4 6 8 16 18 20 - // -} - -void CopyExample2() -{ - // - const int INT_SIZE = 4; - array^ arr = gcnew array { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 }; - Buffer::BlockCopy(arr, 3 * INT_SIZE, arr, 0 * INT_SIZE, 4 * INT_SIZE); - for each (int value in arr) - Console::Write("{0} ", value); - // The example displays the following output: - // 8 10 12 14 10 12 14 16 18 20 - // -} - -void main() -{ - CopyExample1(); - Console::WriteLine(); - CopyExample2(); - Console::ReadLine(); -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Buffer.Bytes/CPP/bytelength.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Buffer.Bytes/CPP/bytelength.cpp deleted file mode 100644 index 08596f73850..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Buffer.Bytes/CPP/bytelength.cpp +++ /dev/null @@ -1,52 +0,0 @@ - -// -// Example of the Buffer::ByteLength method. -using namespace System; - -void ArrayInfo( Array^ arr, String^ name ) -{ - int byteLength = Buffer::ByteLength( arr ); - - // Display the array name, type, Length, and ByteLength. - Console::WriteLine( "{0,10}{1,20}{2,9}{3,12}", name, arr->GetType(), arr->Length, byteLength ); -} - -int main() -{ - array^bytes = {1,2,3,4,5,6,7,8,9,0}; - array^bools = {true,false,true,false,true}; - array^chars = {' ','$','\"','A','{'}; - array^shorts = {258,259,260,261,262,263}; - array^singles = {1,678,2.37E33F,.00415F,8.9F}; - array^doubles = {2E-22,.003,4.4E44,555E55}; - array^longs = {1,10,100,1000,10000,100000}; - Console::WriteLine( "This example of the Buffer::ByteLength( Array* ) " - "\nmethod generates the following output.\n" ); - Console::WriteLine( "{0,10}{1,20}{2,9}{3,12}", "Array name", "Array type", "Length", "ByteLength" ); - Console::WriteLine( "{0,10}{1,20}{2,9}{3,12}", "----------", "----------", "------", "----------" ); - - // Display the Length and ByteLength for each array. - ArrayInfo( bytes, "bytes" ); - ArrayInfo( bools, "bools" ); - ArrayInfo( chars, "chars" ); - ArrayInfo( shorts, "shorts" ); - ArrayInfo( singles, "singles" ); - ArrayInfo( doubles, "doubles" ); - ArrayInfo( longs, "longs" ); -} - -/* -This example of the Buffer::ByteLength( Array* ) -method generates the following output. - -Array name Array type Length ByteLength ----------- ---------- ------ ---------- - bytes System.Byte[] 10 10 - bools System.Boolean[] 5 5 - chars System.Char[] 5 10 - shorts System.Int16[] 6 12 - singles System.Single[] 5 20 - doubles System.Double[] 4 32 - longs System.Int32[] 6 24 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Buffer.Bytes/CPP/getbyte.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Buffer.Bytes/CPP/getbyte.cpp deleted file mode 100644 index 2b8f8c6e6ad..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Buffer.Bytes/CPP/getbyte.cpp +++ /dev/null @@ -1,83 +0,0 @@ - -// -// Example of the Buffer::GetByte method. -using namespace System; -#define formatter "{0,10}{1,10}{2,9} {3}" - -// Display the array contents in hexadecimal. -void DisplayArray( Array^ arr, String^ name ) -{ - - // Get the array element width; format the formatting string. - int elemWidth = Buffer::ByteLength( arr ) / arr->Length; - String^ format = String::Format( " {{0:X{0}}}", 2 * elemWidth ); - - // Display the array elements from right to left. - Console::Write( "{0,5}:", name ); - for ( int loopX = arr->Length - 1; loopX >= 0; loopX-- ) - Console::Write( format, arr->GetValue( loopX ) ); - Console::WriteLine(); -} - -void ArrayInfo( Array^ arr, String^ name, int index ) -{ - unsigned char value = Buffer::GetByte( arr, index ); - - // Display the array name, index, and byte to be viewed. - Console::WriteLine( formatter, name, index, value, String::Format( "0x{0:X2}", value ) ); -} - -int main() -{ - - // These are the arrays to be viewed with GetByte. - array<__int64>^longs = {333333333333333333,666666666666666666,999999999999999999}; - array^ints = {111111111,222222222,333333333,444444444,555555555}; - Console::WriteLine( "This example of the " - "Buffer::GetByte( Array*, int ) \n" - "method generates the following output.\n" - "Note: The arrays are displayed from right to left.\n" ); - Console::WriteLine( " Values of arrays:\n" ); - - // Display the values of the arrays. - DisplayArray( longs, "longs" ); - DisplayArray( ints, "ints" ); - Console::WriteLine(); - Console::WriteLine( formatter, "Array", "index", "value", "" ); - Console::WriteLine( formatter, "-----", "-----", "-----", "----" ); - - // Display the Length and ByteLength for each array. - ArrayInfo( ints, "ints", 0 ); - ArrayInfo( ints, "ints", 7 ); - ArrayInfo( ints, "ints", 10 ); - ArrayInfo( ints, "ints", 17 ); - ArrayInfo( longs, "longs", 0 ); - ArrayInfo( longs, "longs", 6 ); - ArrayInfo( longs, "longs", 10 ); - ArrayInfo( longs, "longs", 17 ); - ArrayInfo( longs, "longs", 21 ); -} - -/* -This example of the Buffer::GetByte( Array*, int ) -method generates the following output. -Note: The arrays are displayed from right to left. - - Values of arrays: - -longs: 0DE0B6B3A763FFFF 094079CD1A42AAAA 04A03CE68D215555 - ints: 211D1AE3 1A7DAF1C 13DE4355 0D3ED78E 069F6BC7 - - Array index value - ----- ----- ----- ---- - ints 0 199 0xC7 - ints 7 13 0x0D - ints 10 222 0xDE - ints 17 26 0x1A - longs 0 85 0x55 - longs 6 160 0xA0 - longs 10 66 0x42 - longs 17 255 0xFF - longs 21 182 0xB6 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Buffer.Bytes/CPP/setbyte.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Buffer.Bytes/CPP/setbyte.cpp deleted file mode 100644 index 564641225bf..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Buffer.Bytes/CPP/setbyte.cpp +++ /dev/null @@ -1,71 +0,0 @@ - -// -// Example of the Buffer::SetByte method. -using namespace System; - -// Display the array contents in hexadecimal. -void DisplayArray( Array^ arr, String^ name ) -{ - - // Get the array element width; format the formatting string. - int elemWidth = Buffer::ByteLength( arr ) / arr->Length; - String^ format = String::Format( " {{0:X{0}}}", 2 * elemWidth ); - - // Display the array elements from right to left. - Console::Write( "{0,7}:", name ); - for ( int loopX = arr->Length - 1; loopX >= 0; loopX-- ) - Console::Write( format, arr->GetValue( loopX ) ); - Console::WriteLine(); -} - -int main() -{ - - // These are the arrays to be modified with SetByte. - array^shorts = gcnew array(10); - array^longs = gcnew array(3); - Console::WriteLine( "This example of the " - "Buffer::SetByte( Array*, int, unsigned char ) \n" - "method generates the following output.\n" - "Note: The arrays are displayed from right to left.\n" ); - Console::WriteLine( " Initial values of arrays:\n" ); - - // Display the initial values of the arrays. - DisplayArray( shorts, "shorts" ); - DisplayArray( longs, "longs" ); - - // Copy two regions of source array to destination array, - // and two overlapped copies from source to source. - Console::WriteLine( "\n Array values after setting byte 3 = 25, \n" - " byte 6 = 64, byte 12 = 121, and byte 17 = 196:\n" ); - Buffer::SetByte( shorts, 3, 25 ); - Buffer::SetByte( shorts, 6, 64 ); - Buffer::SetByte( shorts, 12, 121 ); - Buffer::SetByte( shorts, 17, 196 ); - Buffer::SetByte( longs, 3, 25 ); - Buffer::SetByte( longs, 6, 64 ); - Buffer::SetByte( longs, 12, 121 ); - Buffer::SetByte( longs, 17, 196 ); - - // Display the arrays again. - DisplayArray( shorts, "shorts" ); - DisplayArray( longs, "longs" ); -} - -/* -This example of the Buffer::SetByte( Array*, int, unsigned char ) -method generates the following output. -Note: The arrays are displayed from right to left. - - Initial values of arrays: - - shorts: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 - longs: 0000000000000000 0000000000000000 0000000000000000 - - Array values after setting byte 3 = 25, - byte 6 = 64, byte 12 = 121, and byte 17 = 196: - - shorts: 0000 C400 0000 0079 0000 0000 0040 0000 1900 0000 - longs: 000000000000C400 0000007900000000 0040000019000000 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Byte Examples/CPP/systembyte.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Byte Examples/CPP/systembyte.cpp deleted file mode 100644 index 268d4585d1e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Byte Examples/CPP/systembyte.cpp +++ /dev/null @@ -1,106 +0,0 @@ -using namespace System; - -/// -/// Summary description for Class1. -/// -public ref class SystemByteExamples -{ -private: - Byte MemberByte; - -public: - // c'tor() - SystemByteExamples() - { - MemberByte = 0; - } - - // The following example demonstrates using the MinValue and MaxValue fields to - // determine whether an integer value falls within range of a byte. If it does, - // the value is set. If not, an error message is displayed. - - // MemberByte is assumed to exist as a class member - - // -public: - void MinMaxFields( Int32 numberToSet ) - { - if ( numberToSet <= (Int32)Byte::MaxValue && numberToSet >= (Int32)Byte::MinValue ) - { - - // You must explicitly convert an integer to a byte. - MemberByte = (Byte)numberToSet; - - // Displays MemberByte using the ToString() method. - Console::WriteLine( "The MemberByte value is {0}", MemberByte.ToString() ); - } - else - { - Console::WriteLine( "The value {0} is outside of the range of possible Byte values", numberToSet.ToString() ); - } - } - // - - // The following example converts the string representation of a byte - // into its actual numeric value. - - // MemberByte is assumed to exist as a class member - -public: - void ParseByte( String^ stringToConvert ) - { - try - { - MemberByte = Byte::Parse( stringToConvert ); - Console::WriteLine( "The MemberByte value is {0}", MemberByte.ToString() ); - } - catch ( System::OverflowException^ e ) - { - Console::WriteLine( "Exception: {0}", e->Message ); - } - } - - // The following example checks to see whether a byte passed in is - // greater than, less than, or equal to the member byte. - - // MemberByte is assumed to exist as a class member - - // -public: - void Compare( Byte myByte ) - { - Int32 myCompareResult; - - myCompareResult = MemberByte.CompareTo( myByte ); - - if ( myCompareResult > 0 ) - { - Console::WriteLine( "{0} is less than the MemberByte value {1}", myByte.ToString(), MemberByte.ToString() ); - } - else - { - if ( myCompareResult < 0 ) - Console::WriteLine( "{0} is greater than the MemberByte value {1}", myByte.ToString(), MemberByte.ToString() ); - else - Console::WriteLine( "{0} is equal to the MemberByte value {1}", myByte.ToString(), MemberByte.ToString() ); - } - } - // -}; - -void main() -{ - SystemByteExamples^ sbe = gcnew SystemByteExamples; - Int32 numberToSet; - Byte compareByte; - String^ stringToConvert; - - numberToSet = 120; - stringToConvert = "200"; - compareByte = 201; - - sbe->MinMaxFields( numberToSet ); - sbe->ParseByte( stringToConvert ); - - sbe->Compare( compareByte ); -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Byte.Parse/cpp/parse.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Byte.Parse/cpp/parse.cpp deleted file mode 100644 index b8e6646267a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Byte.Parse/cpp/parse.cpp +++ /dev/null @@ -1,162 +0,0 @@ -// Byte.Parse.cpp : main project file. - -using namespace System; -using namespace System::Globalization; - -// Byte.Parse(String) -void Parse1() -{ - // - String^ stringToConvert = " 162"; - Byte byteValue; - try - { - byteValue = Byte::Parse(stringToConvert); - Console::WriteLine("Converted '{0}' to {1}.", stringToConvert, byteValue); - } - catch (FormatException^) - { - Console::WriteLine("Unable to parse '{0}'.", stringToConvert); - } - catch (OverflowException^) - { - Console::WriteLine("'{0}' is greater than {1} or less than {2}.", - stringToConvert, Byte::MaxValue, Byte::MinValue); - } - // The example displays the following output to the console: - // Converted ' 162' to 162. - // -} - -// Byte.Parse(String, NumberStyles) -void Parse2a() -{ - // - String^ value; - NumberStyles style; - Byte number; - - // Parse value with no styles allowed. - style = NumberStyles::None; - value = " 241 "; - try - { - number = Byte::Parse(value, style); - Console::WriteLine("Converted '{0}' to {1}.", value, number); - } - catch (FormatException^) { - Console::WriteLine("Unable to parse '{0}'.", value); } - - // Parse value with trailing sign. - style = NumberStyles::Integer | NumberStyles::AllowTrailingSign; - value = " 163+"; - number = Byte::Parse(value, style); - Console::WriteLine("Converted '{0}' to {1}.", value, number); - - // Parse value with leading sign. - value = " +253 "; - number = Byte::Parse(value, style); - Console::WriteLine("Converted '{0}' to {1}.", value, number); - // This example displays the following output to the console: - // Unable to parse ' 241 '. - // Converted ' 163+' to 163. - // Converted ' +253 ' to 253. - // -} - -// Byte.Parse(String, IFormatProvider) -void Parse2b() -{ - // - String^ stringToConvert; - Byte byteValue; - - stringToConvert = " 214 "; - try { - byteValue = Byte::Parse(stringToConvert, CultureInfo::InvariantCulture); - Console::WriteLine("Converted '{0}' to {1}.", stringToConvert, byteValue); - } - catch (FormatException^) { - Console::WriteLine("Unable to parse '{0}'.", stringToConvert); } - catch (OverflowException^) { - Console::WriteLine("'{0}' is greater than {1} or less than {2}.", - stringToConvert, Byte::MaxValue, Byte::MinValue); } - - stringToConvert = " + 214 "; - try { - byteValue = Byte::Parse(stringToConvert, CultureInfo::InvariantCulture); - Console::WriteLine("Converted '{0}' to {1}.", stringToConvert, byteValue); - } - catch (FormatException^) { - Console::WriteLine("Unable to parse '{0}'.", stringToConvert); } - catch (OverflowException^) { - Console::WriteLine("'{0}' is greater than {1} or less than {2}.", - stringToConvert, Byte::MaxValue, Byte::MinValue); } - - stringToConvert = " +214 "; - try { - byteValue = Byte::Parse(stringToConvert, CultureInfo::InvariantCulture); - Console::WriteLine("Converted '{0}' to {1}.", stringToConvert, byteValue); - } - catch (FormatException^) { - Console::WriteLine("Unable to parse '{0}'.", stringToConvert); } - catch (OverflowException^) { - Console::WriteLine("'{0}' is greater than {1} or less than {2}.", - stringToConvert, Byte::MaxValue, Byte::MinValue); } - // The example displays the following output to the console: - // Converted ' 214 ' to 214. - // Unable to parse ' + 214 '. - // Converted ' +214 ' to 214. - // -} - -void Parse3() -{ - // - NumberStyles style; - CultureInfo^ culture; - String^ value; - Byte number; - - // Parse number with decimals. - // NumberStyles.Float includes NumberStyles.AllowDecimalPoint. - style = NumberStyles::Float; - culture = CultureInfo::CreateSpecificCulture("fr-FR"); - value = "12,000"; - - number = Byte::Parse(value, style, culture); - Console::WriteLine("Converted '{0}' to {1}.", value, number); - - culture = CultureInfo::CreateSpecificCulture("en-GB"); - try - { - number = Byte::Parse(value, style, culture); - Console::WriteLine("Converted '{0}' to {1}.", value, number); - } - catch (FormatException^) { - Console::WriteLine("Unable to parse '{0}'.", value); } - - value = "12.000"; - number = Byte::Parse(value, style, culture); - Console::WriteLine("Converted '{0}' to {1}.", value, number); - // The example displays the following output to the console: - // Converted '12,000' to 12. - // Unable to parse '12,000'. - // Converted '12.000' to 12. - // -}; - -void main() -{ - Parse1(); // Parse(String) - Console::WriteLine(); - Parse2a(); // Parse(String, NumberStyles) - Console::WriteLine(); - Parse2b(); - Console::WriteLine(); - Parse3(); // Parse(String, NumberStyles, IFormatProvider) - Console::WriteLine(); - - Console::ReadLine(); -} - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Byte.ToString/CPP/newbytemembers.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Byte.ToString/CPP/newbytemembers.cpp deleted file mode 100644 index fbad6b4f72e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Byte.ToString/CPP/newbytemembers.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// Byte.ToString.cpp : main project file. - -using namespace System; -using namespace System::Globalization; - -void main() -{ - // - array^ bytes = gcnew array {0, 1, 14, 168, 255}; - array^ providers = {gcnew CultureInfo("en-us"), - gcnew CultureInfo("fr-fr"), - gcnew CultureInfo("de-de"), - gcnew CultureInfo("es-es")}; - for each (Byte byteValue in bytes) - { - for each (CultureInfo^ provider in providers) - Console::Write("{0,3} ({1}) ", - byteValue.ToString(provider), provider->Name); - - Console::WriteLine(); - } - // The example displays the following output to the console: - // 0 (en-US) 0 (fr-FR) 0 (de-DE) 0 (es-ES) - // 1 (en-US) 1 (fr-FR) 1 (de-DE) 1 (es-ES) - // 14 (en-US) 14 (fr-FR) 14 (de-DE) 14 (es-ES) - // 168 (en-US) 168 (fr-FR) 168 (de-DE) 168 (es-ES) - // 255 (en-US) 255 (fr-FR) 255 (de-DE) 255 (es-ES) - // -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Byte.ToString/CPP/newbytemembers2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Byte.ToString/CPP/newbytemembers2.cpp deleted file mode 100644 index 76bc3225475..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Byte.ToString/CPP/newbytemembers2.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// Byte.ToString2.cpp : main project file. - -using namespace System; -using namespace System::Globalization; - -// Byte.ToString() -void Byte1() -{ - // - array^ bytes = gcnew array {0, 1, 14, 168, 255}; - for each (Byte byteValue in bytes) - Console::WriteLine(byteValue); - // The example displays the following output to the console if the current - // culture is en-US: - // 0 - // 1 - // 14 - // 168 - // 255 - // -} - -// Byte.ToString(String) -void Byte2() -{ - // - array^ formats = gcnew array {"C3", "D4", "e1", "E2", "F1", "G", "N1", - "P0", "X4", "0000.0000"}; - Byte number = 240; - for each (String^ format in formats) - Console::WriteLine("'{0}' format specifier: {1}", - format, number.ToString(format)); - - // The example displays the following output to the console if the - // current culture is en-us: - // 'C3' format specifier: $240.000 - // 'D4' format specifier: 0240 - // 'e1' format specifier: 2.4e+002 - // 'E2' format specifier: 2.40E+002 - // 'F1' format specifier: 240.0 - // 'G' format specifier: 240 - // 'N1' format specifier: 240.0 - // 'P0' format specifier: 24,000 % - // 'X4' format specifier: 00F0 - // '0000.0000' format specifier: 0240.0000 - // -} - -// ToString(String, IFormatProvider) -void Byte3() -{ - // - Byte byteValue = 250; - array^ providers = gcnew array { gcnew CultureInfo("en-us"), - gcnew CultureInfo("fr-fr"), - gcnew CultureInfo("es-es"), - gcnew CultureInfo("de-de")}; - - for each (CultureInfo^ provider in providers) - Console::WriteLine("{0} ({1})", - byteValue.ToString("N2", provider), provider->Name); - // The example displays the following output to the console: - // 250.00 (en-US) - // 250,00 (fr-FR) - // 250,00 (es-ES) - // 250,00 (de-DE) - // -} - -void main() -{ - Byte1(); - Console::WriteLine(); - Byte2(); - Console::WriteLine(); - Byte3(); - Console::WriteLine(); - Console::ReadLine(); -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Byte.TryParse/cpp/tryparse.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Byte.TryParse/cpp/tryparse.cpp deleted file mode 100644 index ad5537892ae..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Byte.TryParse/cpp/tryparse.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// Byte.TryParse.cpp : main project file. -// Byte.TryParse(String, Byte) - -// -using namespace System; - -void main() -{ - array^ byteStrings = gcnew array { nullptr, String::Empty, - "1024", "100.1", "100", - "+100", "-100", "000000000000000100", - "00,100", " 20 ", "FF", "0x1F" }; - Byte byteValue; - for each (String^ byteString in byteStrings) { - bool result = Byte::TryParse(byteString, byteValue); - if (result) - Console::WriteLine("Converted '{0}' to {1}", - byteString, byteValue); - else - Console::WriteLine("Attempted conversion of '{0}' failed.", - byteString); - } -} -// The example displays the following output: -// Attempted conversion of '' failed. -// Attempted conversion of '' failed.` -// Attempted conversion of '1024' failed. -// Attempted conversion of '100.1' failed. -// Converted '100' to 100 -// Converted '+100' to 100 -// Attempted conversion of '-100' failed. -// Converted '000000000000000100' to 100 -// Attempted conversion of '00,100' failed. -// Converted ' 20 ' to 20 -// Attempted conversion of 'FF' failed. -// Attempted conversion of '0x1F' failed.} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Byte.TryParse/cpp/tryparse2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Byte.TryParse/cpp/tryparse2.cpp deleted file mode 100644 index e3e81cd2951..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Byte.TryParse/cpp/tryparse2.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// Byte.TryParse2.cpp : main project file. - -// -using namespace System; -using namespace System::Globalization; - -void CallTryParse(String^ byteString, NumberStyles styles); - -void main() -{ - String^ byteString; - NumberStyles styles; - - byteString = "1024"; - styles = NumberStyles::Integer; - CallTryParse(byteString, styles); - - byteString = "100.1"; - styles = NumberStyles::Integer | NumberStyles::AllowDecimalPoint; - CallTryParse(byteString, styles); - - byteString = "100.0"; - CallTryParse(byteString, styles); - - byteString = "+100"; - styles = NumberStyles::Integer | NumberStyles::AllowLeadingSign - | NumberStyles::AllowTrailingSign; - CallTryParse(byteString, styles); - - byteString = "-100"; - CallTryParse(byteString, styles); - - byteString = "000000000000000100"; - CallTryParse(byteString, styles); - - byteString = "00,100"; - styles = NumberStyles::Integer | NumberStyles::AllowThousands; - CallTryParse(byteString, styles); - - byteString = "2E+3 "; - styles = NumberStyles::Integer | NumberStyles::AllowExponent; - CallTryParse(byteString, styles); - - byteString = "FF"; - styles = NumberStyles::HexNumber; - CallTryParse(byteString, styles); - - byteString = "0x1F"; - CallTryParse(byteString, styles); -} - -void CallTryParse(String^ stringToConvert, NumberStyles styles) -{ - Byte byteValue; - bool result = Byte::TryParse(stringToConvert, styles, - (IFormatProvider^) nullptr , byteValue); - if (result) - Console::WriteLine("Converted '{0}' to {1}", - stringToConvert, byteValue); - else - Console::WriteLine("Attempted conversion of '{0}' failed.", - stringToConvert); -} -// The example displays the following output: -// Attempted conversion of '1024' failed. -// Attempted conversion of '100.1' failed. -// Converted '100.0' to 100 -// Converted '+100' to 100 -// Attempted conversion of '-100' failed. -// Converted '000000000000000100' to 100 -// Converted '00,100' to 100 -// Attempted conversion of '2E+3 ' failed. -// Converted 'FF' to 255 -// Attempted conversion of '0x1F' failed.} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Char [Type Level]/CPP/charstructure.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Char [Type Level]/CPP/charstructure.cpp deleted file mode 100644 index b4230f4b6c0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Char [Type Level]/CPP/charstructure.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -int main() -{ - char chA = 'A'; - char ch1 = '1'; - String^ str = "test string"; - Console::WriteLine( chA.CompareTo( 'B' ) ); // Output: "-1" (meaning 'A' is 1 less than 'B') - Console::WriteLine( chA.Equals( 'A' ) ); // Output: "True" - Console::WriteLine( Char::GetNumericValue( ch1 ) ); // Output: "1" - Console::WriteLine( Char::IsControl( '\t' ) ); // Output: "True" - Console::WriteLine( Char::IsDigit( ch1 ) ); // Output: "True" - Console::WriteLine( Char::IsLetter( ',' ) ); // Output: "False" - Console::WriteLine( Char::IsLower( 'u' ) ); // Output: "True" - Console::WriteLine( Char::IsNumber( ch1 ) ); // Output: "True" - Console::WriteLine( Char::IsPunctuation( '.' ) ); // Output: "True" - Console::WriteLine( Char::IsSeparator( str, 4 ) ); // Output: "True" - Console::WriteLine( Char::IsSymbol( '+' ) ); // Output: "True" - Console::WriteLine( Char::IsWhiteSpace( str, 4 ) ); // Output: "True" - Console::WriteLine( Char::Parse( "S" ) ); // Output: "S" - Console::WriteLine( Char::ToLower( 'M' ) ); // Output: "m" - Console::WriteLine( 'x' ); // Output: "x" -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Char.CompareTo/CPP/compareto.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Char.CompareTo/CPP/compareto.cpp deleted file mode 100644 index 317328712b3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Char.CompareTo/CPP/compareto.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -int main() -{ - char chA = 'A'; - char chB = 'B'; - Console::WriteLine( chA.CompareTo( 'A' ) ); // Output: "0" (meaning they're equal) - Console::WriteLine( 'b'.CompareTo( chB ) ); // Output: "32" (meaning 'b' is greater than 'B' by 32) - Console::WriteLine( chA.CompareTo( chB ) ); // Output: "-1" (meaning 'A' is less than 'B' by 1) -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Char.Equals/CPP/equals.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Char.Equals/CPP/equals.cpp deleted file mode 100644 index 216b8181b48..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Char.Equals/CPP/equals.cpp +++ /dev/null @@ -1,12 +0,0 @@ - -// -using namespace System; -int main() -{ - char chA = 'A'; - char chB = 'B'; - Console::WriteLine( chA.Equals( 'A' ) ); // Output: "True" - Console::WriteLine( 'b'.Equals( chB ) ); // Output: "False" -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Char.GetNumericValue/CPP/getnumericvalue.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Char.GetNumericValue/CPP/getnumericvalue.cpp deleted file mode 100644 index ea6ef6ca1a3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Char.GetNumericValue/CPP/getnumericvalue.cpp +++ /dev/null @@ -1,11 +0,0 @@ - -// -using namespace System; -int main() -{ - String^ str = "input: 1"; - Console::WriteLine( Char::GetNumericValue( '8' ) ); // Output: "8" - Console::WriteLine( Char::GetNumericValue( str, 7 ) ); // Output: "1" -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Char.GetUnicodeCategory/CPP/getunicodecategory.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Char.GetUnicodeCategory/CPP/getunicodecategory.cpp deleted file mode 100644 index 6056fad6c22..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Char.GetUnicodeCategory/CPP/getunicodecategory.cpp +++ /dev/null @@ -1,13 +0,0 @@ - -// -using namespace System; -int main() -{ - char ch2 = '2'; - String^ str = "Upper Case"; - Console::WriteLine( Char::GetUnicodeCategory( 'a' ).ToString() ); // Output: S"LowercaseLetter" - Console::WriteLine( Char::GetUnicodeCategory( ch2 ).ToString() ); // Output: S"DecimalDigitNumber" - Console::WriteLine( Char::GetUnicodeCategory( str, 6 ).ToString() ); // Output: S"UppercaseLetter" -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsControl/CPP/iscontrol1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsControl/CPP/iscontrol1.cpp deleted file mode 100644 index 9f742e155e1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsControl/CPP/iscontrol1.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// Char.IsControl1.cpp : main project file. -// Char.IsControl(Char) - -// -using namespace System; - -void main() -{ - int charsWritten = 0; - - for (int ctr = 0x00; ctr <= 0xFFFF; ctr++) - { - wchar_t ch = ctr; - if (Char::IsControl(ch)) - { - Console::Write(L"\U{0:X4} ", ctr); - charsWritten++; - if (charsWritten % 6 == 0) - Console::WriteLine(); - } - } -} -// The example displays the following output: -// U0000 U0001 U0002 U0003 U0004 U0005 -// U0006 U0007 U0008 U0009 U000A U000B -// U000C U000D U000E U000F U0010 U0011 -// U0012 U0013 U0014 U0015 U0016 U0017 -// U0018 U0019 U001A U001B U001C U001D -// U001E U001F U007F U0080 U0081 U0082 -// U0083 U0084 U0085 U0086 U0087 U0088 -// U0089 U008A U008B U008C U008D U008E -// U008F U0090 U0091 U0092 U0093 U0094 -// U0095 U0096 U0097 U0098 U0099 U009A -// U009B U009C U009D U009E U009F -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsControl/CPP/iscontrol2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsControl/CPP/iscontrol2.cpp deleted file mode 100644 index 0fa25aafc01..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsControl/CPP/iscontrol2.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Char.IsControl2.cpp : main project file. - -// Char.IsControl(String, Int32) - -// -using namespace System; - -void main() -{ - String ^ sentence = "This is a " + Environment::NewLine + "two-line sentence."; - for (int ctr = 0; ctr < sentence->Length; ctr++) - { - if (Char::IsControl(sentence, ctr)) - Console::WriteLine("Control character \\U{0} found in position {1}.", - Convert::ToInt32(sentence[ctr]).ToString("X4"), ctr); - } -} -// The example displays the following output: -// Control character \U000D found in position 10. -// Control character \U000A found in position 11. -// - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsDigit/CPP/isdigit.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsDigit/CPP/isdigit.cpp deleted file mode 100644 index 9de55fe04c1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsDigit/CPP/isdigit.cpp +++ /dev/null @@ -1,11 +0,0 @@ - -// -using namespace System; -int main() -{ - char ch = '8'; - Console::WriteLine( Char::IsDigit( ch ) ); // Output: "True" - Console::WriteLine( Char::IsDigit( "sample string", 7 ) ); // Output: "False" -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsLetter/CPP/isletter.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsLetter/CPP/isletter.cpp deleted file mode 100644 index ca86988a709..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsLetter/CPP/isletter.cpp +++ /dev/null @@ -1,11 +0,0 @@ - -// -using namespace System; -int main() -{ - char ch = '8'; - Console::WriteLine( Char::IsLetter( ch ) ); // False - Console::WriteLine( Char::IsLetter( "sample string", 7 ) ); // True -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsLetterOrDigit/CPP/isletterordigit.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsLetterOrDigit/CPP/isletterordigit.cpp deleted file mode 100644 index 4ffec1eb61f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsLetterOrDigit/CPP/isletterordigit.cpp +++ /dev/null @@ -1,11 +0,0 @@ - -// -using namespace System; -int main() -{ - String^ str = "newline:\n"; - Console::WriteLine( Char::IsLetterOrDigit( '8' ) ); // Output: "True" - Console::WriteLine( Char::IsLetterOrDigit( str, 8 ) ); // Output: "False", because it's a newline -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsLower/CPP/islower.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsLower/CPP/islower.cpp deleted file mode 100644 index ea6466897e4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsLower/CPP/islower.cpp +++ /dev/null @@ -1,11 +0,0 @@ - -// -using namespace System; -int main() -{ - char ch = 'a'; - Console::WriteLine( Char::IsLower( ch ) ); // Output: "True" - Console::WriteLine( Char::IsLower( "upperCase", 5 ) ); // Output: "False" -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsNumber/CPP/isnumber.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsNumber/CPP/isnumber.cpp deleted file mode 100644 index e462ab9c8b3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsNumber/CPP/isnumber.cpp +++ /dev/null @@ -1,11 +0,0 @@ - -// -using namespace System; -int main() -{ - String^ str = "non-numeric"; - Console::WriteLine( Char::IsNumber( '8' ) ); // Output: "True" - Console::WriteLine( Char::IsNumber( str, 3 ) ); // Output: "False" -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsPunctuation/CPP/ispunctuation.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsPunctuation/CPP/ispunctuation.cpp deleted file mode 100644 index 21b3c010264..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsPunctuation/CPP/ispunctuation.cpp +++ /dev/null @@ -1,11 +0,0 @@ - -// -using namespace System; -int main() -{ - char ch = '.'; - Console::WriteLine( Char::IsPunctuation( ch ) ); // Output: "True" - Console::WriteLine( Char::IsPunctuation( "no punctuation", 3 ) ); // Output: "False" -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsSeparator/CPP/isseparator.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsSeparator/CPP/isseparator.cpp deleted file mode 100644 index 51132b2f14c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsSeparator/CPP/isseparator.cpp +++ /dev/null @@ -1,11 +0,0 @@ - -// -using namespace System; -int main() -{ - String^ str = "twain1 twain2"; - Console::WriteLine( Char::IsSeparator( 'a' ) ); // Output: "False" - Console::WriteLine( Char::IsSeparator( str, 6 ) ); // Output: "True" -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsSeparator/CPP/isseparator1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsSeparator/CPP/isseparator1.cpp deleted file mode 100644 index ddec2d22729..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsSeparator/CPP/isseparator1.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// Char.IsSeparator.cpp : main project file. - -// -using namespace System; - -int main() -{ - for (int ctr = Convert::ToInt32(Char::MinValue); ctr <= Convert::ToInt32(Char::MaxValue); ctr++) - { - wchar_t ch = ctr; - if (Char::IsSeparator(ch)) - Console::WriteLine("\u{0:X4} ({1})", (int) ch, Char::GetUnicodeCategory(ch).ToString()); - } -} -// The example displays the following output: -// 0020 (SpaceSeparator) -// u00A0 (SpaceSeparator) -// u1680 (SpaceSeparator) -// u180E (SpaceSeparator) -// u2000 (SpaceSeparator) -// u2001 (SpaceSeparator) -// u2002 (SpaceSeparator) -// u2003 (SpaceSeparator) -// u2004 (SpaceSeparator) -// u2005 (SpaceSeparator) -// u2006 (SpaceSeparator) -// u2007 (SpaceSeparator) -// u2008 (SpaceSeparator) -// u2009 (SpaceSeparator) -// u200A (SpaceSeparator) -// u2028 (LineSeparator) -// u2029 (ParagraphSeparator) -// u202F (SpaceSeparator) -// u205F (SpaceSeparator) -// u3000 (SpaceSeparator) -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsSurrogate/CPP/issurrogate.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsSurrogate/CPP/issurrogate.cpp deleted file mode 100644 index d82d071c7a3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsSurrogate/CPP/issurrogate.cpp +++ /dev/null @@ -1,11 +0,0 @@ - -// -using namespace System; -int main() -{ - - // - escape params specifying Unicode not implemented in v7.0 - Console::WriteLine( Char::IsSurrogate( 'a' ) ); // Output: "False" -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsSymbol/CPP/issymbol.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsSymbol/CPP/issymbol.cpp deleted file mode 100644 index 27bcc3f6fc2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsSymbol/CPP/issymbol.cpp +++ /dev/null @@ -1,11 +0,0 @@ - -// -using namespace System; -int main() -{ - String^ str = "non-symbolic characters"; - Console::WriteLine( Char::IsSymbol( '+' ) ); // Output: "True" - Console::WriteLine( Char::IsSymbol( str, 8 ) ); // Output: "False" -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsWhiteSpace/CPP/iswhitespace.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsWhiteSpace/CPP/iswhitespace.cpp deleted file mode 100644 index f4062420996..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsWhiteSpace/CPP/iswhitespace.cpp +++ /dev/null @@ -1,11 +0,0 @@ - -// -using namespace System; -int main() -{ - String^ str = "black matter"; - Console::WriteLine( Char::IsWhiteSpace( 'A' ) ); // Output: "False" - Console::WriteLine( Char::IsWhiteSpace( str, 5 ) ); // Output: "True" -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Char.Parse/CPP/parse.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Char.Parse/CPP/parse.cpp deleted file mode 100644 index bb4eecacea5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Char.Parse/CPP/parse.cpp +++ /dev/null @@ -1,9 +0,0 @@ - -// -using namespace System; -int main() -{ - Console::WriteLine( Char::Parse( "A" ) ); // Output: 'A' -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Char.ToLower/CPP/tolower.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Char.ToLower/CPP/tolower.cpp deleted file mode 100644 index 6d94d6be514..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Char.ToLower/CPP/tolower.cpp +++ /dev/null @@ -1,12 +0,0 @@ - -// -using namespace System; -using namespace System::Globalization; - -// for CultureInfo -void main() -{ - Console::WriteLine( Char::ToLower( 'A' ) ); // Output: "a" -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Char.ToString/CPP/tostring.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Char.ToString/CPP/tostring.cpp deleted file mode 100644 index 7c9937fa77e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Char.ToString/CPP/tostring.cpp +++ /dev/null @@ -1,11 +0,0 @@ - -// -using namespace System; -int main() -{ - char ch = 'a'; - Console::WriteLine( ch ); // Output: "a" - Console::WriteLine( Char::ToString( 'b' ) ); // Output: "b" -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.CharEnumerator.Class/cpp/charenumerator1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.CharEnumerator.Class/cpp/charenumerator1.cpp deleted file mode 100644 index 6dd27c48dfe..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.CharEnumerator.Class/cpp/charenumerator1.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// CharEnumerator.Current.cpp : main project file. - - -using namespace System; - -void Example1() -{ - // - String ^ title = "A Tale of Two Cities"; - CharEnumerator ^ chEnum = title->GetEnumerator(); - int ctr = 1; - String ^ outputLine1 = nullptr; - String ^ outputLine2 = nullptr; - String ^ outputLine3 = nullptr; - - while (chEnum->MoveNext()) - { - outputLine1 += ctr < 10 || ctr % 10 != 0 ? " " : (ctr / 10) + " "; - outputLine2 += (ctr % 10) + " "; - outputLine3 += chEnum->Current + " "; - ctr++; - } - - Console::WriteLine("The length of the string is {0} characters:", - title->Length); - Console::WriteLine(outputLine1); - Console::WriteLine(outputLine2); - Console::WriteLine(outputLine3); - // The example displays the following output to the console: - // The length of the string is 20 characters: - // 1 2 - // 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 - // A T a l e o f T w o C i t i e s - // - Console::ReadLine(); -} - -void Example2() -{ - // - String ^ title = "A Tale of Two Cities"; - int ctr = 1; - String ^ outputLine1 = nullptr; - String ^ outputLine2 = nullptr; - String ^ outputLine3 = nullptr; - - for each (wchar_t ch in title) - { - outputLine1 += ctr < 10 || ctr % 10 != 0 ? " " : (ctr / 10) + " "; - outputLine2 += (ctr % 10) + " "; - outputLine3 += ch + " "; - ctr++; - } - - Console::WriteLine("The length of the string is {0} characters:", - title->Length); - Console::WriteLine(outputLine1); - Console::WriteLine(outputLine2); - Console::WriteLine(outputLine3); - // The example displays the following output to the console: - // The length of the string is 20 characters: - // 1 2 - // 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 - // A T a l e o f T w o C i t i e s - // - Console::ReadLine(); -} - -void main() -{ - Example1(); - Console::WriteLine(); - Example2(); -} - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Console-INSERTTABS/CPP/inserttabs.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Console-INSERTTABS/CPP/inserttabs.cpp deleted file mode 100644 index d9dc7f158c6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Console-INSERTTABS/CPP/inserttabs.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// This sample opens a file whose name is passed to it as a parameter. -// It reads each line in the file and replaces every occurrence of 4 -// space characters with a tab character. -// -// It takes two command-line arguments: the input file name, and -// the output file name. -// -// Usage: -// -// INSERTTABS inputfile.txt outputfile.txt -// -// -using namespace System; -using namespace System::IO; - -int main() -{ - array^args = Environment::GetCommandLineArgs(); - const int tabSize = 4; - String^ usageText = "Usage: INSERTTABS inputfile.txt outputfile.txt"; - StreamWriter^ writer = nullptr; - if ( args->Length < 3 ) - { - Console::WriteLine( usageText ); - return 1; - } - - try - { - // Attempt to open output file. - writer = gcnew StreamWriter( args[ 2 ] ); - // Redirect standard output from the console to the output file. - Console::SetOut( writer ); - // Redirect standard input from the console to the input file. - Console::SetIn( gcnew StreamReader( args[ 1 ] ) ); - } - catch ( IOException^ e ) - { - TextWriter^ errorWriter = Console::Error; - errorWriter->WriteLine( e->Message ); - errorWriter->WriteLine( usageText ); - return 1; - } - - String^ line; - while ( (line = Console::ReadLine()) != nullptr ) - { - String^ newLine = line->Replace( ((String^)"")->PadRight( tabSize, ' ' ), "\t" ); - Console::WriteLine( newLine ); - } - - writer->Close(); - - // Recover the standard output stream so that a - // completion message can be displayed. - StreamWriter^ standardOutput = gcnew StreamWriter( Console::OpenStandardOutput() ); - standardOutput->AutoFlush = true; - Console::SetOut( standardOutput ); - Console::WriteLine( "INSERTTABS has completed the processing of {0}.", args[ 1 ] ); - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp deleted file mode 100644 index 05916a9e0cd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp +++ /dev/null @@ -1,72 +0,0 @@ - -using namespace System; - -// This sample converts tab-delmited input and converts it to -// comma-delimited output. Furthermore, it converts all boolean -// input to numeric representations. -// System.Console.Write -// System.Console.WriteLine -// System.Console.ReadLine -// -int main() -{ - array^lineInputArr = {"1 2.2 hello TRUE","2 5.22 bye FALSE","3 6.38 see ya' TRUE"}; - for ( Int32 i = 0; i < 3; i++ ) - { - String^ lineInput = lineInputArr->GetValue( i )->ToString(); - String^ aChar = "\t"; - array^fields = lineInput->Split( aChar->ToCharArray() ); - Boolean isFirstField = true; - for ( Int32 i = 0; i < fields->Length; i++ ) - { - if ( isFirstField ) - isFirstField = false; - else - Console::Write( "," ); - - // If the field represents a boolean, replace with a numeric representation. - try - { - Console::Write( Convert::ToByte( Convert::ToBoolean( fields[ i ] ) ) ); - } - catch ( FormatException^ ) - { - Console::Write( fields[ i ] ); - } - - - } - Console::WriteLine(); - - } -} - -// -/* -usage examples: -To convert tab-delimited input from the keyboard and display -the output (type CTRL+Z to mark the end of input): - REFORMAT - -To input tab-delimited data from a file and display the output: - REFORMAT commas.txt - -To convert tab-delimited data from a file and output the conversion -to a file: - REFORMAT commas.txt - -Example input: -1 2.2 hello TRUE -2 5.22 bye FALSE -3 6.38 see ya' TRUE - -Example output: -1,2.2,hello,1 -2,5.22,bye,0 -3,6.38,see ya',1 - -*/ diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Console.OpenStandartInput/CPP/decode.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Console.OpenStandartInput/CPP/decode.cpp deleted file mode 100644 index 28ce20635b1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Console.OpenStandartInput/CPP/decode.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// System.Console.OpenStandartInput -// - -using namespace System; -using namespace System::Text; -using namespace System::IO; - -int main() -{ - Stream^ inputStream = Console::OpenStandardInput(); - array^bytes = gcnew array(100); - Console::WriteLine( "To decode, type or paste the UTF7 encoded string and press enter:" ); - Console::WriteLine( "(Example: \"M+APw-nchen ist wundervoll\")" ); - int outputLength = inputStream->Read( bytes, 0, 100 ); - array^chars = Encoding::UTF7->GetChars( bytes, 0, outputLength ); - Console::WriteLine( "Decoded string:" ); - Console::WriteLine( gcnew String( chars ) ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Console.ReadLine/cpp/ReadLineSimple.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Console.ReadLine/cpp/ReadLineSimple.cpp deleted file mode 100644 index 46250e779de..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Console.ReadLine/cpp/ReadLineSimple.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// -using namespace System; - -void main() -{ - Console::Clear(); - - DateTime dat = DateTime::Now; - - Console::WriteLine("\nToday is {0:d} at {0:T}.", dat); - Console::Write("\nPress any key to continue... "); - Console::ReadLine(); -} -// The example displays output like the following: -// Today is 10/26/2015 at 12:22:22 PM. -// -// Press any key to continue... - -// - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Console.ReadLine/cpp/readline2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Console.ReadLine/cpp/readline2.cpp deleted file mode 100644 index 33019ead3ed..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Console.ReadLine/cpp/readline2.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// Console.ReadLine.cpp : main project file. - -// -using namespace System; - -void main() -{ - String^ line; - Console::WriteLine("Enter one or more lines of text (press CTRL+Z to exit):"); - Console::WriteLine(); - do { - Console::Write(" "); - line = Console::ReadLine(); - if (line != nullptr) - Console::WriteLine(" " + line); - } while (line != nullptr); -} -// The following displays possible output from this example: -// Enter one or more lines of text (press CTRL+Z to exit): -// -// This is line #1. -// This is line #1. -// This is line #2 -// This is line #2 -// ^Z -// -// >} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Console.SetError/cpp/seterror1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Console.SetError/cpp/seterror1.cpp deleted file mode 100644 index 11038946fd4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Console.SetError/cpp/seterror1.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// Console.SetError.cpp : main project file. - -// -using namespace System; -using namespace System::IO; -using namespace System::Reflection; - -ref class RedirectStdErr; - -void main() -{ - // Define file to receive error stream. - DateTime appStart = DateTime::Now; - String^ fn = "c:\\temp\\errlog" + appStart.ToString("yyyyMMddHHmm") + ".log"; - TextWriter^ errStream = gcnew StreamWriter(fn); - String^ appName = Assembly::GetExecutingAssembly()->Location; - appName = appName->Substring(appName->LastIndexOf('\\') + 1); - // Redirect standard error stream to file. - Console::SetError(errStream); - // Write file header. - Console::Error->WriteLine("Error Log for Application {0}", appName); - Console::Error->WriteLine(); - Console::Error->WriteLine("Application started at {0}.", appStart); - Console::Error->WriteLine(); - // - // Application code along with error output - // - // Close redirected error stream. - Console::Error->Close(); -} -// - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Console.WriteLine/CPP/newline1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Console.WriteLine/CPP/newline1.cpp deleted file mode 100644 index a6753c8b965..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Console.WriteLine/CPP/newline1.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// Console.WriteLine.cpp : main project file. - -// -using namespace System; - -void main() -{ - array^ lines = gcnew array { "This is the first line.", - "This is the second line." }; - // Output the lines using the default newline sequence. - Console::WriteLine("With the default new line characters:"); - Console::WriteLine(); - for each (String^ line in lines) - Console::WriteLine(line); - - Console::WriteLine(); - - // Redefine the newline characters to double space. - Console::Out->NewLine = "\r\n\r\n"; - // Output the lines using the new newline sequence. - Console::WriteLine("With redefined new line characters:"); - Console::WriteLine(); - for each (String^ line in lines) - Console::WriteLine(line); -} -// The example displays the following output: -// With the default new line characters: -// -// This is the first line. -// This is the second line. -// -// With redefined new line characters: -// -// -// -// This is the first line. -// -// This is the second line. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Console.WriteLine/CPP/writeline_boolean1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Console.WriteLine/CPP/writeline_boolean1.cpp deleted file mode 100644 index 0a1a1d1bd9d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Console.WriteLine/CPP/writeline_boolean1.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Console.WriteLine1.cpp : main project file. - -// -using namespace System; - -void main() -{ - // Assign 10 random integers to an array. - Random^ rnd = gcnew Random(); - array^ numbers = gcnew array(10); - for (int ctr = 0; ctr <= numbers->GetUpperBound(0); ctr++) - numbers[ctr] = rnd->Next(); - - // Determine whether the numbers are even or odd. - for each (Int32 number in numbers) { - bool even = (number % 2 == 0); - Console::WriteLine("Is {0} even:", number); - Console::WriteLine(even); - Console::WriteLine(); - } -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Console.WriteLine/CPP/writeline_obj1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Console.WriteLine/CPP/writeline_obj1.cpp deleted file mode 100644 index 821a9d93340..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Console.WriteLine/CPP/writeline_obj1.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// -using namespace System; - -void main() -{ - array^ values = { true, 12.632, 17908, "stringValue", - 'a', (Decimal) 16907.32 }; - for each (Object^ value in values) - Console::WriteLine(value); -} -// The example displays the following output: -// True -// 12.632 -// 17908 -// stringValue -// a -// 16907.32 -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.ConsoleKey/cpp/consolekey.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.ConsoleKey/cpp/consolekey.cpp deleted file mode 100644 index 0e3d6bf7e2a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.ConsoleKey/cpp/consolekey.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// ConsoleKey.cpp : main project file. - - -// -using namespace System; -using namespace System::Text; - -void main() -{ - ConsoleKeyInfo input; - do { - Console::WriteLine("Press a key, together with Alt, Ctrl, or Shift."); - Console::WriteLine("Press Esc to exit."); - input = Console::ReadKey(true); - - StringBuilder^ output = gcnew StringBuilder( - String::Format("You pressed {0}", input.Key.ToString())); - bool modifiers = false; - - if ((input.Modifiers & ConsoleModifiers::Alt) == ConsoleModifiers::Alt) { - output->Append(", together with " + ConsoleModifiers::Alt.ToString()); - modifiers = true; - } - if ((input.Modifiers & ConsoleModifiers::Control) == ConsoleModifiers::Control) - { - if (modifiers) { - output->Append(" and "); - } - else { - output->Append(", together with "); - modifiers = true; - } - output->Append(ConsoleModifiers::Control.ToString()); - } - if ((input.Modifiers & ConsoleModifiers::Shift) == ConsoleModifiers::Shift) - { - if (modifiers) { - output->Append(" and "); - } - else { - output->Append(", together with "); - modifiers = true; - } - output->Append(ConsoleModifiers::Shift.ToString()); - } - output->Append("."); - Console::WriteLine(output->ToString()); - Console::WriteLine(); - } while (input.Key != ConsoleKey::Escape); -} -// The output from a sample console session might appear as follows: -// Press a key, along with Alt, Ctrl, or Shift. -// Press Esc to exit. -// You pressed D. -// -// Press a key, along with Alt, Ctrl, or Shift. -// Press Esc to exit. -// You pressed X, along with Shift. -// -// Press a key, along with Alt, Ctrl, or Shift. -// Press Esc to exit. -// You pressed L, along with Control and Shift. -// -// Press a key, along with Alt, Ctrl, or Shift. -// Press Esc to exit. -// You pressed P, along with Alt and Control and Shift. -// -// Press a key, along with Alt, Ctrl, or Shift. -// Press Esc to exit. -// You pressed Escape. -// - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.Equals/cpp/consolekeyinfo.equals.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.Equals/cpp/consolekeyinfo.equals.cpp deleted file mode 100644 index 1aea3c7af8b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.Equals/cpp/consolekeyinfo.equals.cpp +++ /dev/null @@ -1,101 +0,0 @@ -// ConsoleKeyInfo.Equals.cpp : main project file. - -// ConsoleKeyInfo.Equals(Object) - -// -using namespace System; -using namespace System::Text; - -static String^ KeyCombination(ConsoleKeyInfo sourceCki); - -void main() -{ - String^ k1 = "\nEnter a key ......... "; - String^ k2 = "\nEnter another key ... "; - String^ key1 = ""; - String^ key2 = ""; - String^ areKeysEqual = "The {0} and {1} keys are {2}equal."; - String^ equalValue = ""; - String^ prompt = "Press the escape key (ESC) to quit, " + - "or any other key to continue."; - ConsoleKeyInfo cki1; - ConsoleKeyInfo cki2; - // - // The Console.TreatControlCAsInput property prevents this example from - // ending if you press CTL+C, however all other operating system keys and - // shortcuts, such as ALT+TAB or the Windows Logo key, are still in effect. - // - Console::TreatControlCAsInput = true; - - // Request that the user enter two key presses. A key press and any - // combination shift, CTRL, and ALT modifier keys is permitted. - do - { - Console::Write(k1); - cki1 = Console::ReadKey(false); - Console::Write(k2); - cki2 = Console::ReadKey(false); - Console::WriteLine(); - - key1 = KeyCombination(cki1); - key2 = KeyCombination(cki2); - if (cki1.Equals(cki2)) - equalValue = ""; - else - equalValue = "not "; - - Console::WriteLine(areKeysEqual, key1, key2, equalValue); - - Console::WriteLine(prompt); - cki1 = Console::ReadKey(true); - } while (cki1.Key != ConsoleKey::Escape); -// Note: This example requires the Escape (Esc) key. -} - -// The KeyCombination() method creates a string that specifies what -// key and what combination of shift, CTRL, and ALT modifier keys -// were pressed simultaneously. - -static String^ KeyCombination(ConsoleKeyInfo sourceCki) -{ - StringBuilder^ sb = gcnew StringBuilder(); - sb->Length = 0; - String^ keyCombo; - if (sourceCki.Modifiers != ConsoleModifiers()) - { - if ((sourceCki.Modifiers & ConsoleModifiers::Alt) != ConsoleModifiers()) - sb->Append("ALT+"); - if ((sourceCki.Modifiers & ConsoleModifiers::Shift) != ConsoleModifiers()) - sb->Append("SHIFT+"); - if ((sourceCki.Modifiers & ConsoleModifiers::Control) != ConsoleModifiers()) - sb->Append("CTL+"); - } - sb->Append(sourceCki.Key.ToString()); - keyCombo = sb->ToString(); - return keyCombo; -} -/* -This example produces results similar to the following output: - -Enter a key ......... a -Enter another key ... a -The A and A keys are equal. -Press the escape key (ESC) to quit, or any other key to continue. - -Enter a key ......... a -Enter another key ... A -The A and SHIFT+A keys are not equal. -Press the escape key (ESC) to quit, or any other key to continue. - -Enter a key ......... S -Enter another key ... -The ALT+SHIFT+S and ALT+CTL+F keys are not equal. -Press the escape key (ESC) to quit, or any other key to continue. - -Enter a key ......... -Enter another key ... -The UpArrow and UpArrow keys are equal. -Press the escape key (ESC) to quit, or any other key to continue. - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.GetHashcode/cpp/hash.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.GetHashcode/cpp/hash.cpp deleted file mode 100644 index 504f7fe19df..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.GetHashcode/cpp/hash.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// ConsoleKeyInfo.GetHashCode.cpp : main project file. - - -// -using namespace System; -using namespace System::Text; - -String^ KeyCombination(ConsoleKeyInfo sourceCki); - -void main() -{ - String^ k1 = "\nEnter a key ......... "; - String^ key1 = ""; - String^ hashCodeFmt = "The hash code for the {0} key is {1}."; - String^ prompt = "Press the escape key (ESC) to quit, " + - "or any other key to continue."; - ConsoleKeyInfo cki1; - int hashCode = 0; - - // The Console.TreatControlCAsInput property prevents this example from - // ending if you press CTL+C, however all other operating system keys and - // shortcuts, such as ALT+TAB or the Windows Logo key, are still in effect. - // - Console::TreatControlCAsInput = true; - - // Request that the user enter two key presses. A key press and any - // combination shift, CTRL, and ALT modifier keys is permitted. - do - { - Console::Write(k1); - cki1 = Console::ReadKey(false); - Console::WriteLine(); - - key1 = KeyCombination(cki1); - hashCode = cki1.GetHashCode(); - Console::WriteLine(hashCodeFmt, key1, hashCode); - - Console::WriteLine(prompt); - cki1 = Console::ReadKey(true); - } while (cki1.Key != ConsoleKey::Escape); - // Note: This example requires the Escape (Esc) key. -} - -// The KeyCombination() method creates a string that specifies what -// key and what combination of shift, CTRL, and ALT modifier keys -// were pressed simultaneously. - -static String^ KeyCombination(ConsoleKeyInfo sourceCki) -{ - StringBuilder^ sb = gcnew StringBuilder(); - sb->Length = 0; - String^ keyCombo; - if (sourceCki.Modifiers != (ConsoleModifiers) 0) - { - if ((sourceCki.Modifiers & ConsoleModifiers::Alt) != (ConsoleModifiers) 0) - sb->Append("ALT+"); - if ((sourceCki.Modifiers & ConsoleModifiers::Shift) != (ConsoleModifiers) 0) - sb->Append("SHIFT+"); - if ((sourceCki.Modifiers & ConsoleModifiers::Control) != (ConsoleModifiers) 0) - sb->Append("CTL+"); - } - sb->Append(sourceCki.Key.ToString()); - keyCombo = sb->ToString(); - return keyCombo; -} - - -/* -This example produces results similar to the following output: - -Enter a key ......... a -The hash code for the A key is 97. -Press the escape key (ESC) to quit, or any other key to continue. - -Enter a key ......... S -The hash code for the SHIFT+S key is 83. -Press the escape key (ESC) to quit, or any other key to continue. - -Enter a key ......... -The hash code for the ALT+SHIFT+CTL+J key is 7. -Press the escape key (ESC) to quit, or any other key to continue. - -*/ -// - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Convert Snippets/CPP/system.convert snippet.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Convert Snippets/CPP/system.convert snippet.cpp deleted file mode 100644 index ec5dbbee4ff..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Convert Snippets/CPP/system.convert snippet.cpp +++ /dev/null @@ -1,593 +0,0 @@ -using namespace System; - -public ref class ConvertSnippet -{ -// -public: - void ConvertDoubleBool( double doubleVal ) - { - bool boolVal; - - // Double to bool conversion cannot overflow. - boolVal = System::Convert::ToBoolean( doubleVal ); - System::Console::WriteLine( " {0} as a Boolean is: {1}.", - doubleVal, boolVal ); - - // bool to double conversion cannot overflow. - doubleVal = System::Convert::ToDouble( boolVal ); - System::Console::WriteLine( " {0} as a double is: {1}.", - boolVal, doubleVal ); - } - // - - // -public: - void ConvertDoubleByte( double doubleVal ) - { - Byte byteVal = 0; - - // Double to Byte conversion can overflow. - try - { - byteVal = System::Convert::ToByte( doubleVal ); - System::Console::WriteLine( " {0} as a Byte is: {1}.", - doubleVal, byteVal ); - } - catch ( System::OverflowException^ ) - { - System::Console::WriteLine( "Overflow in double-to-Byte conversion." ); - } - - // Byte to double conversion cannot overflow. - doubleVal = System::Convert::ToDouble( byteVal ); - System::Console::WriteLine( " {0} as a double is: {1}.", - byteVal, doubleVal ); - } - // - - // -public: - void ConvertDoubleInt( double doubleVal ) - { - int intVal = 0; - - // Double to int conversion can overflow. - try - { - intVal = System::Convert::ToInt32( doubleVal ); - System::Console::WriteLine( " {0} as an int is: {1}", - doubleVal, intVal ); - } - catch ( System::OverflowException^ ) - { - System::Console::WriteLine( "Overflow in double-to-int conversion." ); - } - - // Int to double conversion cannot overflow. - doubleVal = System::Convert::ToDouble( intVal ); - System::Console::WriteLine( " {0} as a double is: {1}", - intVal, doubleVal ); - } - // - - // -public: - void ConvertDoubleDecimal( double doubleVal ) - { - Decimal decimalVal; - - // Conversion from double to decimal cannot overflow. - decimalVal = System::Convert::ToDecimal( doubleVal ); - System::Console::WriteLine( " {0} as a decimal is: {1}", - doubleVal, decimalVal ); - - // Decimal to double conversion can overflow. - try - { - doubleVal = System::Convert::ToDouble( decimalVal ); - System::Console::WriteLine( " {0} as a double is: {1}", - decimalVal, doubleVal ); - } - catch ( System::OverflowException^ ) - { - System::Console::WriteLine( "Overflow in decimal-to-double conversion." ); - } - } - // - - // -public: - void CovertDoubleFloat( double doubleVal ) - { - float floatVal = 0; - - // A conversion from Double to Single cannot overflow. - floatVal = System::Convert::ToSingle( doubleVal ); - System::Console::WriteLine( " {0} as a float is {1}", - doubleVal, floatVal ); - - // A conversion from Single to Double cannot overflow. - doubleVal = System::Convert::ToDouble( floatVal ); - System::Console::WriteLine( " {0} as a double is: {1}", - floatVal, doubleVal ); - } - // - - // -public: - void ConvertDoubleString( double doubleVal ) - { - String^ stringVal; - - // A conversion from Double to String cannot overflow. - stringVal = System::Convert::ToString( doubleVal ); - System::Console::WriteLine( " {0} as a String is: {1}", - doubleVal, stringVal ); - try - { - doubleVal = System::Convert::ToDouble( stringVal ); - System::Console::WriteLine( " {0} as a double is: {1}", - stringVal, doubleVal ); - } - catch ( System::OverflowException^ ) - { - System::Console::WriteLine( "Conversion from String-to-double overflowed." ); - } - catch ( System::FormatException^ ) - { - System::Console::WriteLine( "The String was not formatted as a double." ); - } - catch ( System::ArgumentException^ ) - { - System::Console::WriteLine( "The String pointed to null." ); - } - } - // - - // -public: - void ConvertLongChar( Int64 longVal ) - { - Char charVal = 'a'; - - try - { - charVal = System::Convert::ToChar( longVal ); - System::Console::WriteLine( " {0} as a char is {1}", - longVal, charVal ); - } - catch ( System::OverflowException^ ) - { - System::Console::WriteLine( "Overflow in long-to-char conversion." ); - } - - - // A conversion from Char to long cannot overflow. - longVal = System::Convert::ToInt64( charVal ); - System::Console::WriteLine( " {0} as an Int64 is {1}", - charVal, longVal ); - } - - - // - // - void ConvertLongByte( Int64 longVal ) - { - Byte byteVal = 0; - - // A conversion from Long to Byte can overflow. - try - { - byteVal = System::Convert::ToByte( longVal ); - System::Console::WriteLine( " {0} as a Byte is {1}", - longVal, byteVal ); - } - catch ( System::OverflowException^ ) - { - System::Console::WriteLine( "Overflow in long-to-Byte conversion." ); - } - - // A conversion from Byte to long cannot overflow. - longVal = System::Convert::ToInt64( byteVal ); - System::Console::WriteLine( " {0} as an Int64 is {1}", - byteVal, longVal ); - } - // - - // -public: - void ConvertLongDecimal( Int64 longVal ) - { - Decimal decimalVal; - - // Long to decimal conversion cannot overflow. - decimalVal = System::Convert::ToDecimal( longVal ); - System::Console::WriteLine( " {0} as a decimal is {1}", - longVal, decimalVal ); - - // Decimal to long conversion can overflow. - try - { - longVal = System::Convert::ToInt64( decimalVal ); - System::Console::WriteLine( " {0} as a long is {1}", - decimalVal, longVal ); - } - catch ( System::OverflowException^ ) - { - System::Console::WriteLine( "Overflow in decimal-to-long conversion." ); - } - } - // - - // -public: - void ConvertLongFloat( Int64 longVal ) - { - float floatVal; - - // A conversion from Long to float cannot overflow. - floatVal = System::Convert::ToSingle( longVal ); - System::Console::WriteLine( " {0} as a float is {1}", - longVal, floatVal ); - - // A conversion from float to long can overflow. - try - { - longVal = System::Convert::ToInt64( floatVal ); - System::Console::WriteLine( " {0} as a long is {1}", - floatVal, longVal ); - } - catch ( System::OverflowException^ ) - { - System::Console::WriteLine( "Overflow in float-to-long conversion." ); - } - } - // - - // -public: - void ConvertStringBoolean( String^ stringVal ) - { - bool boolVal = false; - - try - { - boolVal = System::Convert::ToBoolean( stringVal ); - if ( boolVal ) - { - System::Console::WriteLine( - "String was equal to System::Boolean::TrueString." ); - } - else - { - System::Console::WriteLine( - "String was equal to System::Boolean::FalseString." ); - } - } - catch ( System::FormatException^ ) - { - System::Console::WriteLine( "The String must equal System::Boolean::TrueString " + - "or System::Boolean::FalseString." ); - } - - // A conversion from bool to String will always succeed. - stringVal = System::Convert::ToString( boolVal ); - System::Console::WriteLine( " {0} as a String is {1}", - boolVal, stringVal ); - } - // - - // -public: - void ConvertStringByte( String^ stringVal ) - { - Byte byteVal = 0; - - try - { - byteVal = System::Convert::ToByte( stringVal ); - System::Console::WriteLine( " {0} as a Byte is: {1}", - stringVal, byteVal ); - } - catch ( System::OverflowException^ ) - { - System::Console::WriteLine( - "Conversion from String to Byte overflowed." ); - } - catch ( System::FormatException^ ) - { - System::Console::WriteLine( - "The String is not formatted as a Byte." ); - } - catch ( System::ArgumentNullException^ ) - { - System::Console::WriteLine( "The String is 0." ); - } - - //The conversion from Byte to String is always valid. - stringVal = System::Convert::ToString( byteVal ); - System::Console::WriteLine( " {0} as a String is {1}", - byteVal, stringVal ); - } - // - - // -public: - void ConvertStringChar( String^ stringVal ) - { - Char charVal = 'a'; - - // A String must be one character long to convert to char. - try - { - charVal = System::Convert::ToChar( stringVal ); - System::Console::WriteLine( " {0} as a char is {1}", - stringVal, charVal ); - } - catch ( System::FormatException^ ) - { - System::Console::WriteLine( - "The String is longer than one character." ); - } - catch ( System::ArgumentNullException^ ) - { - System::Console::WriteLine( "The String is 0." ); - } - - // A char to String conversion will always succeed. - stringVal = System::Convert::ToString( charVal ); - System::Console::WriteLine( "The character as a String is {0}", - stringVal ); - } - // - - // -public: - void ConvertStringDecimal( String^ stringVal ) - { - Decimal decimalVal = 0; - - try - { - decimalVal = System::Convert::ToDecimal( stringVal ); - System::Console::WriteLine( "The String as a decimal is {0}.", - decimalVal ); - } - catch ( System::OverflowException^ ) - { - System::Console::WriteLine( - "The conversion from String to decimal overflowed." ); - } - catch ( System::FormatException^ ) - { - System::Console::WriteLine( - "The String is not formatted as a decimal." ); - } - catch ( System::ArgumentNullException^ ) - { - System::Console::WriteLine( "The String is 0." ); - } - - // Decimal to String conversion will not overflow. - stringVal = System::Convert::ToString( decimalVal ); - System::Console::WriteLine( - "The decimal as a String is {0}.", stringVal ); - } - // - - // -public: - void ConvertStringFloat( String^ stringVal ) - { - float floatVal = 0; - - try - { - floatVal = System::Convert::ToSingle( stringVal ); - System::Console::WriteLine( - "The String as a float is {0}.", floatVal ); - } - catch ( System::OverflowException^ ) - { - System::Console::WriteLine( - "The conversion from String-to-float overflowed." ); - } - catch ( System::FormatException^ ) - { - System::Console::WriteLine( - "The String is not formatted as a float." ); - } - catch ( System::ArgumentNullException^ ) - { - System::Console::WriteLine( - "The String is 0." ); - } - - // Float to String conversion will not overflow. - stringVal = System::Convert::ToString( floatVal ); - System::Console::WriteLine( - "The float as a String is {0}.", stringVal ); - } - // - - // -public: - void ConvertCharDecimal( Char charVal ) - { - Decimal decimalVal = 0; - - // Char to decimal conversion is not supported and will always - // throw an InvalidCastException. - try - { - decimalVal = System::Convert::ToDecimal( charVal ); - } - catch ( System::InvalidCastException^ ) - { - System::Console::WriteLine( - "Char-to-Decimal conversion is not supported by the .NET Framework." ); - } - - //Decimal to char conversion is also not supported. - try - { - charVal = System::Convert::ToChar( decimalVal ); - } - catch ( System::InvalidCastException^ ) - { - System::Console::WriteLine( - "Decimal-to-Char conversion is not supported by the .NET Framework." ); - } - } - // - - // -public: - void ConvertByteDecimal( Byte byteVal ) - { - Decimal decimalVal; - - // Byte to decimal conversion will not overflow. - decimalVal = System::Convert::ToDecimal( byteVal ); - System::Console::WriteLine( "The Byte as a decimal is {0}.", - decimalVal ); - - // Decimal to Byte conversion can overflow. - try - { - byteVal = System::Convert::ToByte( decimalVal ); - System::Console::WriteLine( "The Decimal as a Byte is {0}.", - byteVal ); - } - catch ( System::OverflowException^ ) - { - System::Console::WriteLine( - "The decimal value is too large for a Byte." ); - } - } - // - - // -public: - void ConvertByteSingle( Byte byteVal ) - { - float floatVal; - - // Byte to float conversion will not overflow. - floatVal = System::Convert::ToSingle( byteVal ); - System::Console::WriteLine( "The Byte as a float is {0}.", - floatVal ); - - // Float to Byte conversion can overflow. - try - { - byteVal = System::Convert::ToByte( floatVal ); - System::Console::WriteLine( "The float as a Byte is {0}.", - byteVal ); - } - catch ( System::OverflowException^ ) - { - System::Console::WriteLine( - "The float value is too large for a Byte." ); - } - } - // - - // -public: - void ConvertBoolean() - { - const int year = 1979; - const int month = 7; - const int day = 28; - const int hour = 13; - const int minute = 26; - const int second = 15; - const int millisecond = 53; - DateTime dateTime( year, month, day, hour, - minute, second, millisecond ); - bool boolVal; - - // System::InvalidCastException is always thrown. - try - { - boolVal = System::Convert::ToBoolean( dateTime ); - } - catch ( System::InvalidCastException^ ) - { - System::Console::WriteLine( "Conversion from DateTime to Boolean "+ - "is not supported by the .NET Framework." ); - } - } - // - - void ConvertDoubles( double doubleVal ) - { - ConvertDoubleBool( doubleVal ); - ConvertDoubleByte( doubleVal ); - ConvertDoubleInt( doubleVal ); - ConvertDoubleDecimal( doubleVal ); - CovertDoubleFloat( doubleVal ); - ConvertDoubleString( doubleVal ); - } - - void ConvertLongs( Int64 longVal ) - { - ConvertLongChar( longVal ); - ConvertLongByte( longVal ); - ConvertLongDecimal( longVal ); - ConvertLongFloat( longVal ); - } - - void ConvertStrings( String^ stringVal ) - { - ConvertStringBoolean( stringVal ); - ConvertStringByte( stringVal ); - ConvertStringChar( stringVal ); - ConvertStringDecimal( stringVal ); - ConvertStringFloat( stringVal ); - } - - void ConvertChars( Char charVal ) - { - ConvertCharDecimal( charVal ); - } - - void ConvertBytes( Byte byteVal ) - { - ConvertByteDecimal( byteVal ); - ConvertByteSingle( byteVal ); - } -}; - -int main() -{ - ConvertSnippet^ snippet = gcnew ConvertSnippet; - - double doubleVal; - System::Console::WriteLine( "Enter the double value: " ); - doubleVal = System::Convert::ToDouble( System::Console::ReadLine() ); - snippet->ConvertDoubles( doubleVal ); - - Int64 longVal; - System::Console::WriteLine( "Enter the Int64 value: " ); - longVal = System::Convert::ToInt64( System::Console::ReadLine() ); - snippet->ConvertLongs( longVal ); - - String^ stringVal; - System::Console::WriteLine( "Enter the String value: " ); - stringVal = System::Console::ReadLine(); - snippet->ConvertStrings( stringVal ); - - Char charVal; - System::Console::WriteLine( "Enter the char value: " ); - charVal = System::Convert::ToChar( System::Console::ReadLine() ); - snippet->ConvertChars( charVal ); - - Byte byteVal; - System::Console::WriteLine( "Enter the Byte value: " ); - byteVal = System::Convert::ToByte( System::Console::ReadLine() ); - snippet->ConvertBytes( byteVal ); - - snippet->ConvertBoolean(); -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Convert.BaseConversion/cpp/toint_str_int32.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Convert.BaseConversion/cpp/toint_str_int32.cpp deleted file mode 100644 index 6ae7e65bdc1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Convert.BaseConversion/cpp/toint_str_int32.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// ToInt_Str_Int32.cpp : main project file. - -//#include "stdafx.h" - -using namespace System; - -int main(array ^args) -{ - // - // Create a hexadecimal value out of range of the integer type. - String^ value1 = Convert::ToString((static_cast<__int64>(int::MaxValue)) + 1, 16); - // Convert it back to a number. - try { - int number = Convert::ToInt32(value1, 16); - Console::WriteLine("0x{0} converts to {1}.", value1, number); - } - catch (OverflowException ^e) { - Console::WriteLine("Unable to convert '0x{0}' to an integer.", value1); - } - // The example displays the following output: - // 0x80000000 converts to -2147483648. - // - - // - __int64 sourceNumber2 = (static_cast<__int64>(int::MaxValue)) + 1; - bool isNegative = Math::Sign(sourceNumber2) == -1; - String^ value2 = Convert::ToString(sourceNumber2, 16); - int targetNumber; - try { - targetNumber = Convert::ToInt32(value2, 16); - if (!(isNegative) & (targetNumber & 0x80000000) != 0) - throw gcnew OverflowException(); - else - Console::WriteLine("0x{0} converts to {1}.", value2, targetNumber); - } - catch (OverflowException ^e) { - Console::WriteLine("Unable to convert '0x{0}' to an integer.", value2); - } - // The example displays the following output: - // Unable to convert '0x80000000' to an integer. - // - //Console::Write("Press any key..."); - //Console::ReadLine(); - return 0; -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToBoolean/cpp/toboolean1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToBoolean/cpp/toboolean1.cpp deleted file mode 100644 index 7cff3673fb0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToBoolean/cpp/toboolean1.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// Convert.ToBoolean2.cpp : main project file. - -// -using namespace System; - -void main() -{ - array^ values = gcnew array { nullptr, String::Empty, - "true", "TrueString", - "False", " false ", - "-1", "0" }; - for each (String^ value in values) { - try - { - Console::WriteLine("Converted '{0}' to {1}.", value, - Convert::ToBoolean(value)); - } - catch (FormatException^ e) - { - Console::WriteLine("Unable to convert '{0}' to a Boolean.", value); - } - } -} -// The example displays the following output: -// Converted '' to False. -// Unable to convert '' to a Boolean. -// Converted 'true' to True. -// Unable to convert 'TrueString' to a Boolean. -// Converted 'False' to False. -// Converted ' false ' to False. -// Unable to convert '-1' to a Boolean. -// Unable to convert '0' to a Boolean. -// - - - - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToBoolean/cpp/toboolean2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToBoolean/cpp/toboolean2.cpp deleted file mode 100644 index ed404e69c09..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToBoolean/cpp/toboolean2.cpp +++ /dev/null @@ -1,303 +0,0 @@ -// Convert.ToBoolean.cpp : main project file. - -using namespace System; - -void ToByte() -{ - // - array^ bytes = gcnew array { Byte::MinValue, 100, 200, Byte::MaxValue }; - bool result; - - for each (Byte byteValue in bytes) - { - result = Convert::ToBoolean(byteValue); - Console::WriteLine("{0,-5} --> {1}", byteValue, result); - } - // The example displays the following output: - // 0 --> False - // 100 --> True - // 200 --> True - // 255 --> True - // -} - -void ToDecimal() -{ - // - array^ numbers = gcnew array { Decimal::MinValue, (Decimal) -12034.87, - (Decimal) -100, (Decimal) 0, (Decimal) 300, - (Decimal) 6790823.45, Decimal::MaxValue }; - bool result; - - for each (Decimal number in numbers) - { - result = Convert::ToBoolean(number); - Console::WriteLine("{0,-30} --> {1}", number, result); - } - // The example displays the following output: - // -79228162514264337593543950335 --> True - // -12034.87 --> True - // -100 --> True - // 0 --> False - // 300 --> True - // 6790823.45 --> True - // 79228162514264337593543950335 --> True - // -} - -void ToInt16() -{ - // - array^ numbers = gcnew array { Int16::MinValue, -10000, -154, 0, 216, 21453, - Int16::MaxValue }; - bool result; - - for each (Int16 number in numbers) - { - result = Convert::ToBoolean(number); - Console::WriteLine("{0,-7:N0} --> {1}", number, result); - } - // The example displays the following output: - // -32,768 --> True - // -10,000 --> True - // -154 --> True - // 0 --> False - // 216 --> True - // 21,453 --> True - // 32,767 --> True - // -} - -void ToInt32() -{ - // - array^ numbers = gcnew array { Int32::MinValue, -201649, -68, 0, 612, 4038907, - Int32::MaxValue }; - bool result; - - for each (int number in numbers) - { - result = Convert::ToBoolean(number); - Console::WriteLine("{0,-15:N0} --> {1}", number, result); - } - // The example displays the following output: - // -2,147,483,648 --> True - // -201,649 --> True - // -68 --> True - // 0 --> False - // 612 --> True - // 4,038,907 --> True - // 2,147,483,647 --> True - // -} - -void ToInt64() -{ - // - array^ numbers = gcnew array { Int64::MinValue, -2016493, -689, 0, 6121, - 403890774, Int64::MaxValue }; - bool result; - - for each (Int64 number in numbers) - { - result = Convert::ToBoolean(number); - Console::WriteLine("{0,-26:N0} --> {1}", number, result); - } - // The example displays the following output: - // -9,223,372,036,854,775,808 --> True - // -2,016,493 --> True - // -689 --> True - // 0 --> False - // 6,121 --> True - // 403,890,774 --> True - // 9,223,372,036,854,775,807 --> True - // -} - -void ToObject() -{ - // - array^ objects = gcnew array { 16.33, -24, 0, "12", "12.7", String::Empty, - "1String", "True", "false", nullptr, - gcnew System::Collections::ArrayList }; - - for each (Object^ obj in objects) - { - Console::Write("{0,-40} --> ", - obj == nullptr ? "null" : - String::Format("{0} ({1})", obj, obj->GetType()->Name)); - try { - Console::WriteLine("{0}", Convert::ToBoolean((Object^) obj)); - } - catch (FormatException^) { - Console::WriteLine("Bad Format"); - } - catch (InvalidCastException^) { - Console::WriteLine("No Conversion"); - } - } - // The example displays the following output: - // 16.33 (Double) --> True - // -24 (Int32) --> True - // 0 (Int32) --> False - // 12 (String) --> Bad Format - // 12.7 (String) --> Bad Format - // (String) --> Bad Format - // 1String (String) --> Bad Format - // True (String) --> True - // false (String) --> False - // null --> False - // System.Collections.ArrayList (ArrayList) --> No Conversion - // -} - -void ToSByte() -{ - // - array^ numbers = gcnew array { SByte::MinValue, -1, 0, 10, 100, SByte::MaxValue }; - bool result; - - for each (SByte number in numbers) - { - result = Convert::ToBoolean(number); - Console::WriteLine("{0,-5} --> {1}", number, result); - } - // The example displays the following output: - // -128 --> True - // -1 --> True - // 0 --> False - // 10 --> True - // 100 --> True - // 127 --> True - // -} - -void ToSingle() -{ - // - array^ numbers = gcnew array { Single::MinValue, (float) -193.0012, (float) 20e-15f, 0, - (float) 10551e-10, (float) 100.3398, Single::MaxValue }; - bool result; - - for each (float number in numbers) - { - result = Convert::ToBoolean(number); - Console::WriteLine("{0,-15} --> {1}", number, result); - } - // The example displays the following output: - // -3.402823E+38 --> True - // -193.0012 --> True - // 2E-14 --> True - // 0 --> False - // 1.0551E-06 --> True - // 100.3398 --> True - // 3.402823E+38 --> True - // -} - -void ToUInt16() -{ - // - array^ numbers = gcnew array { UInt16::MinValue, 216, 21453, UInt16::MaxValue }; - bool result; - - for each (unsigned short number in numbers) - { - result = Convert::ToBoolean(number); - Console::WriteLine("{0,-7:N0} --> {1}", number, result); - } - // The example displays the following output: - // 0 --> False - // 216 --> True - // 21,453 --> True - // 65,535 --> True - // -} - -void ToUInt32() -{ - // - array^ numbers = gcnew array { UInt32::MinValue, 612, 4038907, Int32::MaxValue }; - bool result; - - for each (unsigned int number in numbers) - { - result = Convert::ToBoolean(number); - Console::WriteLine("{0,-15:N0} --> {1}", number, result); - } - // The example displays the following output: - // 0 --> False - // 612 --> True - // 4,038,907 --> True - // 2,147,483,647 --> True - // -} - -void ToUInt64() -{ - // - array^ numbers = gcnew array { UInt64::MinValue, 6121, 403890774, UInt64::MaxValue }; - bool result; - - for each (UInt64 number in numbers) - { - result = Convert::ToBoolean(number); - Console::WriteLine("{0,-26:N0} --> {1}", number, result); - } - // The example displays the following output: - // 0 --> False - // 6,121 --> True - // 403,890,774 --> True - // 18,446,744,073,709,551,615 --> True - // -} - -void main() -{ - Console::WriteLine("ToByte:"); - ToByte(); - Console::WriteLine(); - - Console::WriteLine("ToDecimal:"); - ToDecimal(); - Console::WriteLine(); - - Console::WriteLine("ToInt16:"); - ToInt16(); - Console::WriteLine(); - - Console::WriteLine("ToInt32:"); - ToInt32(); - Console::WriteLine(); - - Console::WriteLine("ToInt64:"); - ToInt64(); - Console::WriteLine(); - - Console::WriteLine("ToObject:"); - ToObject(); - Console::WriteLine(); - - Console::WriteLine("ToSByte:"); - ToSByte(); - Console::WriteLine(); - - Console::WriteLine("ToSingle:"); - ToSingle(); - Console::WriteLine(); - - Console::WriteLine("ToUInt16:"); - ToUInt16(); - Console::WriteLine(); - - Console::WriteLine("ToUInt32:"); - ToUInt32(); - Console::WriteLine(); - - Console::WriteLine("ToUInt64:"); - ToUInt64(); - Console::WriteLine(); - - Console::ReadLine(); -} - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToNonNum_String/CPP/stringnonnum.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToNonNum_String/CPP/stringnonnum.cpp deleted file mode 100644 index 868a76dd151..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToNonNum_String/CPP/stringnonnum.cpp +++ /dev/null @@ -1,75 +0,0 @@ - -// -using namespace System; -using namespace System::Globalization; -ref class DummyProvider: public IFormatProvider -{ -public: - - // Normally, GetFormat returns an object of the requested type - // (usually itself) if it is able; otherwise, it returns Nothing. - virtual Object^ GetFormat( Type^ argType ) - { - // Here, GetFormat displays the name of argType, after removing - // the namespace information. GetFormat always returns null. - String^ argStr = argType->ToString(); - if ( argStr->Equals( "" ) ) - argStr = "Empty"; - - argStr = argStr->Substring( argStr->LastIndexOf( '.' ) + 1 ); - Console::Write( "{0,-20}", argStr ); - return (Object^)0; - } -}; - -int main() -{ - // Create an instance of IFormatProvider. - DummyProvider^ provider = gcnew DummyProvider; - String^ format = "{0,-17}{1,-17}{2}"; - - // Convert these values using DummyProvider. - String^ Int32A = "-252645135"; - String^ DoubleA = "61680.3855"; - String^ DayTimeA = "2001/9/11 13:45"; - String^ BoolA = "True"; - String^ StringA = "Qwerty"; - String^ CharA = "$"; - Console::WriteLine( "This example of selected " - "Convert::To( String*, IFormatProvider* ) \nmethods " - "generates the following output. The example displays the " - "\nprovider type if the IFormatProvider is called." ); - Console::WriteLine( "\nNote: For the " - "ToBoolean, ToString, and ToChar methods, the \n" - "IFormatProvider object is not referenced." ); - - // The format provider is called for the following conversions. - Console::WriteLine(); - Console::WriteLine( format, "ToInt32", Int32A, Convert::ToInt32( Int32A, provider ) ); - Console::WriteLine( format, "ToDouble", DoubleA, Convert::ToDouble( DoubleA, provider ) ); - Console::WriteLine( format, "ToDateTime", DayTimeA, Convert::ToDateTime( DayTimeA, provider ) ); - - // The format provider is not called for these conversions. - Console::WriteLine(); - Console::WriteLine( format, "ToBoolean", BoolA, Convert::ToBoolean( BoolA, provider ) ); - Console::WriteLine( format, "ToString", StringA, Convert::ToString( StringA, provider ) ); - Console::WriteLine( format, "ToChar", CharA, Convert::ToChar( CharA, provider ) ); -} - -/* -This example of selected Convert::To( String*, IFormatProvider* ) -methods generates the following output. The example displays the -provider type if the IFormatProvider is called. - -Note: For the ToBoolean, ToString, and ToChar methods, the -IFormatProvider object is not referenced. - -NumberFormatInfo ToInt32 -252645135 -252645135 -NumberFormatInfo ToDouble 61680.3855 61680.3855 -DateTimeFormatInfo ToDateTime 2001/9/11 13:45 9/11/2001 1:45:00 PM - -ToBoolean True True -ToString Qwerty Qwerty -ToChar $ $ -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToSInts_String/CPP/toint16.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToSInts_String/CPP/toint16.cpp deleted file mode 100644 index feecf23e2a2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToSInts_String/CPP/toint16.cpp +++ /dev/null @@ -1,105 +0,0 @@ - -// -// Example of the Convert::ToInt16( String* ) and -// Convert::ToInt16( String*, IFormatProvider* ) methods. -using namespace System; -using namespace System::Globalization; -const __wchar_t * protoFmt = L"{0,-20}{1,-20}{2}"; - -// Get the exception type name; remove the namespace prefix. -String^ GetExceptionType( Exception^ ex ) -{ - String^ exceptionType = ex->GetType()->ToString(); - return exceptionType->Substring( exceptionType->LastIndexOf( '.' ) + 1 ); -} - -void ConvertToInt16( String^ numericStr, IFormatProvider^ provider ) -{ - Object^ defaultValue; - Object^ providerValue; - - // Convert numericStr to Int16 without a format provider. - try - { - defaultValue = Convert::ToInt16( numericStr ); - } - catch ( Exception^ ex ) - { - defaultValue = GetExceptionType( ex ); - } - - - // Convert numericStr to Int16 with a format provider. - try - { - providerValue = Convert::ToInt16( numericStr, provider ); - } - catch ( Exception^ ex ) - { - providerValue = GetExceptionType( ex ); - } - - Console::WriteLine( gcnew String( protoFmt ), numericStr, defaultValue, providerValue ); -} - -int main() -{ - - // Create a NumberFormatInfo object and set several of its - // properties that apply to numbers. - NumberFormatInfo^ provider = gcnew NumberFormatInfo; - - // These properties affect the conversion. - provider->NegativeSign = "neg "; - provider->PositiveSign = "pos "; - - // These properties do not affect the conversion. - // The input string cannot have decimal and group separators. - provider->NumberDecimalSeparator = "."; - provider->NumberGroupSeparator = ","; - array^sizes = {3}; - provider->NumberGroupSizes = sizes; - provider->NumberNegativePattern = 0; - Console::WriteLine( "This example of\n" - " Convert::ToInt16( String* ) and \n" - " Convert::ToInt16( String*, IFormatProvider* ) " - "\ngenerates the following output. It converts " - "several strings to \nshort values, using " - "default formatting or a NumberFormatInfo object.\n" ); - Console::WriteLine( gcnew String( protoFmt ), "String to convert", "Default/exception", "Provider/exception" ); - Console::WriteLine( gcnew String( protoFmt ), "-----------------", "-----------------", "------------------" ); - - // Convert strings, with and without an IFormatProvider. - ConvertToInt16( "12345", provider ); - ConvertToInt16( "+12345", provider ); - ConvertToInt16( "pos 12345", provider ); - ConvertToInt16( "-12345", provider ); - ConvertToInt16( "neg 12345", provider ); - ConvertToInt16( "12345.", provider ); - ConvertToInt16( "12,345", provider ); - ConvertToInt16( "(12345)", provider ); - ConvertToInt16( "32768", provider ); - ConvertToInt16( "-32769", provider ); -} - -/* -This example of - Convert::ToInt16( String* ) and - Convert::ToInt16( String*, IFormatProvider* ) -generates the following output. It converts several strings to -short values, using default formatting or a NumberFormatInfo object. - -String to convert Default/exception Provider/exception ------------------ ----------------- ------------------ -12345 12345 12345 -+12345 12345 FormatException -pos 12345 FormatException 12345 --12345 -12345 FormatException -neg 12345 FormatException -12345 -12345. FormatException FormatException -12,345 FormatException FormatException -(12345) FormatException FormatException -32768 OverflowException OverflowException --32769 OverflowException FormatException -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToSInts_String/CPP/tosbyte.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToSInts_String/CPP/tosbyte.cpp deleted file mode 100644 index 3336b2aa23d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToSInts_String/CPP/tosbyte.cpp +++ /dev/null @@ -1,100 +0,0 @@ - -// -// Example of the Convert::ToSByte( String* ) and -// Convert::ToSByte( String*, IFormatProvider* ) methods. -using namespace System; -using namespace System::Globalization; -const __wchar_t * protoFmt = L"{0,-20}{1,-20}{2}"; - -// Get the exception type name; remove the namespace prefix. -String^ GetExceptionType( Exception^ ex ) -{ - String^ exceptionType = ex->GetType()->ToString(); - return exceptionType->Substring( exceptionType->LastIndexOf( '.' ) + 1 ); -} - -void ConvertToSByte( String^ numericStr, IFormatProvider^ provider ) -{ - Object^ defaultValue; - Object^ providerValue; - - // Convert numericStr to SByte without a format provider. - try - { - defaultValue = Convert::ToSByte( numericStr ); - } - catch ( Exception^ ex ) - { - defaultValue = GetExceptionType( ex ); - } - - - // Convert numericStr to SByte with a format provider. - try - { - providerValue = Convert::ToSByte( numericStr, provider ); - } - catch ( Exception^ ex ) - { - providerValue = GetExceptionType( ex ); - } - - Console::WriteLine( gcnew String( protoFmt ), numericStr, defaultValue, providerValue ); -} - -int main() -{ - - // Create a NumberFormatInfo object and set several of its - // properties that apply to numbers. - NumberFormatInfo^ provider = gcnew NumberFormatInfo; - - // These properties affect the conversion. - provider->NegativeSign = "neg "; - provider->PositiveSign = "pos "; - - // These properties do not affect the conversion. - // The input string cannot have decimal and group separators. - provider->NumberDecimalSeparator = "."; - provider->NumberNegativePattern = 0; - Console::WriteLine( "This example of\n" - " Convert::ToSByte( String* ) and \n" - " Convert::ToSByte( String*, IFormatProvider* ) " - "\ngenerates the following output. It converts " - "several strings to \nSByte values, using " - "default formatting or a NumberFormatInfo object.\n" ); - Console::WriteLine( gcnew String( protoFmt ), "String to convert", "Default/exception", "Provider/exception" ); - Console::WriteLine( gcnew String( protoFmt ), "-----------------", "-----------------", "------------------" ); - - // Convert strings, with and without an IFormatProvider. - ConvertToSByte( "123", provider ); - ConvertToSByte( "+123", provider ); - ConvertToSByte( "pos 123", provider ); - ConvertToSByte( "-123", provider ); - ConvertToSByte( "neg 123", provider ); - ConvertToSByte( "123.", provider ); - ConvertToSByte( "(123)", provider ); - ConvertToSByte( "128", provider ); - ConvertToSByte( "-129", provider ); -} - -/* -This example of - Convert::ToSByte( String* ) and - Convert::ToSByte( String*, IFormatProvider* ) -generates the following output. It converts several strings to -SByte values, using default formatting or a NumberFormatInfo object. - -String to convert Default/exception Provider/exception ------------------ ----------------- ------------------ -123 123 123 -+123 123 FormatException -pos 123 FormatException 123 --123 -123 FormatException -neg 123 FormatException -123 -123. FormatException FormatException -(123) FormatException FormatException -128 OverflowException OverflowException --129 OverflowException FormatException -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToString.IFormatProvider/CPP/nonnumeric.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToString.IFormatProvider/CPP/nonnumeric.cpp deleted file mode 100644 index 819130067f5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToString.IFormatProvider/CPP/nonnumeric.cpp +++ /dev/null @@ -1,94 +0,0 @@ - -// -// Example of Convert::ToString( non-numeric types, IFormatProvider ). -using namespace System; -using namespace System::Globalization; - -#define null (Object^)0 - -// An instance of this class can be passed to methods that require -// an IFormatProvider. -ref class DummyProvider: public IFormatProvider -{ -public: - - // Normally, GetFormat returns an object of the requested type - // (usually itself) if it is able; otherwise, it returns Nothing. - virtual Object^ GetFormat( Type^ argType ) - { - // Here, the type of argType is displayed, and GetFormat - // always returns Nothing. - Console::Write( "{0,-40}", argType->ToString() ); - return null; - } -}; - -int main() -{ - // Create an instance of the IFormatProvider. - DummyProvider^ provider = gcnew DummyProvider; - String^ converted; - - // Convert these values using DummyProvider. - int Int32A = -252645135; - double DoubleA = 61680.3855; - Object^ ObjDouble = -98765.4321; - DateTime DayTimeA = DateTime(2001,9,11,13,45,0); - bool BoolA = true; - String^ StringA = "Qwerty"; - Char CharA = '$'; - TimeSpan TSpanA = TimeSpan(0,18,0); - Object^ ObjOther = static_cast(provider); - Console::WriteLine( "This example of " - "Convert::ToString( non-numeric, IFormatProvider* ) \n" - "generates the following output. The provider type, " - "argument type, \nand argument value are displayed." ); - Console::WriteLine( "\nNote: The IFormatProvider object is " - "not called for Boolean, String, \nChar, TimeSpan, " - "and non-numeric Object." ); - - // The format provider is called for these conversions. - Console::WriteLine(); - converted = Convert::ToString( Int32A, provider ); - Console::WriteLine( "int {0}", converted ); - converted = Convert::ToString( DoubleA, provider ); - Console::WriteLine( "double {0}", converted ); - converted = Convert::ToString( ObjDouble, provider ); - Console::WriteLine( "Object {0}", converted ); - converted = Convert::ToString( DayTimeA, provider ); - Console::WriteLine( "DateTime {0}", converted ); - - // The format provider is not called for these conversions. - Console::WriteLine(); - converted = Convert::ToString( BoolA, provider ); - Console::WriteLine( "bool {0}", converted ); - converted = Convert::ToString( StringA, provider ); - Console::WriteLine( "String {0}", converted ); - converted = Convert::ToString( CharA, provider ); - Console::WriteLine( "Char {0}", converted ); - converted = Convert::ToString( TSpanA, provider ); - Console::WriteLine( "TimeSpan {0}", converted ); - converted = Convert::ToString( ObjOther, provider ); - Console::WriteLine( "Object {0}", converted ); -} - -/* -This example of Convert::ToString( non-numeric, IFormatProvider* ) -generates the following output. The provider type, argument type, -and argument value are displayed. - -Note: The IFormatProvider object is not called for Boolean, String, -Char, TimeSpan, and non-numeric Object. - -System.Globalization.NumberFormatInfo int -252645135 -System.Globalization.NumberFormatInfo double 61680.3855 -System.Globalization.NumberFormatInfo Object -98765.4321 -System.Globalization.DateTimeFormatInfo DateTime 9/11/2001 1:45:00 PM - -bool True -String Qwerty -Char $ -TimeSpan 00:18:00 -Object DummyProvider -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToXXX_Object_IFP/CPP/objectifp.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToXXX_Object_IFP/CPP/objectifp.cpp deleted file mode 100644 index 2e233191f16..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToXXX_Object_IFP/CPP/objectifp.cpp +++ /dev/null @@ -1,458 +0,0 @@ - -// -using namespace System; -using namespace System::Collections; - -// Define the types of averaging available in the class -// implementing IConvertible. -public enum class AverageType : short -{ - None = 0, - GeometricMean = 1, - ArithmeticMean = 2, - Median = 3 -}; - - -// Pass an instance of this class to methods that require an -// IFormatProvider. The class instance determines the type of -// average to calculate. -ref class AverageInfo: public IFormatProvider -{ -protected: - AverageType AvgType; - -public: - - // Specify the type of averaging in the constructor. - AverageInfo( AverageType avgType ) - { - this->AvgType = avgType; - } - - - // This method returns a reference to the containing object - // if an object of AverageInfo type is requested. - virtual Object^ GetFormat( Type^ argType ) - { - if ( argType == AverageInfo::typeid) - return this; - else - return (Object^)0; - } - - - property AverageType TypeOfAverage - { - - // Use this property to set or get the type of averaging. - AverageType get() - { - return this->AvgType; - } - - void set( AverageType value ) - { - this->AvgType = value; - } - - } - -}; - - -// This class encapsulates an array of double values and implements -// the IConvertible interface. Most of the IConvertible methods -// return an average of the array elements in one of three types: -// arithmetic mean, geometric mean, or median. -ref class DataSet: public IConvertible -{ -private: - static Object^ null = nullptr; - -protected: - ArrayList^ data; - AverageInfo^ defaultProvider; - - // This method unboxes a boxed double. - double UnBoxDouble( Object^ obj ) - { - return *static_cast(obj); - } - - -public: - - // Construct the object and add an initial list of values. - // Create a default format provider. - DataSet( ... array^values ) - { - data = gcnew ArrayList( (Array^)values ); - defaultProvider = gcnew AverageInfo( AverageType::ArithmeticMean ); - } - - - // Add additional values with this method. - int Add( double value ) - { - data->Add( value ); - return data->Count; - } - - - property double Item[ int ] - { - - // Get, set, and add values with this indexer property. - double get( int index ) - { - if ( index >= 0 && index < data->Count ) - return UnBoxDouble( data[ index ] ); - else - throw gcnew InvalidOperationException( "[DataSet.get] Index out of range." ); - } - - void set( int index, double value ) - { - if ( index >= 0 && index < data->Count ) - data[ index ] = value; - else - if ( index == data->Count ) - data->Add( value ); - else - throw gcnew InvalidOperationException( "[DataSet.set] Index out of range." ); - } - - } - - property int Count - { - - // This property returns the number of elements in the object. - int get() - { - return data->Count; - } - - } - -protected: - - // This method calculates the average of the object's elements. - double Average( AverageType avgType ) - { - double SumProd; - if ( data->Count == 0 ) - return 0.0; - - switch ( avgType ) - { - case AverageType::GeometricMean: - SumProd = 1.0; - for ( int Index = 0; Index < data->Count; Index++ ) - SumProd *= UnBoxDouble( data[ Index ] ); - - // This calculation will not fail with negative - // elements. - return Math::Sign( SumProd ) * Math::Pow( Math::Abs( SumProd ), 1.0 / data->Count ); - - case AverageType::ArithmeticMean: - SumProd = 0.0; - for ( int Index = 0; Index < data->Count; Index++ ) - SumProd += UnBoxDouble( data[ Index ] ); - return SumProd / data->Count; - - case AverageType::Median: - if ( data->Count % 2 == 0 ) - return (UnBoxDouble( data[ data->Count / 2 ] ) + UnBoxDouble( data[ data->Count / 2 - 1 ] )) / 2.0; - else - return UnBoxDouble( data[ data->Count / 2 ] ); - - default: - return 0.0; - } - } - - - // Get the AverageInfo object from the caller's format provider, - // or use the local default. - AverageInfo^ GetAverageInfo( IFormatProvider^ provider ) - { - AverageInfo^ avgInfo = nullptr; - if ( provider != nullptr ) - avgInfo = static_cast(provider->GetFormat( AverageInfo::typeid )); - - if ( avgInfo == nullptr ) - return defaultProvider; - else - return avgInfo; - } - - - // Calculate the average and limit the range. - double CalcNLimitAverage( double min, double max, IFormatProvider^ provider ) - { - - // Get the format provider and calculate the average. - AverageInfo^ avgInfo = GetAverageInfo( provider ); - double avg = Average( avgInfo->TypeOfAverage ); - - // Limit the range, based on the minimum and maximum values - // for the type. - return avg > max ? max : avg < min ? min : avg; - } - - -public: - - // The following elements are required by IConvertible. - // None of these conversion functions throw exceptions. When - // the data is out of range for the type, the appropriate - // MinValue or MaxValue is used. - virtual TypeCode GetTypeCode() - { - return TypeCode::Object; - } - - virtual bool ToBoolean( IFormatProvider^ provider ) - { - - // ToBoolean is false if the dataset is empty. - if ( data->Count <= 0 ) - return false; - // For median averaging, ToBoolean is true if any - // non-discarded elements are nonzero. - else - - // For median averaging, ToBoolean is true if any - // non-discarded elements are nonzero. - if ( AverageType::Median == GetAverageInfo( provider )->TypeOfAverage ) - { - if ( data->Count % 2 == 0 ) - return (UnBoxDouble( data[ data->Count / 2 ] ) != 0.0 || UnBoxDouble( data[ data->Count / 2 - 1 ] ) != 0.0); - else - return UnBoxDouble( data[ data->Count / 2 ] ) != 0.0; - } - // For arithmetic or geometric mean averaging, ToBoolean is - // true if any element of the dataset is nonzero. - else - { - for ( int Index = 0; Index < data->Count; Index++ ) - if ( UnBoxDouble( data[ Index ] ) != 0.0 ) - return true; - return false; - } - } - - virtual Byte ToByte( IFormatProvider^ provider ) - { - return Convert::ToByte( CalcNLimitAverage( Byte::MinValue, Byte::MaxValue, provider ) ); - } - - virtual Char ToChar( IFormatProvider^ provider ) - { - return Convert::ToChar( Convert::ToUInt16( CalcNLimitAverage( Char::MinValue, Char::MaxValue, provider ) ) ); - } - - - // Convert to DateTime by adding the calculated average as - // seconds to the current date and time. A valid DateTime is - // always returned. - virtual DateTime ToDateTime( IFormatProvider^ provider ) - { - double seconds = Average( GetAverageInfo( provider )->TypeOfAverage ); - try - { - return DateTime::Now.AddSeconds( seconds ); - } - catch ( ArgumentOutOfRangeException^ ) - { - return seconds < 0.0 ? DateTime::MinValue : DateTime::MaxValue; - } - - } - - virtual Decimal ToDecimal( IFormatProvider^ provider ) - { - - // The Double conversion rounds Decimal.MinValue and - // Decimal.MaxValue to invalid Decimal values, so the - // following limits must be used. - return Convert::ToDecimal( CalcNLimitAverage( -79228162514264330000000000000.0, 79228162514264330000000000000.0, provider ) ); - } - - virtual double ToDouble( IFormatProvider^ provider ) - { - return Average( GetAverageInfo( provider )->TypeOfAverage ); - } - - virtual short ToInt16( IFormatProvider^ provider ) - { - return Convert::ToInt16( CalcNLimitAverage( Int16::MinValue, Int16::MaxValue, provider ) ); - } - - virtual int ToInt32( IFormatProvider^ provider ) - { - return Convert::ToInt32( CalcNLimitAverage( Int32::MinValue, Int32::MaxValue, provider ) ); - } - - virtual __int64 ToInt64( IFormatProvider^ provider ) - { - - // The Double conversion rounds Int64.MinValue and - // Int64.MaxValue to invalid Int64 values, so the following - // limits must be used. - return Convert::ToInt64( CalcNLimitAverage( -9223372036854775000, 9223372036854775000, provider ) ); - } - - virtual signed char ToSByte( IFormatProvider^ provider ) - { - return Convert::ToSByte( CalcNLimitAverage( SByte::MinValue, SByte::MaxValue, provider ) ); - } - - virtual float ToSingle( IFormatProvider^ provider ) - { - return Convert::ToSingle( CalcNLimitAverage( Single::MinValue, Single::MaxValue, provider ) ); - } - - virtual UInt16 ToUInt16( IFormatProvider^ provider ) - { - return Convert::ToUInt16( CalcNLimitAverage( UInt16::MinValue, UInt16::MaxValue, provider ) ); - } - - virtual UInt32 ToUInt32( IFormatProvider^ provider ) - { - return Convert::ToUInt32( CalcNLimitAverage( UInt32::MinValue, UInt32::MaxValue, provider ) ); - } - - virtual UInt64 ToUInt64( IFormatProvider^ provider ) - { - - // The Double conversion rounds UInt64.MaxValue to an invalid - // UInt64 value, so the following limit must be used. - return Convert::ToUInt64( CalcNLimitAverage( 0, 18446744073709550000.0, provider ) ); - } - - virtual Object^ ToType( Type^ conversionType, IFormatProvider^ provider ) - { - return Convert::ChangeType( Average( GetAverageInfo( provider )->TypeOfAverage ), conversionType ); - } - - virtual String^ ToString( IFormatProvider^ provider ) - { - AverageType avgType = GetAverageInfo( provider )->TypeOfAverage; - return String::Format( "( {0}: {1:G10} )", avgType, Average( avgType ) ); - } - -}; - - -// Display a DataSet with three different format providers. -void DisplayDataSet( DataSet^ ds ) -{ - IFormatProvider^ null = nullptr; - String^ fmt = "{0,-12}{1,20}{2,20}{3,20}"; - AverageInfo^ median = gcnew AverageInfo( AverageType::Median ); - AverageInfo^ geMean = gcnew AverageInfo( AverageType::GeometricMean ); - - // Display the dataset elements. - if ( ds->Count > 0 ) - { - Console::Write( "\nDataSet: [{0}", ds->Item[ 0 ] ); - for ( int iX = 1; iX < ds->Count; iX++ ) - Console::Write( ", {0}", ds->Item[ iX ] ); - Console::WriteLine( "]\n" ); - } - - Console::WriteLine( fmt, "Convert::", "Default", "Geometric Mean", "Median" ); - Console::WriteLine( fmt, "---------", "-------", "--------------", "------" ); - Console::WriteLine( fmt, "ToBoolean", Convert::ToBoolean( ds, null ), Convert::ToBoolean( ds, geMean ), Convert::ToBoolean( ds, median ) ); - Console::WriteLine( fmt, "ToByte", Convert::ToByte( ds, null ), Convert::ToByte( ds, geMean ), Convert::ToByte( ds, median ) ); - Console::WriteLine( fmt, "ToChar", Convert::ToChar( ds, null ), Convert::ToChar( ds, geMean ), Convert::ToChar( ds, median ) ); - Console::WriteLine( "{0,-12}{1,20:yyyy-MM-dd HH:mm:ss}" - "{2,20:yyyy-MM-dd HH:mm:ss}{3,20:yyyy-MM-dd HH:mm:ss}", "ToDateTime", Convert::ToDateTime( ds, null ), Convert::ToDateTime( ds, geMean ), Convert::ToDateTime( ds, median ) ); - Console::WriteLine( fmt, "ToDecimal", Convert::ToDecimal( ds, null ), Convert::ToDecimal( ds, geMean ), Convert::ToDecimal( ds, median ) ); - Console::WriteLine( fmt, "ToDouble", Convert::ToDouble( ds, null ), Convert::ToDouble( ds, geMean ), Convert::ToDouble( ds, median ) ); - Console::WriteLine( fmt, "ToInt16", Convert::ToInt16( ds, null ), Convert::ToInt16( ds, geMean ), Convert::ToInt16( ds, median ) ); - Console::WriteLine( fmt, "ToInt32", Convert::ToInt32( ds, null ), Convert::ToInt32( ds, geMean ), Convert::ToInt32( ds, median ) ); - Console::WriteLine( fmt, "ToInt64", Convert::ToInt64( ds, null ), Convert::ToInt64( ds, geMean ), Convert::ToInt64( ds, median ) ); - Console::WriteLine( fmt, "ToSByte", Convert::ToSByte( ds, null ), Convert::ToSByte( ds, geMean ), Convert::ToSByte( ds, median ) ); - Console::WriteLine( fmt, "ToSingle", Convert::ToSingle( ds, null ), Convert::ToSingle( ds, geMean ), Convert::ToSingle( ds, median ) ); - Console::WriteLine( fmt, "ToUInt16", Convert::ToUInt16( ds, null ), Convert::ToUInt16( ds, geMean ), Convert::ToUInt16( ds, median ) ); - Console::WriteLine( fmt, "ToUInt32", Convert::ToUInt32( ds, null ), Convert::ToUInt32( ds, geMean ), Convert::ToUInt32( ds, median ) ); - Console::WriteLine( fmt, "ToUInt64", Convert::ToUInt64( ds, null ), Convert::ToUInt64( ds, geMean ), Convert::ToUInt64( ds, median ) ); -} - -int main() -{ - Console::WriteLine( "This example of the " - "Convert::To( Object*, IFormatProvider* ) methods " - "\ngenerates the following output. The example " - "displays the values \nreturned by the methods, " - "using several IFormatProvider objects.\n" ); - - // To call a [ParamArray] method in C++, you cannot just - // list the parameters, you need to build an array. - array^dataElem = gcnew array(6); - dataElem[ 0 ] = 10.5; - dataElem[ 1 ] = 22.2; - dataElem[ 2 ] = 45.9; - dataElem[ 3 ] = 88.7; - dataElem[ 4 ] = 156.05; - dataElem[ 5 ] = 297.6; - DataSet^ ds1 = gcnew DataSet( dataElem ); - DisplayDataSet( ds1 ); - dataElem = gcnew array(5); - dataElem[ 0 ] = 359999.95; - dataElem[ 1 ] = 425000; - dataElem[ 2 ] = 499999.5; - dataElem[ 3 ] = 775000; - dataElem[ 4 ] = 1695000; - DataSet^ ds2 = gcnew DataSet( dataElem ); - DisplayDataSet( ds2 ); -} - -/* -This example of the Convert::To( Object*, IFormatProvider* ) methods -generates the following output. The example displays the values -returned by the methods, using several IFormatProvider objects. - -DataSet: [10.5, 22.2, 45.9, 88.7, 156.05, 297.6] - -Convert:: Default Geometric Mean Median ---------- ------- -------------- ------ -ToBoolean True True True -ToByte 103 59 67 -ToChar g ; C -ToDateTime 2003-05-13 15:30:23 2003-05-13 15:29:39 2003-05-13 15:29:47 -ToDecimal 103.491666666667 59.4332135445164 67.3 -ToDouble 103.491666666667 59.4332135445164 67.3 -ToInt16 103 59 67 -ToInt32 103 59 67 -ToInt64 103 59 67 -ToSByte 103 59 67 -ToSingle 103.4917 59.43321 67.3 -ToUInt16 103 59 67 -ToUInt32 103 59 67 -ToUInt64 103 59 67 - -DataSet: [359999.95, 425000, 499999.5, 775000, 1695000] - -Convert:: Default Geometric Mean Median ---------- ------- -------------- ------ -ToBoolean True True True -ToByte 255 255 255 -ToChar ? ? ? -ToDateTime 2003-05-22 08:05:19 2003-05-20 22:54:57 2003-05-19 10:21:59 -ToDecimal 750999.89 631577.237188435 499999.5 -ToDouble 750999.89 631577.237188435 499999.5 -ToInt16 32767 32767 32767 -ToInt32 751000 631577 500000 -ToInt64 751000 631577 500000 -ToSByte 127 127 127 -ToSingle 750999.9 631577.3 499999.5 -ToUInt16 65535 65535 65535 -ToUInt32 751000 631577 500000 -ToUInt64 751000 631577 500000 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.DateTime.Date/cpp/date1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.DateTime.Date/cpp/date1.cpp deleted file mode 100644 index caf5fe1bc43..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.DateTime.Date/cpp/date1.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// -using namespace System; - -void main() -{ - DateTime^ date1 = gcnew DateTime(2008, 6, 1, 7, 47, 0); - Console::WriteLine(date1->ToString()); - - // Get date-only portion of date, without its time. - DateTime dateOnly = date1->Date; - // Display date using short date string. - Console::WriteLine(dateOnly.ToString("d")); - // Display date using 24-hour clock. - Console::WriteLine(dateOnly.ToString("g")); - Console::WriteLine(dateOnly.ToString(L"MM/dd/yyyy HH:mm")); -} -// The example displays the following output to the console: -// 6/1/2008 7:47:00 AM -// 6/1/2008 -// 6/1/2008 12:00 AM -// 06/01/2008 00:00 -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.DateTime.Minute etc/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.DateTime.Minute etc/CPP/class1.cpp deleted file mode 100644 index 1c991227a37..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.DateTime.Minute etc/CPP/class1.cpp +++ /dev/null @@ -1,31 +0,0 @@ -using namespace System; - -int main() -{ - // - System::DateTime moment = System::DateTime( - 1999, 1, 13, 3, 57, 32, 11 ); - - // Year gets 1999. - int year = moment.Year; - - // Month gets 1 (January). - int month = moment.Month; - - // Day gets 13. - int day = moment.Day; - - // Hour gets 3. - int hour = moment.Hour; - - // Minute gets 57. - int minute = moment.Minute; - - // Second gets 32. - int second = moment.Second; - - // Millisecond gets 11. - int millisecond = moment.Millisecond; - - // -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.DateTime.TryParse/cpp/datetime.tryparse1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.DateTime.TryParse/cpp/datetime.tryparse1.cpp deleted file mode 100644 index 26954f5c7f6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.DateTime.TryParse/cpp/datetime.tryparse1.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// DateTime.TryParse1.cpp : Defines the entry point for the console application. -// - -// -using namespace System; -using namespace System::Globalization; - -void main() -{ - array^ dateStrings = { "05/01/2009 14:57:32.8", "2009-05-01 14:57:32.8", - "2009-05-01T14:57:32.8375298-04:00", - "5/01/2008 14:57:32.80 -07:00", - "1 May 2008 2:57:32.8 PM", "16-05-2009 1:00:32 PM", - "Fri, 15 May 2009 20:10:57 GMT" }; - DateTime dateValue; - - Console::WriteLine("Attempting to parse strings using {0} culture.", - CultureInfo::CurrentCulture->Name); - for each (String^ dateString in dateStrings) - { - if (DateTime::TryParse(dateString, dateValue)) - Console::WriteLine(" Converted '{0}' to {1} ({2}).", dateString, - dateValue, dateValue.Kind); - else - Console::WriteLine(" Unable to parse '{0}'.", dateString); - } -} -// The example displays the following output: -// Attempting to parse strings using en-US culture. -// Converted '05/01/2009 14:57:32.8' to 5/1/2009 2:57:32 PM (Unspecified). -// Converted '2009-05-01 14:57:32.8' to 5/1/2009 2:57:32 PM (Unspecified). -// Converted '2009-05-01T14:57:32.8375298-04:00' to 5/1/2009 11:57:32 AM (Local). -// Converted '5/01/2008 14:57:32.80 -07:00' to 5/1/2008 2:57:32 PM (Local). -// Converted '1 May 2008 2:57:32.8 PM' to 5/1/2008 2:57:32 PM (Unspecified). -// Unable to parse '16-05-2009 1:00:32 PM'. -// Converted 'Fri, 15 May 2009 20:10:57 GMT' to 5/15/2009 1:10:57 PM (Local). -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Compare_Equals/CPP/comp_equal.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Compare_Equals/CPP/comp_equal.cpp deleted file mode 100644 index 224dd1602e1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Compare_Equals/CPP/comp_equal.cpp +++ /dev/null @@ -1,65 +0,0 @@ - -// -// Example of the Decimal::Compare and static Decimal::Equals methods. -using namespace System; -const __wchar_t * protoFmt = L"{0,-45}{1}"; - -// Compare Decimal parameters, and display them with the results. -void CompareDecimals( Decimal Left, Decimal Right, String^ RightText ) -{ - String^ dataFmt = gcnew String( protoFmt ); - Console::WriteLine(); - Console::WriteLine( dataFmt, String::Concat( "Right: ", RightText ), Right ); - Console::WriteLine( dataFmt, "Decimal::Equals( Left, Right )", Decimal::Equals( Left, Right ) ); - Console::WriteLine( dataFmt, "Decimal::Compare( Left, Right )", Decimal::Compare( Left, Right ) ); -} - -int main() -{ - Console::WriteLine( "This example of the Decimal::Equals( Decimal, Decimal " - ") and \nDecimal::Compare( Decimal, Decimal ) " - "methods generates the \nfollowing output. It creates " - "several different Decimal \nvalues and compares them " - "with the following reference value.\n" ); - - // Create a reference Decimal value. - Decimal Left = Decimal(123.456); - Console::WriteLine( gcnew String( protoFmt ), "Left: Decimal( 123.456 )", Left ); - - // Create Decimal values to compare with the reference. - CompareDecimals( Left, Decimal(1.2345600E+2), "Decimal( 1.2345600E+2 )" ); - CompareDecimals( Left, Decimal::Parse( "123.4561" ), "Decimal::Parse( \"123.4561\" )" ); - CompareDecimals( Left, Decimal::Parse( "123.4559" ), "Decimal::Parse( \"123.4559\" )" ); - CompareDecimals( Left, Decimal::Parse( "123.456000" ), "Decimal::Parse( \"123.456000\" )" ); - CompareDecimals( Left, Decimal(123456000,0,0,false,6), "Decimal( 123456000, 0, 0, false, 6 )" ); -} - -/* -This example of the Decimal::Equals( Decimal, Decimal ) and -Decimal::Compare( Decimal, Decimal ) methods generates the -following output. It creates several different Decimal -values and compares them with the following reference value. - -Left: Decimal( 123.456 ) 123.456 - -Right: Decimal( 1.2345600E+2 ) 123.456 -Decimal::Equals( Left, Right ) True -Decimal::Compare( Left, Right ) 0 - -Right: Decimal::Parse( "123.4561" ) 123.4561 -Decimal::Equals( Left, Right ) False -Decimal::Compare( Left, Right ) -1 - -Right: Decimal::Parse( "123.4559" ) 123.4559 -Decimal::Equals( Left, Right ) False -Decimal::Compare( Left, Right ) 1 - -Right: Decimal::Parse( "123.456000" ) 123.456000 -Decimal::Equals( Left, Right ) True -Decimal::Compare( Left, Right ) 0 - -Right: Decimal( 123456000, 0, 0, false, 6 ) 123.456000 -Decimal::Equals( Left, Right ) True -Decimal::Compare( Left, Right ) 0 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Compare_Equals/CPP/cto_eq_obj.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Compare_Equals/CPP/cto_eq_obj.cpp deleted file mode 100644 index e155f61c420..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Compare_Equals/CPP/cto_eq_obj.cpp +++ /dev/null @@ -1,88 +0,0 @@ - -// -// Example of the Decimal::CompareTo and Decimal::Equals instance -// methods. -using namespace System; - -// Get the exception type name; remove the namespace prefix. -String^ GetExceptionType( Exception^ ex ) -{ - String^ exceptionType = ex->GetType()->ToString(); - return exceptionType->Substring( exceptionType->LastIndexOf( '.' ) + 1 ); -} - - -// Compare the Decimal to the Object parameters, -// and display the Object parameters with the results. -void CompDecimalToObject( Decimal Left, Object^ Right, String^ RightText ) -{ - Console::WriteLine( "{0,-46}{1}", String::Concat( "Object: ", RightText ), Right ); - Console::WriteLine( "{0,-46}{1}", "Left.Equals( Object )", Left.Equals( Right ) ); - Console::Write( "{0,-46}", "Left.CompareTo( Object )" ); - try - { - - // Catch the exception if CompareTo( ) throws one. - Console::WriteLine( "{0}\n", Left.CompareTo( Right ) ); - } - catch ( Exception^ ex ) - { - Console::WriteLine( "{0}\n", GetExceptionType( ex ) ); - } - -} - -int main() -{ - Console::WriteLine( "This example of the Decimal::Equals( Object* ) and \n" - "Decimal::CompareTo( Object* ) methods generates the \n" - "following output. It creates several different " - "Decimal \nvalues and compares them with the following " - "reference value.\n" ); - - // Create a reference Decimal value. - Decimal Left = Decimal(987.654); - Console::WriteLine( "{0,-46}{1}\n", "Left: Decimal( 987.654 )", Left ); - - // Create objects to compare with the reference. - CompDecimalToObject( Left, Decimal(9.8765400E+2), "Decimal( 9.8765400E+2 )" ); - CompDecimalToObject( Left, Decimal::Parse( "987.6541" ), "Decimal::Parse( \"987.6541\" )" ); - CompDecimalToObject( Left, Decimal::Parse( "987.6539" ), "Decimal::Parse( \"987.6539\" )" ); - CompDecimalToObject( Left, Decimal(987654000,0,0,false,6), "Decimal( 987654000, 0, 0, false, 6 )" ); - CompDecimalToObject( Left, 9.8765400E+2, "Double 9.8765400E+2" ); - CompDecimalToObject( Left, "987.654", "String \"987.654\"" ); -} - -/* -This example of the Decimal::Equals( Object* ) and -Decimal::CompareTo( Object* ) methods generates the -following output. It creates several different Decimal -values and compares them with the following reference value. - -Left: Decimal( 987.654 ) 987.654 - -Object: Decimal( 9.8765400E+2 ) 987.654 -Left.Equals( Object ) True -Left.CompareTo( Object ) 0 - -Object: Decimal::Parse( "987.6541" ) 987.6541 -Left.Equals( Object ) False -Left.CompareTo( Object ) -1 - -Object: Decimal::Parse( "987.6539" ) 987.6539 -Left.Equals( Object ) False -Left.CompareTo( Object ) 1 - -Object: Decimal( 987654000, 0, 0, false, 6 ) 987.654000 -Left.Equals( Object ) True -Left.CompareTo( Object ) 0 - -Object: Double 9.8765400E+2 987.654 -Left.Equals( Object ) False -Left.CompareTo( Object ) ArgumentException - -Object: String "987.654" 987.654 -Left.Equals( Object ) False -Left.CompareTo( Object ) ArgumentException -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Arrays/CPP/ctoriarr.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Arrays/CPP/ctoriarr.cpp deleted file mode 100644 index 52935e71178..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Arrays/CPP/ctoriarr.cpp +++ /dev/null @@ -1,117 +0,0 @@ - -// -// Example of the Decimal( int __gc [ ] ) constructor. -using namespace System; - -// Get the exception type name; remove the namespace prefix. -String^ GetExceptionType( Exception^ ex ) -{ - String^ exceptionType = ex->GetType()->ToString(); - return exceptionType->Substring( exceptionType->LastIndexOf( '.' ) + 1 ); -} - - -// Create a Decimal object and display its value. -void CreateDecimal( array^bits ) -{ - - // Format the constructor for display. - String^ ctor = String::Format( "Decimal( {{ 0x{0:X}", bits[ 0 ] ); - String^ valOrExc; - for ( int index = 1; index < bits->Length; index++ ) - ctor = String::Concat( ctor, String::Format( ", 0x{0:X}", bits[ index ] ) ); - ctor = String::Concat( ctor, " } )" ); - try - { - - // Construct the Decimal value. - Decimal decimalNum = Decimal(bits); - - // Format the Decimal value for display. - valOrExc = decimalNum.ToString(); - } - catch ( Exception^ ex ) - { - - // Save the exception type if an exception was thrown. - valOrExc = GetExceptionType( ex ); - } - - - // Display the constructor and Decimal value or exception. - int ctorLen = 76 - valOrExc->Length; - - // Display the data on one line if it will fit. - if ( ctorLen > ctor->Length ) - Console::WriteLine( "{0}{1}", ctor->PadRight( ctorLen ), valOrExc ); - // Otherwise, display the data on two lines. - else - { - Console::WriteLine( "{0}", ctor ); - Console::WriteLine( "{0,76}", valOrExc ); - } -} - -int main() -{ - Console::WriteLine( "This example of the Decimal( int __gc [ ] ) " - "constructor \ngenerates the following output.\n" ); - Console::WriteLine( "{0,-38}{1,38}", "Constructor", "Value or Exception" ); - Console::WriteLine( "{0,-38}{1,38}", "-----------", "------------------" ); - - // Construct Decimal objects from integer arrays. - array^zero = {0,0,0,0}; - CreateDecimal( zero ); - array^arrayShort = {0,0,0}; - CreateDecimal( arrayShort ); - array^arrayLong = {0,0,0,0,0}; - CreateDecimal( arrayLong ); - array^word0Data = {1000000000,0,0,0}; - CreateDecimal( word0Data ); - array^word1Data = {0,1000000000,0,0}; - CreateDecimal( word1Data ); - array^word2Data = {0,0,1000000000,0}; - CreateDecimal( word2Data ); - array^word3Data = {0,0,0,1000000000}; - CreateDecimal( word3Data ); - array^decMax = { -1,-1,-1,0}; - CreateDecimal( decMax ); - array^decMin = { -1,-1,-1,0x80000000}; - CreateDecimal( decMin ); - array^fracDig16 = { -1,0,0,0x100000}; - CreateDecimal( fracDig16 ); - array^fracDig28 = { -1,0,0,0x1C0000}; - CreateDecimal( fracDig28 ); - array^fracDig29 = { -1,0,0,0x1D0000}; - CreateDecimal( fracDig29 ); - array^reserved = { -1,0,0,0x1C0001}; - CreateDecimal( reserved ); - array^Same4Words = {0xF0000,0xF0000,0xF0000,0xF0000}; - CreateDecimal( Same4Words ); -} - -/* -This example of the Decimal( int __gc [ ] ) constructor -generates the following output. - -Constructor Value or Exception ------------ ------------------ -Decimal( { 0x0, 0x0, 0x0, 0x0 } ) 0 -Decimal( { 0x0, 0x0, 0x0 } ) ArgumentException -Decimal( { 0x0, 0x0, 0x0, 0x0, 0x0 } ) ArgumentException -Decimal( { 0x3B9ACA00, 0x0, 0x0, 0x0 } ) 1000000000 -Decimal( { 0x0, 0x3B9ACA00, 0x0, 0x0 } ) 4294967296000000000 -Decimal( { 0x0, 0x0, 0x3B9ACA00, 0x0 } ) 18446744073709551616000000000 -Decimal( { 0x0, 0x0, 0x0, 0x3B9ACA00 } ) ArgumentException -Decimal( { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0 } ) - 79228162514264337593543950335 -Decimal( { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x80000000 } ) - -79228162514264337593543950335 -Decimal( { 0xFFFFFFFF, 0x0, 0x0, 0x100000 } ) 0.0000004294967295 -Decimal( { 0xFFFFFFFF, 0x0, 0x0, 0x1C0000 } ) 0.0000000000000000004294967295 -Decimal( { 0xFFFFFFFF, 0x0, 0x0, 0x1D0000 } ) ArgumentException -Decimal( { 0xFFFFFFFF, 0x0, 0x0, 0x1C0001 } ) ArgumentException -Decimal( { 0xF0000, 0xF0000, 0xF0000, 0xF0000 } ) - 18133887298.441562272235520 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Arrays/CPP/ctoriiibby.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Arrays/CPP/ctoriiibby.cpp deleted file mode 100644 index c0aef542fb3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Arrays/CPP/ctoriiibby.cpp +++ /dev/null @@ -1,108 +0,0 @@ - -// -// Example of the Decimal( int, int, int, bool, unsigned char ) -// constructor. -using namespace System; - -// Get the exception type name; remove the namespace prefix. -String^ GetExceptionType( Exception^ ex ) -{ - String^ exceptionType = ex->GetType()->ToString(); - return exceptionType->Substring( exceptionType->LastIndexOf( '.' ) + 1 ); -} - - -// Create a Decimal object and display its value. -void CreateDecimal( int low, int mid, int high, bool isNeg, unsigned char scale ) -{ - - // Format the constructor for display. - array^boxedParams = gcnew array(5); - boxedParams[ 0 ] = low; - boxedParams[ 1 ] = mid; - boxedParams[ 2 ] = high; - boxedParams[ 3 ] = isNeg; - boxedParams[ 4 ] = scale; - String^ ctor = String::Format( "Decimal( {0}, {1}, {2}, {3}, {4} )", boxedParams ); - String^ valOrExc; - try - { - - // Construct the Decimal value. - Decimal decimalNum = Decimal(low,mid,high,isNeg,scale); - - // Format and save the Decimal value. - valOrExc = decimalNum.ToString(); - } - catch ( Exception^ ex ) - { - - // Save the exception type if an exception was thrown. - valOrExc = GetExceptionType( ex ); - } - - - // Display the constructor and Decimal value or exception. - int ctorLen = 76 - valOrExc->Length; - - // Display the data on one line if it will fit. - if ( ctorLen > ctor->Length ) - Console::WriteLine( "{0}{1}", ctor->PadRight( ctorLen ), valOrExc ); - // Otherwise, display the data on two lines. - else - { - Console::WriteLine( "{0}", ctor ); - Console::WriteLine( "{0,76}", valOrExc ); - } -} - -int main() -{ - Console::WriteLine( "This example of the Decimal( int, int, " - "int, bool, unsigned char ) \nconstructor " - "generates the following output.\n" ); - Console::WriteLine( "{0,-38}{1,38}", "Constructor", "Value or Exception" ); - Console::WriteLine( "{0,-38}{1,38}", "-----------", "------------------" ); - - // Construct Decimal objects from double values. - CreateDecimal( 0, 0, 0, false, 0 ); - CreateDecimal( 0, 0, 0, false, 27 ); - CreateDecimal( 0, 0, 0, true, 0 ); - CreateDecimal( 1000000000, 0, 0, false, 0 ); - CreateDecimal( 0, 1000000000, 0, false, 0 ); - CreateDecimal( 0, 0, 1000000000, false, 0 ); - CreateDecimal( 1000000000, 1000000000, 1000000000, false, 0 ); - CreateDecimal( -1, -1, -1, false, 0 ); - CreateDecimal( -1, -1, -1, true, 0 ); - CreateDecimal( -1, -1, -1, false, 15 ); - CreateDecimal( -1, -1, -1, false, 28 ); - CreateDecimal( -1, -1, -1, false, 29 ); - CreateDecimal( Int32::MaxValue, 0, 0, false, 18 ); - CreateDecimal( Int32::MaxValue, 0, 0, false, 28 ); - CreateDecimal( Int32::MaxValue, 0, 0, true, 28 ); -} - -/* -This example of the Decimal( int, int, int, bool, unsigned char ) -constructor generates the following output. - -Constructor Value or Exception ------------ ------------------ -Decimal( 0, 0, 0, False, 0 ) 0 -Decimal( 0, 0, 0, False, 27 ) 0 -Decimal( 0, 0, 0, True, 0 ) 0 -Decimal( 1000000000, 0, 0, False, 0 ) 1000000000 -Decimal( 0, 1000000000, 0, False, 0 ) 4294967296000000000 -Decimal( 0, 0, 1000000000, False, 0 ) 18446744073709551616000000000 -Decimal( 1000000000, 1000000000, 1000000000, False, 0 ) - 18446744078004518913000000000 -Decimal( -1, -1, -1, False, 0 ) 79228162514264337593543950335 -Decimal( -1, -1, -1, True, 0 ) -79228162514264337593543950335 -Decimal( -1, -1, -1, False, 15 ) 79228162514264.337593543950335 -Decimal( -1, -1, -1, False, 28 ) 7.9228162514264337593543950335 -Decimal( -1, -1, -1, False, 29 ) ArgumentOutOfRangeException -Decimal( 2147483647, 0, 0, False, 18 ) 0.000000002147483647 -Decimal( 2147483647, 0, 0, False, 28 ) 0.0000000000000000002147483647 -Decimal( 2147483647, 0, 0, True, 28 ) -0.0000000000000000002147483647 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Ints/CPP/ctori.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Ints/CPP/ctori.cpp deleted file mode 100644 index ecdc7081878..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Ints/CPP/ctori.cpp +++ /dev/null @@ -1,47 +0,0 @@ - -// -// Example of the Decimal( int ) constructor. -using namespace System; - -// Create a Decimal object and display its value. -void CreateDecimal( int value, String^ valToStr ) -{ - Decimal decimalNum = Decimal(value); - - // Format the constructor for display. - String^ ctor = String::Format( "Decimal( {0} )", valToStr ); - - // Display the constructor and its value. - Console::WriteLine( "{0,-30}{1,16}", ctor, decimalNum ); -} - -int main() -{ - Console::WriteLine( "This example of the Decimal( int ) " - "constructor \ngenerates the following output.\n" ); - Console::WriteLine( "{0,-30}{1,16}", "Constructor", "Value" ); - Console::WriteLine( "{0,-30}{1,16}", "-----------", "-----" ); - - // Construct Decimal objects from int values. - CreateDecimal( Int32::MinValue, "Int32::MinValue" ); - CreateDecimal( Int32::MaxValue, "Int32::MaxValue" ); - CreateDecimal( 0, "0" ); - CreateDecimal( 999999999, "999999999" ); - CreateDecimal( 0x40000000, "0x40000000" ); - CreateDecimal( (int)0xC0000000, "(int)0xC0000000" ); -} - -/* -This example of the Decimal( int ) constructor -generates the following output. - -Constructor Value ------------ ----- -Decimal( Int32::MinValue ) -2147483648 -Decimal( Int32::MaxValue ) 2147483647 -Decimal( 0 ) 0 -Decimal( 999999999 ) 999999999 -Decimal( 0x40000000 ) 1073741824 -Decimal( (int)0xC0000000 ) -1073741824 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Ints/CPP/ctorl.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Ints/CPP/ctorl.cpp deleted file mode 100644 index 1e66c122bf6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Ints/CPP/ctorl.cpp +++ /dev/null @@ -1,47 +0,0 @@ - -// -// Example of the Decimal( __int64 ) constructor. -using namespace System; - -// Create a Decimal object and display its value. -void CreateDecimal( __int64 value, String^ valToStr ) -{ - Decimal decimalNum = Decimal(value); - - // Format the constructor for display. - String^ ctor = String::Format( "Decimal( {0} )", valToStr ); - - // Display the constructor and its value. - Console::WriteLine( "{0,-35}{1,22}", ctor, decimalNum ); -} - -int main() -{ - Console::WriteLine( "This example of the Decimal( __int64 ) " - "constructor \ngenerates the following output.\n" ); - Console::WriteLine( "{0,-35}{1,22}", "Constructor", "Value" ); - Console::WriteLine( "{0,-35}{1,22}", "-----------", "-----" ); - - // Construct Decimal objects from __int64 values. - CreateDecimal( Int64::MinValue, "Int64::MinValue" ); - CreateDecimal( Int64::MaxValue, "Int64::MaxValue" ); - CreateDecimal( 0, "0" ); - CreateDecimal( 999999999999999999, "999999999999999999" ); - CreateDecimal( 0x2000000000000000, "0x2000000000000000" ); - CreateDecimal( 0xE000000000000000, "0xE000000000000000" ); -} - -/* -This example of the Decimal( __int64 ) constructor -generates the following output. - -Constructor Value ------------ ----- -Decimal( Int64::MinValue ) -9223372036854775808 -Decimal( Int64::MaxValue ) 9223372036854775807 -Decimal( 0 ) 0 -Decimal( 999999999999999999 ) 999999999999999999 -Decimal( 0x2000000000000000 ) 2305843009213693952 -Decimal( 0xE000000000000000 ) -2305843009213693952 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Ints/CPP/ctorui.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Ints/CPP/ctorui.cpp deleted file mode 100644 index 4882d3004fb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Ints/CPP/ctorui.cpp +++ /dev/null @@ -1,47 +0,0 @@ - -// -// Example of the Decimal( unsigned int ) constructor. -using namespace System; - -// Create a Decimal object and display its value. -void CreateDecimal( unsigned int value, String^ valToStr ) -{ - Decimal decimalNum = Decimal(value); - - // Format the constructor for display. - String^ ctor = String::Format( "Decimal( {0} )", valToStr ); - - // Display the constructor and its value. - Console::WriteLine( "{0,-30}{1,16}", ctor, decimalNum ); -} - -int main() -{ - Console::WriteLine( "This example of the Decimal( unsigned " - "int ) constructor \ngenerates the following output.\n" ); - Console::WriteLine( "{0,-30}{1,16}", "Constructor", "Value" ); - Console::WriteLine( "{0,-30}{1,16}", "-----------", "-----" ); - - // Construct Decimal objects from unsigned int values. - CreateDecimal( UInt32::MinValue, "UInt32::MinValue" ); - CreateDecimal( UInt32::MaxValue, "UInt32::MaxValue" ); - CreateDecimal( Int32::MaxValue, "Int32::MaxValue" ); - CreateDecimal( 999999999, "999999999" ); - CreateDecimal( 0x40000000, "0x40000000" ); - CreateDecimal( 0xC0000000, "0xC0000000" ); -} - -/* -This example of the Decimal( unsigned int ) constructor -generates the following output. - -Constructor Value ------------ ----- -Decimal( UInt32::MinValue ) 0 -Decimal( UInt32::MaxValue ) 4294967295 -Decimal( Int32::MaxValue ) 2147483647 -Decimal( 999999999 ) 999999999 -Decimal( 0x40000000 ) 1073741824 -Decimal( 0xC0000000 ) 3221225472 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Ints/CPP/ctorul.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Ints/CPP/ctorul.cpp deleted file mode 100644 index d09060bdbb9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Ints/CPP/ctorul.cpp +++ /dev/null @@ -1,47 +0,0 @@ - -// -// Example of the Decimal( unsigned __int64 ) constructor. -using namespace System; - -// Create a Decimal object and display its value. -void CreateDecimal( unsigned __int64 value, String^ valToStr ) -{ - Decimal decimalNum = Decimal(value); - - // Format the constructor for display. - String^ ctor = String::Format( "Decimal( {0} )", valToStr ); - - // Display the constructor and its value. - Console::WriteLine( "{0,-33}{1,22}", ctor, decimalNum ); -} - -int main() -{ - Console::WriteLine( "This example of the Decimal( unsigned " - "__int64 ) constructor \ngenerates the following output.\n" ); - Console::WriteLine( "{0,-33}{1,22}", "Constructor", "Value" ); - Console::WriteLine( "{0,-33}{1,22}", "-----------", "-----" ); - - // Construct Decimal objects from unsigned __int64 values. - CreateDecimal( UInt64::MinValue, "UInt64::MinValue" ); - CreateDecimal( UInt64::MaxValue, "UInt64::MaxValue" ); - CreateDecimal( Int64::MaxValue, "Int64::MaxValue" ); - CreateDecimal( 999999999999999999, "999999999999999999" ); - CreateDecimal( 0x2000000000000000, "0x2000000000000000" ); - CreateDecimal( 0xE000000000000000, "0xE000000000000000" ); -} - -/* -This example of the Decimal( unsigned __int64 ) constructor -generates the following output. - -Constructor Value ------------ ----- -Decimal( UInt64::MinValue ) 0 -Decimal( UInt64::MaxValue ) 18446744073709551615 -Decimal( Int64::MaxValue ) 9223372036854775807 -Decimal( 999999999999999999 ) 999999999999999999 -Decimal( 0x2000000000000000 ) 2305843009213693952 -Decimal( 0xE000000000000000 ) 16140901064495857664 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Reals/CPP/ctordo.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Reals/CPP/ctordo.cpp deleted file mode 100644 index 3ffa533351d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Reals/CPP/ctordo.cpp +++ /dev/null @@ -1,73 +0,0 @@ - -// -// Example of the Decimal( double ) constructor. -using namespace System; - -// Get the exception type name; remove the namespace prefix. -String^ GetExceptionType( Exception^ ex ) -{ - String^ exceptionType = ex->GetType()->ToString(); - return exceptionType->Substring( exceptionType->LastIndexOf( '.' ) + 1 ); -} - - -// Create a Decimal object and display its value. -void CreateDecimal( double value, String^ valToStr ) -{ - - // Format and display the constructor. - Console::Write( "{0,-34}", String::Format( "Decimal( {0} )", valToStr ) ); - try - { - - // Construct the Decimal value. - Decimal decimalNum = Decimal(value); - - // Display the value if it was created successfully. - Console::WriteLine( "{0,31}", decimalNum ); - } - catch ( Exception^ ex ) - { - - // Display the exception type if an exception was thrown. - Console::WriteLine( "{0,31}", GetExceptionType( ex ) ); - } - -} - -int main() -{ - Console::WriteLine( "This example of the Decimal( double ) " - "constructor \ngenerates the following output.\n" ); - Console::WriteLine( "{0,-34}{1,31}", "Constructor", "Value or Exception" ); - Console::WriteLine( "{0,-34}{1,31}", "-----------", "------------------" ); - - // Construct Decimal objects from double values. - CreateDecimal( 1.23456789E+5, "1.23456789E+5" ); - CreateDecimal( 1.234567890123E+15, "1.234567890123E+15" ); - CreateDecimal( 1.2345678901234567E+25, "1.2345678901234567E+25" ); - CreateDecimal( 1.2345678901234567E+35, "1.2345678901234567E+35" ); - CreateDecimal( 1.23456789E-5, "1.23456789E-5" ); - CreateDecimal( 1.234567890123E-15, "1.234567890123E-15" ); - CreateDecimal( 1.2345678901234567E-25, "1.2345678901234567E-25" ); - CreateDecimal( 1.2345678901234567E-35, "1.2345678901234567E-35" ); - CreateDecimal( 1.0 / 7.0, "1.0 / 7.0" ); -} - -/* -This example of the Decimal( double ) constructor -generates the following output. - -Constructor Value or Exception ------------ ------------------ -Decimal( 1.23456789E+5 ) 123456.789 -Decimal( 1.234567890123E+15 ) 1234567890123000 -Decimal( 1.2345678901234567E+25 ) 12345678901234600000000000 -Decimal( 1.2345678901234567E+35 ) OverflowException -Decimal( 1.23456789E-5 ) 0.0000123456789 -Decimal( 1.234567890123E-15 ) 0.000000000000001234567890123 -Decimal( 1.2345678901234567E-25 ) 0.0000000000000000000000001235 -Decimal( 1.2345678901234567E-35 ) 0 -Decimal( 1.0 / 7.0 ) 0.142857142857143 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Reals/CPP/ctors.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Reals/CPP/ctors.cpp deleted file mode 100644 index f2052b72799..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Reals/CPP/ctors.cpp +++ /dev/null @@ -1,73 +0,0 @@ - -// -// Example of the Decimal( float ) constructor. -using namespace System; - -// Get the exception type name; remove the namespace prefix. -String^ GetExceptionType( Exception^ ex ) -{ - String^ exceptionType = ex->GetType()->ToString(); - return exceptionType->Substring( exceptionType->LastIndexOf( '.' ) + 1 ); -} - - -// Create a Decimal object and display its value. -void CreateDecimal( float value, String^ valToStr ) -{ - - // Format and display the constructor. - Console::Write( "{0,-27}", String::Format( "Decimal( {0} )", valToStr ) ); - try - { - - // Construct the Decimal value. - Decimal decimalNum = Decimal(value); - - // Display the value if it was created successfully. - Console::WriteLine( "{0,31}", decimalNum ); - } - catch ( Exception^ ex ) - { - - // Display the exception type if an exception was thrown. - Console::WriteLine( "{0,31}", GetExceptionType( ex ) ); - } - -} - -int main() -{ - Console::WriteLine( "This example of the Decimal( float ) " - "constructor \ngenerates the following output.\n" ); - Console::WriteLine( "{0,-27}{1,31}", "Constructor", "Value or Exception" ); - Console::WriteLine( "{0,-27}{1,31}", "-----------", "------------------" ); - - // Construct Decimal objects from float values. - CreateDecimal( 1.2345E+5, "1.2345E+5" ); - CreateDecimal( 1.234567E+15, "1.234567E+15" ); - CreateDecimal( 1.23456789E+25, "1.23456789E+25" ); - CreateDecimal( 1.23456789E+35, "1.23456789E+35" ); - CreateDecimal( 1.2345E-5, "1.2345E-5" ); - CreateDecimal( 1.234567E-15, "1.234567E-15" ); - CreateDecimal( 1.23456789E-25, "1.23456789E-25" ); - CreateDecimal( 1.23456789E-35, "1.23456789E-35" ); - CreateDecimal( 1.0 / 7.0, "1.0 / 7.0" ); -} - -/* -This example of the Decimal( float ) constructor -generates the following output. - -Constructor Value or Exception ------------ ------------------ -Decimal( 1.2345E+5 ) 123450 -Decimal( 1.234567E+15 ) 1234567000000000 -Decimal( 1.23456789E+25 ) 12345680000000000000000000 -Decimal( 1.23456789E+35 ) OverflowException -Decimal( 1.2345E-5 ) 0.000012345 -Decimal( 1.234567E-15 ) 0.000000000000001234567 -Decimal( 1.23456789E-25 ) 0.0000000000000000000000001235 -Decimal( 1.23456789E-35 ) 0 -Decimal( 1.0 / 7.0 ) 0.1428571 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Fields/CPP/fields.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Fields/CPP/fields.cpp deleted file mode 100644 index 7f0743a1a5e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Fields/CPP/fields.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -// -// Example of the Decimal fields. -using namespace System; -int main() -{ - String^ numberFmt = "{0,-25}{1,45:N0}"; - String^ exprFmt = "{0,-55}{1,15}"; - Console::WriteLine( "This example of the fields of the Decimal structure " - "\ngenerates the following output.\n" ); - Console::WriteLine( numberFmt, "Field or Expression", "Value" ); - Console::WriteLine( numberFmt, "-------------------", "-----" ); - - // Display the values of the Decimal fields. - Console::WriteLine( numberFmt, "Decimal::MaxValue", Decimal::MaxValue ); - Console::WriteLine( numberFmt, "Decimal::MinValue", Decimal::MinValue ); - Console::WriteLine( numberFmt, "Decimal::MinusOne", Decimal::MinusOne ); - Console::WriteLine( numberFmt, "Decimal::One", Decimal::One ); - Console::WriteLine( numberFmt, "Decimal::Zero", Decimal::Zero ); - Console::WriteLine(); - - // Display the values of expressions of the Decimal fields. - Console::WriteLine( exprFmt, "( Decimal::MinusOne + Decimal::One ) == Decimal::Zero", (Decimal::MinusOne + Decimal::One) == Decimal::Zero ); - Console::WriteLine( exprFmt, "Decimal::MaxValue + Decimal::MinValue", Decimal::MaxValue + Decimal::MinValue ); - Console::WriteLine( exprFmt, "Decimal::MinValue / Decimal::MaxValue", Decimal::MinValue / Decimal::MaxValue ); - Console::WriteLine( "{0,-40}{1,30}", "100000000000000M / Decimal::MaxValue", Convert::ToDecimal( 100000000000000 ) / Decimal::MaxValue ); -} - -/* -This example of the fields of the Decimal structure -generates the following output. - -Field or Expression Value -------------------- ----- -Decimal::MaxValue 79,228,162,514,264,337,593,543,950,335 -Decimal::MinValue -79,228,162,514,264,337,593,543,950,335 -Decimal::MinusOne -1 -Decimal::One 1 -Decimal::Zero 0 - -( Decimal::MinusOne + Decimal::One ) == Decimal::Zero True -Decimal::MaxValue + Decimal::MinValue 0 -Decimal::MinValue / Decimal::MaxValue -1 -100000000000000M / Decimal::MaxValue 0.0000000000000012621774483536 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Flr_Neg_Rnd_Trnc/CPP/floor_neg_trunc.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Flr_Neg_Rnd_Trnc/CPP/floor_neg_trunc.cpp deleted file mode 100644 index 5ec1281cf67..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Flr_Neg_Rnd_Trnc/CPP/floor_neg_trunc.cpp +++ /dev/null @@ -1,66 +0,0 @@ - -// -// Example of the Decimal::Negate, Decimal::Floor, and -// Decimal::Truncate methods. -using namespace System; - -// Display Decimal parameters and the method results. -void ShowDecimalFloorNegTrunc( Decimal Argument ) -{ - String^ dataFmt = "{0,-30}{1,26}"; - Console::WriteLine(); - Console::WriteLine( dataFmt, "Decimal Argument", Argument ); - Console::WriteLine( dataFmt, "Decimal::Negate( Argument )", Decimal::Negate( Argument ) ); - Console::WriteLine( dataFmt, "Decimal::Floor( Argument )", Decimal::Floor( Argument ) ); - Console::WriteLine( dataFmt, "Decimal::Truncate( Argument )", Decimal::Truncate( Argument ) ); -} - -int main() -{ - Console::WriteLine( "This example of the \n" - " Decimal::Negate( Decimal ), \n" - " Decimal::Floor( Decimal ), and \n" - " Decimal::Truncate( Decimal ) \n" - "methods generates the following output." ); - - // Create pairs of Decimal objects. - ShowDecimalFloorNegTrunc( Decimal::Parse( "0" ) ); - ShowDecimalFloorNegTrunc( Decimal::Parse( "123.456" ) ); - ShowDecimalFloorNegTrunc( Decimal::Parse( "-123.456" ) ); - ShowDecimalFloorNegTrunc( Decimal(1230000000,0,0,true,7) ); - ShowDecimalFloorNegTrunc( Decimal::Parse( "-9999999999.9999999999" ) ); -} - -/* -This example of the - Decimal::Negate( Decimal ), - Decimal::Floor( Decimal ), and - Decimal::Truncate( Decimal ) -methods generates the following output. - -Decimal Argument 0 -Decimal::Negate( Argument ) 0 -Decimal::Floor( Argument ) 0 -Decimal::Truncate( Argument ) 0 - -Decimal Argument 123.456 -Decimal::Negate( Argument ) -123.456 -Decimal::Floor( Argument ) 123 -Decimal::Truncate( Argument ) 123 - -Decimal Argument -123.456 -Decimal::Negate( Argument ) 123.456 -Decimal::Floor( Argument ) -124 -Decimal::Truncate( Argument ) -123 - -Decimal Argument -123.0000000 -Decimal::Negate( Argument ) 123.0000000 -Decimal::Floor( Argument ) -123 -Decimal::Truncate( Argument ) -123 - -Decimal Argument -9999999999.9999999999 -Decimal::Negate( Argument ) 9999999999.9999999999 -Decimal::Floor( Argument ) -10000000000 -Decimal::Truncate( Argument ) -9999999999 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Get_Bits_Hash_Type/CPP/getbits.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Get_Bits_Hash_Type/CPP/getbits.cpp deleted file mode 100644 index ac862b815f9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Get_Bits_Hash_Type/CPP/getbits.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// -using namespace System; - -int main() -{ - // Define an array of Decimal values. - array^ values = gcnew array { Decimal::One, - Decimal::Parse("100000000000000"), - Decimal::Parse("10000000000000000000000000000"), - Decimal::Parse("100000000000000.00000000000000"), - Decimal::Parse("1.0000000000000000000000000000"), - Decimal::Parse("123456789"), - Decimal::Parse("0.123456789"), - Decimal::Parse("0.000000000123456789"), - Decimal::Parse("0.000000000000000000123456789"), - Decimal::Parse("4294967295.0"), - Decimal::Parse("18446744073709551615.0"), - Decimal::MaxValue, Decimal::MinValue, - Decimal::Parse("-7.9228162514264337593543950335") }; - - Console::WriteLine("{0,31} {1,10:X8}{2,10:X8}{3,10:X8}{4,10:X8}", - "Argument", "Bits[3]", "Bits[2]", "Bits[1]", "Bits[0]" ); - Console::WriteLine("{0,31} {1,10:X8}{2,10:X8}{3,10:X8}{4,10:X8}", - "--------", "-------", "-------", "-------", "-------" ); - - for each (Decimal value in values) - { - array^ bits = Decimal::GetBits(value); - Console::WriteLine("{0,31} {1,10:X8}{2,10:X8}{3,10:X8}{4,10:X8}", - value, bits[3], bits[2], bits[1], bits[0] ); - } -} - -/* -This example of the Decimal::GetBits( Decimal ) method -generates the following output. It displays the argument -as a Decimal and the result array in hexadecimal. - - Argument Bits[3] Bits[2] Bits[1] Bits[0] - -------- ------- ------- ------- ------- - 1 00000000 00000000 00000000 00000001 - 100000000000000 00000000 00000000 00005AF3 107A4000 - 10000000000000000000000000000 00000000 204FCE5E 3E250261 10000000 - 100000000000000.00000000000000 000E0000 204FCE5E 3E250261 10000000 - 1.0000000000000000000000000000 001C0000 204FCE5E 3E250261 10000000 - 123456789 00000000 00000000 00000000 075BCD15 - 0.123456789 00090000 00000000 00000000 075BCD15 - 0.000000000123456789 00120000 00000000 00000000 075BCD15 - 0.000000000000000000123456789 001B0000 00000000 00000000 075BCD15 - 4294967295 00000000 00000000 00000000 FFFFFFFF - 18446744073709551615 00000000 00000000 FFFFFFFF FFFFFFFF - 79228162514264337593543950335 00000000 FFFFFFFF FFFFFFFF FFFFFFFF - -79228162514264337593543950335 80000000 FFFFFFFF FFFFFFFF FFFFFFFF --7.9228162514264337593543950335 801C0000 FFFFFFFF FFFFFFFF FFFFFFFF -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Get_Bits_Hash_Type/CPP/gettypecode.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Get_Bits_Hash_Type/CPP/gettypecode.cpp deleted file mode 100644 index f99684b6727..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Get_Bits_Hash_Type/CPP/gettypecode.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -// -// Example of the Decimal::GetTypeCode method. -using namespace System; -int main() -{ - Console::WriteLine( "This example of the " - "Decimal::GetTypeCode( ) \nmethod " - "generates the following output.\n" ); - - // Create a Decimal object and get its type code. - Decimal aDecimal = Decimal(1.0); - TypeCode typCode = aDecimal.GetTypeCode(); - Console::WriteLine( "Type Code: \"{0}\"", typCode ); - Console::WriteLine( "Numeric value: {0}", (int)typCode ); -} - -/* -This example of the Decimal::GetTypeCode( ) -method generates the following output. - -Type Code: "Decimal" -Numeric value: 15 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Mul_Div_Rem/CPP/mul_div_rem.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Mul_Div_Rem/CPP/mul_div_rem.cpp deleted file mode 100644 index ec780d29082..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Mul_Div_Rem/CPP/mul_div_rem.cpp +++ /dev/null @@ -1,76 +0,0 @@ - -// -// Example of the Decimal::Multiply, Decimal::Divide, and -// Decimal::Remainder methods. -using namespace System; - -// Display Decimal parameters and their product, quotient, and -// remainder. -void ShowDecimalProQuoRem( Decimal Left, Decimal Right ) -{ - String^ dataFmt = "{0,-35}{1,31}"; - Console::WriteLine(); - Console::WriteLine( dataFmt, "Decimal Left", Left ); - Console::WriteLine( dataFmt, "Decimal Right", Right ); - Console::WriteLine( dataFmt, "Decimal::Multiply( Left, Right )", Decimal::Multiply( Left, Right ) ); - Console::WriteLine( dataFmt, "Decimal::Divide( Left, Right )", Decimal::Divide( Left, Right ) ); - Console::WriteLine( dataFmt, "Decimal::Remainder( Left, Right )", Decimal::Remainder( Left, Right ) ); -} - -int main() -{ - Console::WriteLine( "This example of the \n" - " Decimal::Multiply( Decimal, Decimal ), \n" - " Decimal::Divide( Decimal, Decimal ), and \n" - " Decimal::Remainder( Decimal, Decimal ) \n" - "methods generates the following output. It displays " - "the product, \nquotient, and remainder of several " - "pairs of Decimal objects." ); - - // Create pairs of Decimal objects. - ShowDecimalProQuoRem( Decimal::Parse( "1000" ), Decimal::Parse( "7" ) ); - ShowDecimalProQuoRem( Decimal::Parse( "-1000" ), Decimal::Parse( "7" ) ); - ShowDecimalProQuoRem( Decimal(1230000000,0,0,false,7), Decimal::Parse( "0.0012300" ) ); - ShowDecimalProQuoRem( Decimal::Parse( "12345678900000000" ), Decimal::Parse( "0.0000000012345678" ) ); - ShowDecimalProQuoRem( Decimal::Parse( "123456789.0123456789" ), Decimal::Parse( "123456789.1123456789" ) ); -} - -/* -This example of the - Decimal::Multiply( Decimal, Decimal ), - Decimal::Divide( Decimal, Decimal ), and - Decimal::Remainder( Decimal, Decimal ) -methods generates the following output. It displays the product, -quotient, and remainder of several pairs of Decimal objects. - -Decimal Left 1000 -Decimal Right 7 -Decimal::Multiply( Left, Right ) 7000 -Decimal::Divide( Left, Right ) 142.85714285714285714285714286 -Decimal::Remainder( Left, Right ) 6 - -Decimal Left -1000 -Decimal Right 7 -Decimal::Multiply( Left, Right ) -7000 -Decimal::Divide( Left, Right ) -142.85714285714285714285714286 -Decimal::Remainder( Left, Right ) -6 - -Decimal Left 123.0000000 -Decimal Right 0.0012300 -Decimal::Multiply( Left, Right ) 0.15129000000000 -Decimal::Divide( Left, Right ) 100000 -Decimal::Remainder( Left, Right ) 0 - -Decimal Left 12345678900000000 -Decimal Right 0.0000000012345678 -Decimal::Multiply( Left, Right ) 15241577.6390794200000000 -Decimal::Divide( Left, Right ) 10000000729000059778004901.796 -Decimal::Remainder( Left, Right ) 0.000000000983 - -Decimal Left 123456789.0123456789 -Decimal Right 123456789.1123456789 -Decimal::Multiply( Left, Right ) 15241578765584515.651425087878 -Decimal::Divide( Left, Right ) 0.9999999991899999933660999449 -Decimal::Remainder( Left, Right ) 123456789.0123456789 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.OACurrency/CPP/fromoacurrency.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.OACurrency/CPP/fromoacurrency.cpp deleted file mode 100644 index 2447a44f013..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.OACurrency/CPP/fromoacurrency.cpp +++ /dev/null @@ -1,59 +0,0 @@ - -// -// Example of the Decimal::FromOACurrency method. -using namespace System; -#define dataFmt "{0,21}{1,25}" - -// Display the Decimal::FromOACurrency parameter and Decimal result. -void ShowDecimalFromOACurrency( __int64 Argument ) -{ - Decimal decCurrency = Decimal::FromOACurrency( Argument ); - Console::WriteLine( dataFmt, Argument, decCurrency ); -} - -int main() -{ - Console::WriteLine( "This example of the " - "Decimal::FromOACurrency( ) method generates \nthe " - "following output. It displays the OLE Automation " - "Currency \nvalue as an __int64 and the result as a " - "Decimal.\n" ); - Console::WriteLine( dataFmt, "OA Currency", "Decimal Value" ); - Console::WriteLine( dataFmt, "-----------", "-------------" ); - - // Convert OLE Automation Currency values to Decimal objects. - ShowDecimalFromOACurrency( 0L ); - ShowDecimalFromOACurrency( 1L ); - ShowDecimalFromOACurrency( 100000L ); - ShowDecimalFromOACurrency( 100000000000L ); - ShowDecimalFromOACurrency( 1000000000000000000L ); - ShowDecimalFromOACurrency( 1000000000000000001L ); - ShowDecimalFromOACurrency( Int64::MaxValue ); - ShowDecimalFromOACurrency( Int64::MinValue ); - ShowDecimalFromOACurrency( 123456789L ); - ShowDecimalFromOACurrency( 1234567890000L ); - ShowDecimalFromOACurrency( 1234567890987654321 ); - ShowDecimalFromOACurrency( 4294967295L ); -} - -/* -This example of the Decimal::FromOACurrency( ) method generates -the following output. It displays the OLE Automation Currency -value as an __int64 and the result as a Decimal. - - OA Currency Decimal Value - ----------- ------------- - 0 0 - 1 0.0001 - 100000 10 - 100000000000 10000000 - 1000000000000000000 100000000000000 - 1000000000000000001 100000000000000.0001 - 9223372036854775807 922337203685477.5807 - -9223372036854775808 -922337203685477.5808 - 123456789 12345.6789 - 1234567890000 123456789 - 1234567890987654321 123456789098765.4321 - 4294967295 429496.7295 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.OACurrency/CPP/tooacurrency.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.OACurrency/CPP/tooacurrency.cpp deleted file mode 100644 index 047800b7566..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.OACurrency/CPP/tooacurrency.cpp +++ /dev/null @@ -1,82 +0,0 @@ - -// -// Example of the Decimal::ToOACurrency method. -using namespace System; -#define dataFmt "{0,31}{1,27}" - -// Get the exception type name; remove the namespace prefix. -String^ GetExceptionType( Exception^ ex ) -{ - String^ exceptionType = ex->GetType()->ToString(); - return exceptionType->Substring( exceptionType->LastIndexOf( '.' ) + 1 ); -} - - -// Display the Decimal::ToOACurrency parameter and the result -// or exception. -void ShowDecimalToOACurrency( Decimal Argument ) -{ - - // Catch the exception if ToOACurrency( ) throws one. - try - { - __int64 oaCurrency = Decimal::ToOACurrency( Argument ); - Console::WriteLine( dataFmt, Argument, oaCurrency ); - } - catch ( Exception^ ex ) - { - Console::WriteLine( dataFmt, Argument, GetExceptionType( ex ) ); - } - -} - -int main() -{ - Console::WriteLine( "This example of the " - "Decimal::ToOACurrency( ) method generates \nthe " - "following output. It displays the argument as a " - "Decimal \nand the OLE Automation Currency value " - "as an __int64.\n" ); - Console::WriteLine( dataFmt, "Argument", "OA Currency or Exception" ); - Console::WriteLine( dataFmt, "--------", "------------------------" ); - - // Convert Decimal values to OLE Automation Currency values. - ShowDecimalToOACurrency( Decimal(0) ); - ShowDecimalToOACurrency( Decimal(1) ); - ShowDecimalToOACurrency( Decimal::Parse( "1.0000000000000000000000000000" ) ); - ShowDecimalToOACurrency( Decimal::Parse( "100000000000000" ) ); - ShowDecimalToOACurrency( Decimal::Parse( "100000000000000.00000000000000" ) ); - ShowDecimalToOACurrency( Decimal::Parse( "10000000000000000000000000000" ) ); - ShowDecimalToOACurrency( Decimal::Parse( "0.000000000123456789" ) ); - ShowDecimalToOACurrency( Decimal::Parse( "0.123456789" ) ); - ShowDecimalToOACurrency( Decimal::Parse( "123456789" ) ); - ShowDecimalToOACurrency( Decimal::Parse( "123456789000000000" ) ); - ShowDecimalToOACurrency( Decimal::Parse( "4294967295" ) ); - ShowDecimalToOACurrency( Decimal::Parse( "18446744073709551615" ) ); - ShowDecimalToOACurrency( Decimal::Parse( "-79.228162514264337593543950335" ) ); - ShowDecimalToOACurrency( Decimal::Parse( "-79228162514264.337593543950335" ) ); -} - -/* -This example of the Decimal::ToOACurrency( ) method generates -the following output. It displays the argument as a Decimal -and the OLE Automation Currency value as an __int64. - - Argument OA Currency or Exception - -------- ------------------------ - 0 0 - 1 10000 - 1.0000000000000000000000000000 10000 - 100000000000000 1000000000000000000 - 100000000000000.00000000000000 1000000000000000000 - 10000000000000000000000000000 OverflowException - 0.000000000123456789 0 - 0.123456789 1235 - 123456789 1234567890000 - 123456789000000000 OverflowException - 4294967295 42949672950000 - 18446744073709551615 OverflowException --79.228162514264337593543950335 -792282 --79228162514264.337593543950335 -792281625142643376 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.ToXXX/CPP/tosgl_dbl.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.ToXXX/CPP/tosgl_dbl.cpp deleted file mode 100644 index 9aec6164459..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.ToXXX/CPP/tosgl_dbl.cpp +++ /dev/null @@ -1,60 +0,0 @@ - -// -// Example of the Decimal::ToSingle and Decimal::ToDouble methods. -using namespace System; -#define formatter "{0,30}{1,17}{2,23}" - -// Convert the Decimal argument; no exceptions are thrown. -void DecimalToSgl_Dbl( Decimal argument ) -{ - Object^ SingleValue; - Object^ DoubleValue; - - // Convert the argument to a float value. - SingleValue = Decimal::ToSingle( argument ); - - // Convert the argument to a double value. - DoubleValue = Decimal::ToDouble( argument ); - Console::WriteLine( formatter, argument, SingleValue, DoubleValue ); -} - -int main() -{ - Console::WriteLine( "This example of the \n" - " Decimal::ToSingle( Decimal ) and \n" - " Decimal::ToDouble( Decimal ) \nmethods " - "generates the following output. It \ndisplays " - "several converted Decimal values.\n" ); - Console::WriteLine( formatter, "Decimal argument", "float", "double" ); - Console::WriteLine( formatter, "----------------", "-----", "------" ); - - // Convert Decimal values and display the results. - DecimalToSgl_Dbl( Decimal::Parse( "0.0000000000000000000000000001" ) ); - DecimalToSgl_Dbl( Decimal::Parse( "0.0000000000123456789123456789" ) ); - DecimalToSgl_Dbl( Decimal::Parse( "123" ) ); - DecimalToSgl_Dbl( Decimal(123000000,0,0,false,6) ); - DecimalToSgl_Dbl( Decimal::Parse( "123456789.123456789" ) ); - DecimalToSgl_Dbl( Decimal::Parse( "123456789123456789123456789" ) ); - DecimalToSgl_Dbl( Decimal::MinValue ); - DecimalToSgl_Dbl( Decimal::MaxValue ); -} - -/* -This example of the - Decimal::ToSingle( Decimal ) and - Decimal::ToDouble( Decimal ) -methods generates the following output. It -displays several converted Decimal values. - - Decimal argument float double - ---------------- ----- ------ -0.0000000000000000000000000001 1E-28 1E-28 -0.0000000000123456789123456789 1.234568E-11 1.23456789123457E-11 - 123 123 123 - 123.000000 123 123 - 123456789.123456789 1.234568E+08 123456789.123457 - 123456789123456789123456789 1.234568E+26 1.23456789123457E+26 --79228162514264337593543950335 -7.922816E+28 -7.92281625142643E+28 - 79228162514264337593543950335 7.922816E+28 7.92281625142643E+28 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Double.ToString/cpp/tostring1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Double.ToString/cpp/tostring1.cpp deleted file mode 100644 index b208ee69e6c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Double.ToString/cpp/tostring1.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// ToStringCPP.cpp : main project file. - -// -using namespace System; -using namespace System::Globalization; - -int main(array ^args) -{ - double value = 16325.62901; - String^ specifier; - CultureInfo^ culture; - - // Use standard numeric format specifiers. - specifier = "G"; - culture = CultureInfo::CreateSpecificCulture("eu-ES"); - Console::WriteLine(value.ToString(specifier, culture)); - // Displays: 16325,62901 - Console::WriteLine(value.ToString(specifier, CultureInfo::InvariantCulture)); - // Displays: 16325.62901 - - specifier = "C"; - culture = CultureInfo::CreateSpecificCulture("en-US"); - Console::WriteLine(value.ToString(specifier, culture)); - // Displays: $16,325.63 - culture = CultureInfo::CreateSpecificCulture("en-GB"); - Console::WriteLine(value.ToString(specifier, culture)); - // Displays: £16,325.63 - - specifier = "E04"; - culture = CultureInfo::CreateSpecificCulture("sv-SE"); - Console::WriteLine(value.ToString(specifier, culture)); - // Displays: 1,6326E+004 - culture = CultureInfo::CreateSpecificCulture("en-NZ"); - Console::WriteLine(value.ToString(specifier, culture)); - // Displays: 1.6326E+004 - - specifier = "F"; - culture = CultureInfo::CreateSpecificCulture("fr-FR"); - Console::WriteLine(value.ToString(specifier, culture)); - // Displays: 16325,63 - culture = CultureInfo::CreateSpecificCulture("en-CA"); - Console::WriteLine(value.ToString(specifier, culture)); - // Displays: 16325.63 - - specifier = "N"; - culture = CultureInfo::CreateSpecificCulture("es-ES"); - Console::WriteLine(value.ToString(specifier, culture)); - // Displays: 16.325,63 - culture = CultureInfo::CreateSpecificCulture("fr-CA"); - Console::WriteLine(value.ToString(specifier, culture)); - // Displays: 16 325,63 - - specifier = "P"; - culture = CultureInfo::InvariantCulture; - Console::WriteLine((value/10000).ToString(specifier, culture)); - // Displays: 163.26 % - culture = CultureInfo::CreateSpecificCulture("ar-EG"); - Console::WriteLine((value/10000).ToString(specifier, culture)); - // Displays: 163.256 % - - return 0; -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Double.ToString/cpp/tostring3.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Double.ToString/cpp/tostring3.cpp deleted file mode 100644 index 69e9a30d33e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Double.ToString/cpp/tostring3.cpp +++ /dev/null @@ -1,223 +0,0 @@ -// -using namespace System; - -void main() -{ - array^ numbers= {1054.32179, -195489100.8377, 1.0437E21, - -1.0573e-05}; - array^ specifiers = { "C", "E", "e", "F", "G", "N", "P", - "R", "#,000.000", "0.###E-000", - "000,000,000,000.00###" }; - for each (Double number in numbers) - { - Console::WriteLine("Formatting of {0}:", number); - for each (String^ specifier in specifiers) { - Console::WriteLine(" {0,-22} {1}", - specifier + ":", number.ToString(specifier)); - // Add precision specifiers from 0 to 3. - if (specifier->Length == 1 & ! specifier->Equals("R")) { - for (int precision = 0; precision <= 3; precision++) { - String^ pSpecifier = String::Format("{0}{1}", specifier, precision); - Console::WriteLine(" {0,-22} {1}", - pSpecifier + ":", number.ToString(pSpecifier)); - } - Console::WriteLine(); - } - } - Console::WriteLine(); - } -} -// The example displays the following output: -// Formatting of 1054.32179: -// C: $1,054.32 -// C0: $1,054 -// C1: $1,054.3 -// C2: $1,054.32 -// C3: $1,054.322 -// -// E: 1.054322E+003 -// E0: 1E+003 -// E1: 1.1E+003 -// E2: 1.05E+003 -// E3: 1.054E+003 -// -// e: 1.054322e+003 -// e0: 1e+003 -// e1: 1.1e+003 -// e2: 1.05e+003 -// e3: 1.054e+003 -// -// F: 1054.32 -// F0: 1054 -// F1: 1054.3 -// F2: 1054.32 -// F3: 1054.322 -// -// G: 1054.32179 -// G0: 1054.32179 -// G1: 1E+03 -// G2: 1.1E+03 -// G3: 1.05E+03 -// -// N: 1,054.32 -// N0: 1,054 -// N1: 1,054.3 -// N2: 1,054.32 -// N3: 1,054.322 -// -// P: 105,432.18 % -// P0: 105,432 % -// P1: 105,432.2 % -// P2: 105,432.18 % -// P3: 105,432.179 % -// -// R: 1054.32179 -// #,000.000: 1,054.322 -// 0.###E-000: 1.054E003 -// 000,000,000,000.00###: 000,000,001,054.32179 -// -// Formatting of -195489100.8377: -// C: ($195,489,100.84) -// C0: ($195,489,101) -// C1: ($195,489,100.8) -// C2: ($195,489,100.84) -// C3: ($195,489,100.838) -// -// E: -1.954891E+008 -// E0: -2E+008 -// E1: -2.0E+008 -// E2: -1.95E+008 -// E3: -1.955E+008 -// -// e: -1.954891e+008 -// e0: -2e+008 -// e1: -2.0e+008 -// e2: -1.95e+008 -// e3: -1.955e+008 -// -// F: -195489100.84 -// F0: -195489101 -// F1: -195489100.8 -// F2: -195489100.84 -// F3: -195489100.838 -// -// G: -195489100.8377 -// G0: -195489100.8377 -// G1: -2E+08 -// G2: -2E+08 -// G3: -1.95E+08 -// -// N: -195,489,100.84 -// N0: -195,489,101 -// N1: -195,489,100.8 -// N2: -195,489,100.84 -// N3: -195,489,100.838 -// -// P: -19,548,910,083.77 % -// P0: -19,548,910,084 % -// P1: -19,548,910,083.8 % -// P2: -19,548,910,083.77 % -// P3: -19,548,910,083.770 % -// -// R: -195489100.8377 -// #,000.000: -195,489,100.838 -// 0.###E-000: -1.955E008 -// 000,000,000,000.00###: -000,195,489,100.8377 -// -// Formatting of 1.0437E+21: -// C: $1,043,700,000,000,000,000,000.00 -// C0: $1,043,700,000,000,000,000,000 -// C1: $1,043,700,000,000,000,000,000.0 -// C2: $1,043,700,000,000,000,000,000.00 -// C3: $1,043,700,000,000,000,000,000.000 -// -// E: 1.043700E+021 -// E0: 1E+021 -// E1: 1.0E+021 -// E2: 1.04E+021 -// E3: 1.044E+021 -// -// e: 1.043700e+021 -// e0: 1e+021 -// e1: 1.0e+021 -// e2: 1.04e+021 -// e3: 1.044e+021 -// -// F: 1043700000000000000000.00 -// F0: 1043700000000000000000 -// F1: 1043700000000000000000.0 -// F2: 1043700000000000000000.00 -// F3: 1043700000000000000000.000 -// -// G: 1.0437E+21 -// G0: 1.0437E+21 -// G1: 1E+21 -// G2: 1E+21 -// G3: 1.04E+21 -// -// N: 1,043,700,000,000,000,000,000.00 -// N0: 1,043,700,000,000,000,000,000 -// N1: 1,043,700,000,000,000,000,000.0 -// N2: 1,043,700,000,000,000,000,000.00 -// N3: 1,043,700,000,000,000,000,000.000 -// -// P: 104,370,000,000,000,000,000,000.00 % -// P0: 104,370,000,000,000,000,000,000 % -// P1: 104,370,000,000,000,000,000,000.0 % -// P2: 104,370,000,000,000,000,000,000.00 % -// P3: 104,370,000,000,000,000,000,000.000 % -// -// R: 1.0437E+21 -// #,000.000: 1,043,700,000,000,000,000,000.000 -// 0.###E-000: 1.044E021 -// 000,000,000,000.00###: 1,043,700,000,000,000,000,000.00 -// -// Formatting of -1.0573E-05: -// C: $0.00 -// C0: $0 -// C1: $0.0 -// C2: $0.00 -// C3: $0.000 -// -// E: -1.057300E-005 -// E0: -1E-005 -// E1: -1.1E-005 -// E2: -1.06E-005 -// E3: -1.057E-005 -// -// e: -1.057300e-005 -// e0: -1e-005 -// e1: -1.1e-005 -// e2: -1.06e-005 -// e3: -1.057e-005 -// -// F: 0.00 -// F0: 0 -// F1: 0.0 -// F2: 0.00 -// F3: 0.000 -// -// G: -1.0573E-05 -// G0: -1.0573E-05 -// G1: -1E-05 -// G2: -1.1E-05 -// G3: -1.06E-05 -// -// N: 0.00 -// N0: 0 -// N1: 0.0 -// N2: 0.00 -// N3: 0.000 -// -// P: 0.00 % -// P0: 0 % -// P1: 0.0 % -// P2: 0.00 % -// P3: -0.001 % -// -// R: -1.0573E-05 -// #,000.000: 000.000 -// 0.###E-000: -1.057E-005 -// 000,000,000,000.00###: -000,000,000,000.00001 -// - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Double/CPP/doublesample.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Double/CPP/doublesample.cpp deleted file mode 100644 index 7d153608b4c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Double/CPP/doublesample.cpp +++ /dev/null @@ -1,150 +0,0 @@ -using namespace System; - -int main() -{ - // - Double d = 4.55; - // - - // - Console::WriteLine( "A double is of type {0}.", d.GetType() ); - // - - // - bool done = false; - String^ inp; - do - { - Console::Write( "Enter a real number: " ); - inp = Console::ReadLine(); - try - { - d = Double::Parse( inp ); - Console::WriteLine( "You entered {0}.", d ); - done = true; - } - catch ( FormatException^ ) - { - Console::WriteLine( "You did not enter a number." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "An exception occurred while parsing your response: {0}", e ); - } - - } - while ( !done ); - // - - // - if ( d > Double::MaxValue ) - { - Console::WriteLine( "Your number is bigger than a double." ); - } - // - - // - if ( d < Double::MinValue ) - { - Console::WriteLine( "Your number is smaller than a double." ); - } - // - - // - Console::WriteLine( "Epsilon, or the permittivity of a vacuum, has value {0}", Double::Epsilon ); - // - - // - Double zero = 0; - - // This condition will return false. - if ( (0 / zero) == Double::NaN ) - { - Console::WriteLine( "0 / 0 can be tested with Double::NaN." ); - } - else - { - Console::WriteLine( "0 / 0 cannot be tested with Double::NaN; use Double::IsNan() instead." ); - } - // - - // - // This will return true. - if ( Double::IsNaN( 0 / zero ) ) - { - Console::WriteLine( "Double::IsNan() can determine whether a value is not-a-number." ); - } - // - - // - // This will equal Infinity. - Console::WriteLine( "10.0 minus NegativeInfinity equals {0}.", (10.0 - Double::NegativeInfinity) ); - // - - // - // This will equal Infinity. - Console::WriteLine( "PositiveInfinity plus 10.0 equals {0}.", (Double::PositiveInfinity + 10.0) ); - // - - // - // This will return S"true". - Console::WriteLine( "IsInfinity(3.0 / 0) == {0}.", Double::IsInfinity( 3.0 / zero ) ? (String^)"true" : "false" ); - // - - // - // This will return S"true". - Console::WriteLine( "IsPositiveInfinity(4.0 / 0) == {0}.", Double::IsPositiveInfinity( 4.0 / zero ) ? (String^)"true" : "false" ); - // - - // - // This will return S"true". - Console::WriteLine( "IsNegativeInfinity(-5.0 / 0) == {0}.", Double::IsNegativeInfinity( -5.0 / zero ) ? (String^)"true" : "false" ); - // - - // - Double a; - a = 500; - Object^ obj1; - // - - // - // The variables point to the same objects. - Object^ obj2; - obj1 = a; - obj2 = obj1; - if ( Double::ReferenceEquals( obj1, obj2 ) ) - { - Console::WriteLine( "The variables point to the same double object." ); - } - else - { - Console::WriteLine( "The variables point to different double objects." ); - } - // - - // - obj1 = (Double)450; - if ( a.CompareTo( obj1 ) < 0 ) - { - Console::WriteLine( "{0} is less than {1}.", a, obj1 ); - } - - if ( a.CompareTo( obj1 ) > 0 ) - { - Console::WriteLine( "{0} is greater than {1}.", a, obj1 ); - } - - if ( a.CompareTo( obj1 ) == 0 ) - { - Console::WriteLine( "{0} equals {1}.", a, obj1 ); - } - // - - // - obj1 = (Double)500; - if ( a.Equals( obj1 ) ) - { - Console::WriteLine( "The value type and reference type values are equal." ); - } - // -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Environment/CPP/Vars1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Environment/CPP/Vars1.cpp deleted file mode 100644 index 9a426f16689..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Environment/CPP/Vars1.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// -using namespace System; -using namespace System::IO; - -void main() -{ - if (Environment::OSVersion->Platform == PlatformID::Win32NT) - { - // Change the directory to %WINDIR% - Environment::CurrentDirectory = Environment::GetEnvironmentVariable( "windir" ); - DirectoryInfo^ info = gcnew DirectoryInfo( "." ); - - Console::WriteLine("Directory Info: {0}", info->FullName); - } - else - { - Console::WriteLine("This example runs on Windows only."); - } -} -// The example displays output like the following on a .NET implementation running on Windows: -// Directory Info: C:\windows -// The example displays the following output on a .NET implementation on Unix-based systems: -// This example runs on Windows only. -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Exception.Ctor/CPP/new.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Exception.Ctor/CPP/new.cpp deleted file mode 100644 index dcea5c7890b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Exception.Ctor/CPP/new.cpp +++ /dev/null @@ -1,108 +0,0 @@ - -// -// Example for the Exception( ) constructor. -using namespace System; - -namespace NDP_UE_CPP -{ - - // Derive an exception with a predefined message. - public ref class NotEvenException: public Exception - { - public: - NotEvenException() - : Exception( "The argument to a function requiring " - "even input is not divisible by 2." ) - {} - - }; - - - // Half throws a base exception if the input is not even. - int Half( int input ) - { - if ( input % 2 != 0 ) - throw gcnew Exception; - else - return input / 2; - } - - - // Half2 throws a derived exception if the input is not even. - int Half2( int input ) - { - if ( input % 2 != 0 ) - throw gcnew NotEvenException; - else - return input / 2; - } - - - // CalcHalf calls Half and catches any thrown exceptions. - void CalcHalf( int input ) - { - try - { - int halfInput = Half( input ); - Console::WriteLine( "Half of {0} is {1}.", input, halfInput ); - } - catch ( Exception^ ex ) - { - Console::WriteLine( ex->ToString() ); - } - - } - - - // CalcHalf2 calls Half2 and catches any thrown exceptions. - void CalcHalf2( int input ) - { - try - { - int halfInput = Half2( input ); - Console::WriteLine( "Half of {0} is {1}.", input, halfInput ); - } - catch ( Exception^ ex ) - { - Console::WriteLine( ex->ToString() ); - } - - } - -} - -int main() -{ - Console::WriteLine( "This example of the Exception( ) constructor " - "generates the following output." ); - Console::WriteLine( "\nHere, an exception is thrown using the \n" - "parameterless constructor of the base class.\n" ); - NDP_UE_CPP::CalcHalf( 12 ); - NDP_UE_CPP::CalcHalf( 15 ); - Console::WriteLine( "\nHere, an exception is thrown using the \n" - "parameterless constructor of a derived class.\n" ); - NDP_UE_CPP::CalcHalf2( 24 ); - NDP_UE_CPP::CalcHalf2( 27 ); -} - -/* -This example of the Exception( ) constructor generates the following output. - -Here, an exception is thrown using the -parameterless constructor of the base class. - -Half of 12 is 6. -System.Exception: Exception of type System.Exception was thrown. - at NDP_UE_CPP.Half(Int32 input) - at NDP_UE_CPP.CalcHalf(Int32 input) - -Here, an exception is thrown using the -parameterless constructor of a derived class. - -Half of 24 is 12. -NDP_UE_CPP.NotEvenException: The argument to a function requiring even input is - not divisible by 2. - at NDP_UE_CPP.Half2(Int32 input) - at NDP_UE_CPP.CalcHalf2(Int32 input) -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Exception.Ctor/CPP/news.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Exception.Ctor/CPP/news.cpp deleted file mode 100644 index 680a5c851ed..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Exception.Ctor/CPP/news.cpp +++ /dev/null @@ -1,116 +0,0 @@ - -// -// Example for the Exception( String* ) constructor. -using namespace System; - -namespace NDP_UE_CPP -{ - - // Derive an exception with a specifiable message. - public ref class NotEvenException: public Exception - { - private: - static String^ notEvenMessage = "The argument to a function requiring " - "even input is not divisible by 2."; - - public: - NotEvenException() - : Exception( notEvenMessage ) - {} - - NotEvenException( String^ auxMessage ) - : Exception( String::Format( "{0} - {1}", auxMessage, notEvenMessage ) ) - {} - - }; - - - // Half throws a base exception if the input is not even. - int Half( int input ) - { - if ( input % 2 != 0 ) - throw gcnew Exception( String::Format( "The argument {0} is not divisible by 2.", input ) ); - else - return input / 2; - } - - - // Half2 throws a derived exception if the input is not even. - int Half2( int input ) - { - if ( input % 2 != 0 ) - throw gcnew NotEvenException( String::Format( "Invalid argument: {0}", input ) ); - else - return input / 2; - } - - - // CalcHalf calls Half and catches any thrown exceptions. - void CalcHalf( int input ) - { - try - { - int halfInput = Half( input ); - Console::WriteLine( "Half of {0} is {1}.", input, halfInput ); - } - catch ( Exception^ ex ) - { - Console::WriteLine( ex->ToString() ); - } - - } - - - // CalcHalf2 calls Half2 and catches any thrown exceptions. - void CalcHalf2( int input ) - { - try - { - int halfInput = Half2( input ); - Console::WriteLine( "Half of {0} is {1}.", input, halfInput ); - } - catch ( Exception^ ex ) - { - Console::WriteLine( ex->ToString() ); - } - - } - -} - -int main() -{ - Console::WriteLine( "This example of the Exception( String* )\n" - "constructor generates the following output." ); - Console::WriteLine( "\nHere, an exception is thrown using the \n" - "constructor of the base class.\n" ); - NDP_UE_CPP::CalcHalf( 18 ); - NDP_UE_CPP::CalcHalf( 21 ); - Console::WriteLine( "\nHere, an exception is thrown using the \n" - "constructor of a derived class.\n" ); - NDP_UE_CPP::CalcHalf2( 30 ); - NDP_UE_CPP::CalcHalf2( 33 ); -} - -/* -This example of the Exception( String* ) -constructor generates the following output. - -Here, an exception is thrown using the -constructor of the base class. - -Half of 18 is 9. -System.Exception: The argument 21 is not divisible by 2. - at NDP_UE_CPP.Half(Int32 input) - at NDP_UE_CPP.CalcHalf(Int32 input) - -Here, an exception is thrown using the -constructor of a derived class. - -Half of 30 is 15. -NDP_UE_CPP.NotEvenException: Invalid argument: 33 - The argument to a function -requiring even input is not divisible by 2. - at NDP_UE_CPP.Half2(Int32 input) - at NDP_UE_CPP.CalcHalf2(Int32 input) -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Exception.Ctor/CPP/newsi.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Exception.Ctor/CPP/newsi.cpp deleted file mode 100644 index c1923e2fbc7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Exception.Ctor/CPP/newsi.cpp +++ /dev/null @@ -1,109 +0,0 @@ - -// -// Example for the Exception( String*, Exception* ) constructor. -using namespace System; - -namespace NDP_UE_CPP -{ - - // Derive an exception with a specifiable message and inner exception. - public ref class LogTableOverflowException: public Exception - { - private: - static String^ overflowMessage = "The log table has overflowed."; - - public: - LogTableOverflowException() - : Exception( overflowMessage ) - {} - - LogTableOverflowException( String^ auxMessage ) - : Exception( String::Format( "{0} - {1}", overflowMessage, auxMessage ) ) - {} - - LogTableOverflowException( String^ auxMessage, Exception^ inner ) - : Exception( String::Format( "{0} - {1}", overflowMessage, auxMessage ), inner ) - {} - - }; - - public ref class LogTable - { - public: - LogTable( int numElements ) - { - logArea = gcnew array(numElements); - elemInUse = 0; - } - - - protected: - array^logArea; - int elemInUse; - - public: - - // The AddRecord method throws a derived exception - // if the array bounds exception is caught. - int AddRecord( String^ newRecord ) - { - try - { - logArea[ elemInUse ] = newRecord; - return elemInUse++; - } - catch ( Exception^ ex ) - { - throw gcnew LogTableOverflowException( String::Format( "Record \"{0}\" was not logged.", newRecord ),ex ); - } - - } - - }; - - - // Create a log table and force an overflow. - void ForceOverflow() - { - LogTable^ log = gcnew LogTable( 4 ); - try - { - for ( int count = 1; ; count++ ) - { - log->AddRecord( String::Format( "Log record number {0}", count ) ); - - } - } - catch ( Exception^ ex ) - { - Console::WriteLine( ex->ToString() ); - } - - } - -} - -int main() -{ - Console::WriteLine( "This example of the Exception( String*, Exception* )\n" - "constructor generates the following output." ); - Console::WriteLine( "\nExample of a derived exception " - "that references an inner exception:\n" ); - NDP_UE_CPP::ForceOverflow(); -} - -/* -This example of the Exception( String*, Exception* ) -constructor generates the following output. - -Example of a derived exception that references an inner exception: - -NDP_UE_CPP.LogTableOverflowException: The log table has overflowed. - Record "L -og record number 5" was not logged. ---> System.IndexOutOfRangeException: Index - was outside the bounds of the array. - at NDP_UE_CPP.LogTable.AddRecord(String newRecord) - --- End of inner exception stack trace --- - at NDP_UE_CPP.LogTable.AddRecord(String newRecord) - at NDP_UE_CPP.ForceOverflow() -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Exception.GetBaseException/CPP/getbaseexc.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Exception.GetBaseException/CPP/getbaseexc.cpp deleted file mode 100644 index 38d74dc3b35..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Exception.GetBaseException/CPP/getbaseexc.cpp +++ /dev/null @@ -1,137 +0,0 @@ - -// -// Example for the Exception::GetBaseException method. -using namespace System; - -namespace NDP_UE_CPP -{ - - // Define two derived exceptions to demonstrate nested exceptions. - ref class SecondLevelException: public Exception - { - public: - SecondLevelException( String^ message, Exception^ inner ) - : Exception( message, inner ) - {} - - }; - - ref class ThirdLevelException: public Exception - { - public: - ThirdLevelException( String^ message, Exception^ inner ) - : Exception( message, inner ) - {} - - }; - - - // DivideBy0 forces a division by 0 and throws a second exception. - void DivideBy0() - { - try - { - int zero = 0; - int ecks = 1 / zero; - } - catch ( Exception^ ex ) - { - throw gcnew SecondLevelException( "Forced a division by 0 and threw " - "a second exception.",ex ); - } - - } - - - // This function catches the exception from the called function - // DivideBy0( ) and throws another in response. - void Rethrow() - { - try - { - DivideBy0(); - } - catch ( Exception^ ex ) - { - throw gcnew ThirdLevelException( "Caught the second exception and " - "threw a third in response.",ex ); - } - - } - -} - -int main() -{ - Console::WriteLine( "This example of Exception.GetBaseException " - "generates the following output." ); - Console::WriteLine( "\nThe program forces a division by 0, " - "then throws the exception \ntwice more, " - "using a different derived exception each time.\n" ); - try - { - - // This function calls another that forces a division by 0. - NDP_UE_CPP::Rethrow(); - } - catch ( Exception^ e ) - { - Exception^ current; - Console::WriteLine( "Unwind the nested exceptions using " - "the InnerException property:\n" ); - - // This code unwinds the nested exceptions using the - // InnerException property. - current = e; - while ( current != (Object^)0 ) - { - Console::WriteLine( current->ToString() ); - Console::WriteLine(); - current = current->InnerException; - } - - // Display the innermost exception. - Console::WriteLine( "Display the base exception using the \n" - "GetBaseException method:\n" ); - Console::WriteLine( e->GetBaseException()->ToString() ); - } - -} - -/* -This example of Exception.GetBaseException generates the following output. - -The program forces a division by 0, then throws the exception -twice more, using a different derived exception each time. - -Unwind the nested exceptions using the InnerException property: - -NDP_UE_CPP.ThirdLevelException: Caught the second exception and threw a third i -n response. ---> NDP_UE_CPP.SecondLevelException: Forced a division by 0 and th -rew a second exception. ---> System.DivideByZeroException: Attempted to divide -by zero. - at NDP_UE_CPP.DivideBy0() - --- End of inner exception stack trace --- - at NDP_UE_CPP.DivideBy0() - at NDP_UE_CPP.Rethrow() - --- End of inner exception stack trace --- - at NDP_UE_CPP.Rethrow() - at main() - -NDP_UE_CPP.SecondLevelException: Forced a division by 0 and threw a second exce -ption. ---> System.DivideByZeroException: Attempted to divide by zero. - at NDP_UE_CPP.DivideBy0() - --- End of inner exception stack trace --- - at NDP_UE_CPP.DivideBy0() - at NDP_UE_CPP.Rethrow() - -System.DivideByZeroException: Attempted to divide by zero. - at NDP_UE_CPP.DivideBy0() - -Display the base exception using the -GetBaseException method: - -System.DivideByZeroException: Attempted to divide by zero. - at NDP_UE_CPP.DivideBy0() -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Exception.HResult/CPP/hresult.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Exception.HResult/CPP/hresult.cpp deleted file mode 100644 index b3714fff6d0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Exception.HResult/CPP/hresult.cpp +++ /dev/null @@ -1,70 +0,0 @@ - -// -// Example for the Exception::HResult property. -using namespace System; - -namespace NDP_UE_CPP -{ - - // Create the derived exception class. - ref class SecondLevelException: public Exception - { - private: - static int SecondLevelHResult = (int)0x81234567; - - public: - - // Set HResult for this exception, and include it in - // the exception message. - SecondLevelException( String^ message, Exception^ inner ) - : Exception( String::Format( "(HRESULT:0x{1:X8}) {0}", message, SecondLevelHResult ), inner ) - { - HResult = SecondLevelHResult; - } - - }; - - - // This function forces a division by 0 and throws - // a second exception. - void DivideBy0() - { - try - { - try - { - int zero = 0; - int ecks = 1 / zero; - } - catch ( Exception^ ex ) - { - throw gcnew SecondLevelException( "Forced a division by 0 and threw " - "a second exception.",ex ); - } - - } - catch ( Exception^ ex ) - { - Console::WriteLine( ex->ToString() ); - } - - } - -} - -int main() -{ - NDP_UE_CPP::DivideBy0(); -} - -/* -This example of Exception::HResult generates the following output. - -NDP_UE_CPP.SecondLevelException: (HRESULT:0x81234567) Forced a division by 0 an -d threw a second exception. ---> System.DivideByZeroException: Attempted to div -ide by zero. - at NDP_UE_CPP.DivideBy0() - --- End of inner exception stack trace --- - at NDP_UE_CPP.DivideBy0() -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Exception.Properties/CPP/exception_properties.vcxproj b/snippets/cpp/VS_Snippets_CLR_System/system.Exception.Properties/CPP/exception_properties.vcxproj deleted file mode 100644 index 62a1c06daf2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Exception.Properties/CPP/exception_properties.vcxproj +++ /dev/null @@ -1,123 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {9E46617A-3919-4B6F-94D6-B3873EC9E79C} - NDP_UE_CPP - ManagedCProj - - - - Application - Unicode - Pure - true - - - Application - Unicode - Pure - - - - - - - - - - - - - <_ProjectFileVersion>10.0.21125.1 - .\ - $(Configuration)\ - true - $(SolutionDir)$(Configuration)\ - $(Configuration)\ - false - AllRules.ruleset - - - AllRules.ruleset - - - - - - Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - - - Level3 - ProgramDatabase - - - - - true - true - Windows - main - false - - - MachineX86 - - - - - WIN32;NDEBUG;%(PreprocessorDefinitions) - MultiThreadedDLL - - - Level3 - ProgramDatabase - - - - - true - Windows - main - false - - - MachineX86 - - - - - true - true - - - true - true - - - true - true - - - true - true - - - - - - - - - \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Exception.Properties/CPP/properties.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Exception.Properties/CPP/properties.cpp deleted file mode 100644 index 5597ab64333..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Exception.Properties/CPP/properties.cpp +++ /dev/null @@ -1,121 +0,0 @@ - -// -// Example for the Exception::HelpLink, Exception::Source, -// Exception::StackTrace, and Exception::TargetSite properties. -using namespace System; - -namespace NDP_UE_CPP -{ - - // Derive an exception; the constructor sets the HelpLink and - // Source properties. - public ref class LogTableOverflowException: public Exception - { - private: - static String^ overflowMessage = "The log table has overflowed."; - - public: - LogTableOverflowException( String^ auxMessage, Exception^ inner ) - : Exception( String::Format( "{0} - {1}", overflowMessage, auxMessage ), inner ) - { - this->HelpLink = "https://learn.microsoft.com"; - this->Source = "Exception_Class_Samples"; - } - - }; - - public ref class LogTable - { - public: - LogTable( int numElements ) - { - logArea = gcnew array(numElements); - elemInUse = 0; - } - - - protected: - array^logArea; - int elemInUse; - - public: - - // The AddRecord method throws a derived exception if - // the array bounds exception is caught. - int AddRecord( String^ newRecord ) - { - try - { - logArea[ elemInUse ] = newRecord; - return elemInUse++; - } - catch ( Exception^ ex ) - { - throw gcnew LogTableOverflowException( String::Format( "Record \"{0}\" was not logged.", newRecord ),ex ); - } - - } - - }; - - - // Create a log table and force an overflow. - void ForceOverflow() - { - LogTable^ log = gcnew LogTable( 4 ); - try - { - for ( int count = 1; ; count++ ) - { - log->AddRecord( String::Format( "Log record number {0}", count ) ); - - } - } - catch ( Exception^ ex ) - { - Console::WriteLine( "\nMessage ---\n{0}", ex->Message ); - Console::WriteLine( "\nHelpLink ---\n{0}", ex->HelpLink ); - Console::WriteLine( "\nSource ---\n{0}", ex->Source ); - Console::WriteLine( "\nStackTrace ---\n{0}", ex->StackTrace ); - Console::WriteLine( "\nTargetSite ---\n{0}", ex->TargetSite->ToString() ); - } - - } - -} - -int main() -{ - Console::WriteLine( "This example of \n Exception::Message, \n" - " Exception::HelpLink, \n Exception::Source, \n" - " Exception::StackTrace, and \n Exception::" - "TargetSite \ngenerates the following output." ); - NDP_UE_CPP::ForceOverflow(); -} - -/* -This example of - Exception::Message, - Exception::HelpLink, - Exception::Source, - Exception::StackTrace, and - Exception::TargetSite -generates the following output. - -Message --- -The log table has overflowed. - Record "Log record number 5" was not logged. - -HelpLink --- -https://learn.microsoft.com - -Source --- -Exception_Class_Samples - -StackTrace --- - at NDP_UE_CPP.LogTable.AddRecord(String newRecord) - at NDP_UE_CPP.ForceOverflow() - -TargetSite --- -Int32 AddRecord(System.String) -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.FlagsAttribute/CPP/flags.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.FlagsAttribute/CPP/flags.cpp deleted file mode 100644 index f572f53062b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.FlagsAttribute/CPP/flags.cpp +++ /dev/null @@ -1,79 +0,0 @@ - -// -using namespace System; - -// Define an Enum without FlagsAttribute. -public enum class SingleHue : short -{ - None = 0, - Black = 1, - Red = 2, - Green = 4, - Blue = 8 -}; - -// Define an Enum with FlagsAttribute. -[Flags] -enum class MultiHue : short -{ - None = 0, - Black = 1, - Red = 2, - Green = 4, - Blue = 8 -}; - -int main() -{ - // Display all possible combinations of values. - Console::WriteLine( - "All possible combinations of values without FlagsAttribute:"); - for (int val = 0; val <= 16; val++) - Console::WriteLine("{0,3} - {1:G}", val, (SingleHue)val); - - Console::WriteLine( - "\nAll possible combinations of values with FlagsAttribute:"); - - // Display all combinations of values, and invalid values. - for (int val = 0; val <= 16; val++ ) - Console::WriteLine("{0,3} - {1:G}", val, (MultiHue)val); -} -// The example displays the following output: -// All possible combinations of values without FlagsAttribute: -// 0 - None -// 1 - Black -// 2 - Red -// 3 - 3 -// 4 - Green -// 5 - 5 -// 6 - 6 -// 7 - 7 -// 8 - Blue -// 9 - 9 -// 10 - 10 -// 11 - 11 -// 12 - 12 -// 13 - 13 -// 14 - 14 -// 15 - 15 -// 16 - 16 -// -// All possible combinations of values with FlagsAttribute: -// 0 - None -// 1 - Black -// 2 - Red -// 3 - Black, Red -// 4 - Green -// 5 - Black, Green -// 6 - Red, Green -// 7 - Black, Red, Green -// 8 - Blue -// 9 - Black, Blue -// 10 - Red, Blue -// 11 - Black, Red, Blue -// 12 - Green, Blue -// 13 - Black, Green, Blue -// 14 - Red, Green, Blue -// 15 - Black, Red, Green, Blue -// 16 - 16 -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.FlagsAttribute/CPP/flags1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.FlagsAttribute/CPP/flags1.cpp deleted file mode 100644 index 71b62c4c010..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.FlagsAttribute/CPP/flags1.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// -using namespace System; - -[Flags] -enum class PhoneService -{ - None = 0, - LandLine = 1, - Cell = 2, - Fax = 4, - Internet = 8, - Other = 16 -}; - -void main() -{ - // Define three variables representing the types of phone service - // in three households. - PhoneService household1 = PhoneService::LandLine | PhoneService::Cell | - PhoneService::Internet; - PhoneService household2 = PhoneService::None; - PhoneService household3 = PhoneService::Cell | PhoneService::Internet; - - // Store the variables in an array for ease of access. - array^ households = { household1, household2, household3 }; - - // Which households have no service? - for (int ctr = 0; ctr < households->Length; ctr++) - Console::WriteLine("Household {0} has phone service: {1}", - ctr + 1, - households[ctr] == PhoneService::None ? - "No" : "Yes"); - Console::WriteLine(); - - // Which households have cell phone service? - for (int ctr = 0; ctr < households->Length; ctr++) - Console::WriteLine("Household {0} has cell phone service: {1}", - ctr + 1, - (households[ctr] & PhoneService::Cell) == PhoneService::Cell ? - "Yes" : "No"); - Console::WriteLine(); - - // Which households have cell phones and land lines? - PhoneService cellAndLand = PhoneService::Cell | PhoneService::LandLine; - for (int ctr = 0; ctr < households->Length; ctr++) - Console::WriteLine("Household {0} has cell and land line service: {1}", - ctr + 1, - (households[ctr] & cellAndLand) == cellAndLand ? - "Yes" : "No"); - Console::WriteLine(); - - // List all types of service of each household?// - for (int ctr = 0; ctr < households->Length; ctr++) - Console::WriteLine("Household {0} has: {1:G}", - ctr + 1, households[ctr]); - Console::WriteLine(); -} -// The example displays the following output: -// Household 1 has phone service: Yes -// Household 2 has phone service: No -// Household 3 has phone service: Yes -// -// Household 1 has cell phone service: Yes -// Household 2 has cell phone service: No -// Household 3 has cell phone service: Yes -// -// Household 1 has cell and land line service: Yes -// Household 2 has cell and land line service: No -// Household 3 has cell and land line service: No -// -// Household 1 has: LandLine, Cell, Internet -// Household 2 has: None -// Household 3 has: Cell, Internet -// - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Func~2/cpp/Example.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Func~2/cpp/Example.cpp deleted file mode 100644 index 55b8b589334..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Func~2/cpp/Example.cpp +++ /dev/null @@ -1,44 +0,0 @@ -using namespace System; -using namespace System::Linq; -using namespace System::Collections; -using namespace System::Collections::Generic; - -// -// Declare a delegate -delegate String ^ MyDel(String ^); - -// Create wrapper class and function that takes in a string and converts it to uppercase -ref class DelegateWrapper { -public: - String ^ ToUpper(String ^ s) { - return s->ToUpper(); - } -}; - -int main() { - // Declare delegate - DelegateWrapper ^ delegateWrapper = gcnew DelegateWrapper; - MyDel ^ DelInst = gcnew MyDel(delegateWrapper, &DelegateWrapper::ToUpper); - - // Cast into Func - Func ^ selector = reinterpret_cast ^>(DelInst); - - // Create an array of strings - array ^ words = { "orange", "apple", "Article", "elephant" }; - - // Query the array and select strings according to the selector method - Generic::IEnumerable ^ aWords = Enumerable::Select((Generic::IEnumerable^)words, selector); - - // Output the results to the console - for each(String ^ word in aWords) - Console::WriteLine(word); - /* - This code example produces the following output: - - ORANGE - APPLE - ARTICLE - ELEPHANT - */ -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.GC.Collect Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.GC.Collect Example/CPP/class1.cpp deleted file mode 100644 index 8583565fa53..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.GC.Collect Example/CPP/class1.cpp +++ /dev/null @@ -1,31 +0,0 @@ - -// -using namespace System; - -const int maxGarbage = 1000; - -void MakeSomeGarbage() -{ - Version^ vt; - for ( int i = 0; i < maxGarbage; i++ ) { - // Create objects and release them to fill up memory with unused objects. - vt = gcnew Version; - } -} - -void main() -{ - // Put some objects in memory. - MakeSomeGarbage(); - Console::WriteLine("Memory used before collection: {0:N0}", - GC::GetTotalMemory( false ) ); - - // Collect all generations of memory. - GC::Collect(); - Console::WriteLine("Memory used after full collection: {0:N0}", - GC::GetTotalMemory( true ) ); -} -// The output from the example resembles the following: -// Memory used before collection: 79,392 -// Memory used after full collection: 52,640 -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.GC.GetGenerationWeak Example/CPP/systemgcgetgenerationweak.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.GC.GetGenerationWeak Example/CPP/systemgcgetgenerationweak.cpp deleted file mode 100644 index e3587de2c56..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.GC.GetGenerationWeak Example/CPP/systemgcgetgenerationweak.cpp +++ /dev/null @@ -1,72 +0,0 @@ - -// -using namespace System; -ref class MyGCCollectClass -{ -private: - static const long maxGarbage = 1000; - -public: - void MakeSomeGarbage() - { - Version^ vt; - for ( int i = 0; i < maxGarbage; i++ ) - { - - // Create objects and release them to fill up memory - // with unused objects. - vt = gcnew Version; - - } - } - -}; - -int main() -{ - - // Create a strong reference to an Object. - MyGCCollectClass^ myGCCol = gcnew MyGCCollectClass; - - // Put some objects in memory. - myGCCol->MakeSomeGarbage(); - - // Get the generation of managed memory where myGCCol is stored. - Console::WriteLine( "The object is in generation: {0}", GC::GetGeneration( myGCCol ) ); - - // Perform a full garbage collection. - // Because there is a strong reference to myGCCol, it will - // not be garbage collected. - GC::Collect(); - - // Get the generation of managed memory where myGCCol is stored. - Console::WriteLine( "The object is in generation: {0}", GC::GetGeneration( myGCCol ) ); - - // Create a WeakReference to myGCCol. - WeakReference^ wkref = gcnew WeakReference( myGCCol ); - - // Remove the strong reference to myGCCol. - myGCCol = nullptr; - - // Get the generation of managed memory where wkref is stored. - Console::WriteLine( "The WeakReference to the object is in generation: {0}", GC::GetGeneration( wkref ) ); - - // Perform another full garbage collection. - // A WeakReference will not survive a garbage collection. - GC::Collect(); - - // Try to get the generation of managed memory where wkref is stored. - // Because it has been collected, an exception will be thrown. - try - { - Console::WriteLine( "The WeakReference to the object is in generation: {0}", GC::GetGeneration( wkref ) ); - Console::Read(); - } - catch ( Exception^ e ) - { - Console::WriteLine( "The WeakReference to the object has been garbage collected: ' {0}'", e ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.GC.KeepAlive Example2/CPP/gckeepalive.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.GC.KeepAlive Example2/CPP/gckeepalive.cpp deleted file mode 100644 index b457b3d8f57..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.GC.KeepAlive Example2/CPP/gckeepalive.cpp +++ /dev/null @@ -1,108 +0,0 @@ - -// -using namespace System; -using namespace System::Threading; -using namespace System::Runtime::InteropServices; - -// A simple class that exposes two static Win32 functions. -// One is a delegate type and the other is an enumerated type. -public ref class MyWin32 -{ -public: - - // An enumerated type for the control messages sent to the handler routine. - enum class CtrlTypes - { - CTRL_C_EVENT = 0, - CTRL_BREAK_EVENT, CTRL_CLOSE_EVENT, CTRL_LOGOFF_EVENT = 5, - CTRL_SHUTDOWN_EVENT - }; - - delegate Boolean HandlerRoutine( // A delegate type to be used as the Handler Routine for SetConsoleCtrlHandler. - CtrlTypes CtrlType ); - - // Declare the SetConsoleCtrlHandler function as external and receiving a delegate. - - [DllImport("Kernel32")] - static Boolean SetConsoleCtrlHandler( HandlerRoutine^ Handler, Boolean Add ); -}; - -public ref class MyApp -{ -private: - - // A private static handler function in the MyApp class. - static Boolean Handler( MyWin32::CtrlTypes CtrlType ) - { - String^ message = "This message should never be seen!"; - - // A switch to handle the event type. - switch ( CtrlType ) - { - case MyWin32::CtrlTypes::CTRL_C_EVENT: - message = "A CTRL_C_EVENT was raised by the user."; - break; - - case MyWin32::CtrlTypes::CTRL_BREAK_EVENT: - message = "A CTRL_BREAK_EVENT was raised by the user."; - break; - - case MyWin32::CtrlTypes::CTRL_CLOSE_EVENT: - message = "A CTRL_CLOSE_EVENT was raised by the user."; - break; - - case MyWin32::CtrlTypes::CTRL_LOGOFF_EVENT: - message = "A CTRL_LOGOFF_EVENT was raised by the user."; - break; - - case MyWin32::CtrlTypes::CTRL_SHUTDOWN_EVENT: - message = "A CTRL_SHUTDOWN_EVENT was raised by the user."; - break; - } - - // Use interop to display a message for the type of event. - Console::WriteLine( message ); - return true; - } - - -public: - static void Test() - { - - // Use interop to set a console control handler. - MyWin32::HandlerRoutine^ hr = gcnew MyWin32::HandlerRoutine( Handler ); - MyWin32::SetConsoleCtrlHandler( hr, true ); - - // Give the user some time to raise a few events. - Console::WriteLine( "Waiting 30 seconds for console ctrl events..." ); - - // The Object hr is not referred to again. - // The garbage collector can detect that the object has no - // more managed references and might clean it up here while - // the unmanaged SetConsoleCtrlHandler method is still using it. - // Force a garbage collection to demonstrate how the hr - // object will be handled. - GC::Collect(); - GC::WaitForPendingFinalizers(); - GC::Collect(); - Thread::Sleep( 30000 ); - - // Display a message to the console when the unmanaged method - // has finished its work. - Console::WriteLine( "Finished!" ); - - // Call GC::KeepAlive(hr) at this point to maintain a reference to hr. - // This will prevent the garbage collector from collecting the - // object during the execution of the SetConsoleCtrlHandler method. - GC::KeepAlive( hr ); - } - -}; - -int main() -{ - MyApp::Test(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.GC.ReRegisterForFinalize Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.GC.ReRegisterForFinalize Example/CPP/class1.cpp deleted file mode 100644 index 9a8cc79ec77..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.GC.ReRegisterForFinalize Example/CPP/class1.cpp +++ /dev/null @@ -1,64 +0,0 @@ - -// -using namespace System; -ref class MyFinalizeObject -{ -public: - static MyFinalizeObject^ currentInstance = nullptr; - -private: - bool hasFinalized; - -public: - MyFinalizeObject() - { - hasFinalized = false; - } - - ~MyFinalizeObject() - { - if ( !hasFinalized ) - { - Console::WriteLine( "First finalization" ); - - // Put this object back into a root by creating - // a reference to it. - MyFinalizeObject::currentInstance = this; - - // Indicate that this instance has finalized once. - hasFinalized = true; - - // Place a reference to this object back in the - // finalization queue. - GC::ReRegisterForFinalize( this ); - } - else - { - Console::WriteLine( "Second finalization" ); - } - } - -}; - -int main() -{ - - // Create a MyFinalizeObject. - MyFinalizeObject^ mfo = gcnew MyFinalizeObject; - - // Release the reference to mfo. - mfo = nullptr; - - // Force a garbage collection. - GC::Collect(); - - // At this point mfo will have gone through the first Finalize. - // There should now be a reference to mfo in the static - // MyFinalizeObject::currentInstance field. Setting this value - // to 0 and forcing another garbage collection will now - // cause the object to Finalize permanently. - MyFinalizeObject::currentInstance = nullptr; - GC::Collect(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.GC.WaitForPendingFinalizers Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.GC.WaitForPendingFinalizers Example/CPP/class1.cpp deleted file mode 100644 index c542afe35eb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.GC.WaitForPendingFinalizers Example/CPP/class1.cpp +++ /dev/null @@ -1,70 +0,0 @@ - -// -using namespace System; -ref class MyFinalizeObject -{ -private: - - // Make this number very large to cause the finalizer to - // do more work. - literal int maxIterations = 10000; - ~MyFinalizeObject() - { - Console::WriteLine( "Finalizing a MyFinalizeObject" ); - - // Do some work. - for ( int i = 0; i < maxIterations; i++ ) - { - - // This method performs no operation on i, but prevents - // the JIT compiler from optimizing away the code inside - // the loop. - GC::KeepAlive( i ); - - } - } - -}; - - -// You can increase this number to fill up more memory. -const int numMfos = 1000; - -// You can increase this number to cause more -// post-finalization work to be done. -const int maxIterations = 100; -int main() -{ - MyFinalizeObject^ mfo = nullptr; - - // Create and release a large number of objects - // that require finalization. - for ( int j = 0; j < numMfos; j++ ) - { - mfo = gcnew MyFinalizeObject; - - } - - //Release the last object created in the loop. - mfo = nullptr; - - //Force garbage collection. - GC::Collect(); - - // Wait for all finalizers to complete before continuing. - // Without this call to GC::WaitForPendingFinalizers, - // the worker loop below might execute at the same time - // as the finalizers. - // With this call, the worker loop executes only after - // all finalizers have been called. - GC::WaitForPendingFinalizers(); - - // Worker loop to perform post-finalization code. - for ( int i = 0; i < maxIterations; i++ ) - { - Console::WriteLine( "Doing some post-finalize work" ); - - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IConvertible/CPP/iconvertible.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IConvertible/CPP/iconvertible.cpp deleted file mode 100644 index 8b5d97c0b94..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IConvertible/CPP/iconvertible.cpp +++ /dev/null @@ -1,144 +0,0 @@ - - -// -#using - -using namespace System; - -/// Class that implements IConvertible -ref class Complex: public IConvertible -{ -private: - double x; - double y; - -public: - Complex( double x, double y ) - { - this->x = x; - this->y = y; - } - - virtual TypeCode GetTypeCode() - { - return TypeCode::Object; - } - - virtual bool ToBoolean( IFormatProvider^ /*provider*/ ) = IConvertible::ToBoolean - { - if ( (x != 0.0) || (y != 0.0) ) - return true; - else - return false; - } - - double GetDoubleValue() - { - return Math::Sqrt( x * x + y * y ); - } - - virtual Byte ToByte( IFormatProvider^ /*provider*/ ) = IConvertible::ToByte - { - return Convert::ToByte( GetDoubleValue() ); - } - - virtual Char ToChar( IFormatProvider^ /*provider*/ ) = IConvertible::ToChar - { - return Convert::ToChar( GetDoubleValue() ); - } - - virtual DateTime ToDateTime( IFormatProvider^ /*provider*/ ) = IConvertible::ToDateTime - { - return Convert::ToDateTime( GetDoubleValue() ); - } - - virtual Decimal ToDecimal( IFormatProvider^ /*provider*/ ) = IConvertible::ToDecimal - { - return Convert::ToDecimal( GetDoubleValue() ); - } - - virtual double ToDouble( IFormatProvider^ /*provider*/ ) = IConvertible::ToDouble - { - return GetDoubleValue(); - } - - virtual short ToInt16( IFormatProvider^ /*provider*/ ) = IConvertible::ToInt16 - { - return Convert::ToInt16( GetDoubleValue() ); - } - - virtual int ToInt32( IFormatProvider^ /*provider*/ ) = IConvertible::ToInt32 - { - return Convert::ToInt32( GetDoubleValue() ); - } - - virtual Int64 ToInt64( IFormatProvider^ /*provider*/ ) = IConvertible::ToInt64 - { - return Convert::ToInt64( GetDoubleValue() ); - } - - virtual signed char ToSByte( IFormatProvider^ /*provider*/ ) = IConvertible::ToSByte - { - return Convert::ToSByte( GetDoubleValue() ); - } - - virtual float ToSingle( IFormatProvider^ /*provider*/ ) = IConvertible::ToSingle - { - return Convert::ToSingle( GetDoubleValue() ); - } - - virtual String^ ToString( IFormatProvider^ /*provider*/ ) = IConvertible::ToString - { - return String::Format( "( {0} , {1} )", x, y ); - } - - virtual Object^ ToType( Type^ conversionType, IFormatProvider^ /*provider*/ ) = IConvertible::ToType - { - return Convert::ChangeType( GetDoubleValue(), conversionType ); - } - - virtual UInt16 ToUInt16( IFormatProvider^ /*provider*/ ) = IConvertible::ToUInt16 - { - return Convert::ToUInt16( GetDoubleValue() ); - } - - virtual UInt32 ToUInt32( IFormatProvider^ /*provider*/ ) = IConvertible::ToUInt32 - { - return Convert::ToUInt32( GetDoubleValue() ); - } - - virtual UInt64 ToUInt64( IFormatProvider^ /*provider*/ ) = IConvertible::ToUInt64 - { - return Convert::ToUInt64( GetDoubleValue() ); - } - -}; - -void WriteObjectInfo( Object^ testObject ) -{ - TypeCode typeCode = Type::GetTypeCode( testObject->GetType() ); - switch ( typeCode ) - { - case TypeCode::Boolean: - Console::WriteLine( "Boolean: {0}", testObject ); - break; - - case TypeCode::Double: - Console::WriteLine( "Double: {0}", testObject ); - break; - - default: - Console::WriteLine( "{0}: {1}", typeCode, testObject ); - break; - } -} - -int main() -{ - Complex^ testComplex = gcnew Complex( 4,7 ); - WriteObjectInfo( testComplex ); - WriteObjectInfo( Convert::ToBoolean( testComplex ) ); - WriteObjectInfo( Convert::ToDecimal( testComplex ) ); - WriteObjectInfo( Convert::ToString( testComplex ) ); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.IDisposable.Dispose Example/CPP/idisposabledispose.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.IDisposable.Dispose Example/CPP/idisposabledispose.cpp deleted file mode 100644 index 7ec610d0749..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.IDisposable.Dispose Example/CPP/idisposabledispose.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::ComponentModel; -using namespace System::Windows::Forms; - -// The following example demonstrates how to create a class that -// implements the IDisposable interface and the IDisposable.Dispose -// method with finalization to clean up unmanaged resources. -// -public ref class MyResource: public IDisposable -{ -private: - - // Pointer to an external unmanaged resource. - IntPtr handle; - - // A managed resource this class uses. - Component^ component; - - // Track whether Dispose has been called. - bool disposed; - -public: - // The class constructor. - MyResource( IntPtr handle, Component^ component ) - { - this->handle = handle; - this->component = component; - disposed = false; - } - - // This method is called if the user explicitly disposes of the - // object (by calling the Dispose method in other managed languages, - // or the destructor in C++). The compiler emits as a call to - // GC::SuppressFinalize( this ) for you, so there is no need to - // call it here. - ~MyResource() - { - // Dispose of managed resources. - component->~Component(); - - // Call C++ finalizer to clean up unmanaged resources. - this->!MyResource(); - - // Mark the class as disposed. This flag allows you to throw an - // exception if a disposed object is accessed. - disposed = true; - } - - // Use interop to call the method necessary to clean up the - // unmanaged resource. - // - [System::Runtime::InteropServices::DllImport("Kernel32")] - static Boolean CloseHandle( IntPtr handle ); - - // The C++ finalizer destructor ensures that unmanaged resources get - // released if the user releases the object without explicitly - // disposing of it. - // - !MyResource() - { - // Call the appropriate methods to clean up unmanaged - // resources here. If disposing is false when Dispose(bool, - // disposing) is called, only the following code is executed. - CloseHandle( handle ); - handle = IntPtr::Zero; - } - -}; - -void main() -{ - // Insert code here to create and use the MyResource object. - MyResource^ mr = gcnew MyResource((IntPtr) 42, (Component^) gcnew Button()); - mr->~MyResource(); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Int16.MaxValue/cpp/minvalue.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Int16.MaxValue/cpp/minvalue.cpp deleted file mode 100644 index ced314ab27c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Int16.MaxValue/cpp/minvalue.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// MinValue.cpp : main project file. - -using namespace System; - -int main(array ^args) -{ - // - array^ numbersToConvert = {162345, 32183, -54000}; - Int16 newNumber; - for each (Int64 number in numbersToConvert) - { - if (number >= Int16::MinValue && number <= Int16::MaxValue) - { - newNumber = Convert::ToInt16(number); - Console::WriteLine("Successfully converted {0} to an Int16.", - newNumber); - } - else - { - Console::WriteLine("Unable to convert {0} to an Int16.", number); - } - } - // The example displays the following output: - // Unable to convert 162345 to an Int16. - // Successfully converted 32183 to an Int16. - // Unable to convert -54000 to an Int16. - // - Console::ReadLine(); - return 0; -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Int16.Parse/cpp/parse1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Int16.Parse/cpp/parse1.cpp deleted file mode 100644 index aeaef4e7bea..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Int16.Parse/cpp/parse1.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Parse1.cpp : main project file. -// Code example for Int16.Parse(String) - -using namespace System; - -int main(array ^args) -{ - // - String^ value; - Int16 number; - - value = " 12603 "; - try - { - number = Int16::Parse(value); - Console::WriteLine("Converted '{0}' to {1}.", value, number); - } - catch (FormatException ^e) - { - Console::WriteLine("Unable to convert '{0}' to a 16-bit signed integer.", - value); - } - - value = " 16,054"; - try - { - number = Int16::Parse(value); - Console::WriteLine("Converted '{0}' to {1}.", value, number); - } - catch (FormatException ^e) - { - Console::WriteLine("Unable to convert '{0}' to a 16-bit signed integer.", - value); - } - - value = " -17264"; - try - { - number = Int16::Parse(value); - Console::WriteLine("Converted '{0}' to {1}.", value, number); - } - catch (FormatException ^e) - { - Console::WriteLine("Unable to convert '{0}' to a 16-bit signed integer.", - value); - } - // The example displays the following output to the console: - // Converted ' 12603 ' to 12603. - // Unable to convert ' 16,054' to a 16-bit signed integer. - // Converted ' -17264' to -17264. - // - Console::ReadLine(); - return 0; -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Int16.Parse/cpp/parse2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Int16.Parse/cpp/parse2.cpp deleted file mode 100644 index 0b5222a1f6f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Int16.Parse/cpp/parse2.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// Parse2.cpp : main project file. - -// -using namespace System; -using namespace System::Globalization; - -ref class ParseSample -{ -public: - static void Main() - { - String^ value; - NumberStyles style; - - // Parse a number with a thousands separator (throws an exception). - value = "14,644"; - style = NumberStyles::None; - ParseSample::ParseToInt16(value, style); - - style = NumberStyles::AllowThousands; - ParseToInt16(value, style); - - // Parse a number with a thousands separator and decimal point. - value = "14,644.00"; - style = NumberStyles::AllowThousands | NumberStyles::Integer | - NumberStyles::AllowDecimalPoint; - ParseToInt16(value, style); - - // Parse a number with a fractional component (throws an exception). - value = "14,644.001"; - ParseToInt16(value, style); - - // Parse a number in exponential notation. - value = "145E02"; - style = style | NumberStyles::AllowExponent; - ParseToInt16(value, style); - - // Parse a number in exponential notation with a positive sign. - value = "145E+02"; - ParseToInt16(value, style); - - // Parse a number in exponential notation with a negative sign - // (throws an exception). - value = "145E-02"; - ParseToInt16(value, style); - } - -private: - static void ParseToInt16(String^ value, NumberStyles style) - { - try - { - Int16 number = Int16::Parse(value, style); - Console::WriteLine("Converted '{0}' to {1}.", value, number); - } - catch (FormatException ^e) - { - Console::WriteLine("Unable to parse '{0}' with style {1}.", value, - style); - } - catch (OverflowException ^e) - { - Console::WriteLine("'{0}' is out of range of the Int16 type.", value); - } - } -}; - -int main() -{ - ParseSample::Main(); - Console::ReadLine(); - return 0; -} -// The example displays the following output: -// Unable to parse '14,644' with style None. -// Converted '14,644' to 14644. -// Converted '14,644.00' to 14644. -// '14,644.001' is out of range of the Int16 type. -// Converted '145E02' to 14500. -// Converted '145E+02' to 14500. -// '145E-02' is out of range of the Int16 type. -// - - - - - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Int16.Parse/cpp/parse3.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Int16.Parse/cpp/parse3.cpp deleted file mode 100644 index e17d9457ac6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Int16.Parse/cpp/parse3.cpp +++ /dev/null @@ -1,62 +0,0 @@ -// Parse3.cpp : main project file. - -using namespace System; -using namespace System::Globalization; - -int main(array ^args) -{ - // - String^ value; - Int16 number; - NumberStyles style; - - // Parse string using "." as the thousands separator - // and " " as the decimal separator. - value = "19 694,00"; - style = NumberStyles::AllowDecimalPoint | NumberStyles::AllowThousands; - CultureInfo^ provider = gcnew CultureInfo("fr-FR"); - - number = Int16::Parse(value, style, provider); - Console::WriteLine("'{0}' converted to {1}.", value, number); - // Displays: - // '19 694,00' converted to 19694. - - try - { - number = Int16::Parse(value, style, CultureInfo::InvariantCulture); - Console::WriteLine("'{0}' converted to {1}.", value, number); - } - catch (FormatException ^e) - { - Console::WriteLine("Unable to parse '{0}'.", value); - } - // Displays: - // Unable to parse '19 694,00'. - - // Parse string using "$" as the currency symbol for en_GB and - // en-US cultures. - value = "$6,032.00"; - style = NumberStyles::Number | NumberStyles::AllowCurrencySymbol; - provider = gcnew CultureInfo("en-GB"); - - try - { - number = Int16::Parse(value, style, CultureInfo::InvariantCulture); - Console::WriteLine("'{0}' converted to {1}.", value, number); - } - catch (FormatException ^e) - { - Console::WriteLine("Unable to parse '{0}'.", value); - } - // Displays: - // Unable to parse '$6,032.00'. - - provider = gcnew CultureInfo("en-US"); - number = Int16::Parse(value, style, provider); - Console::WriteLine("'{0}' converted to {1}.", value, number); - // Displays: - // '$6,032.00' converted to 6032. - // - Console::ReadLine(); - return 0; -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Int16.Parse/cpp/parse4.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Int16.Parse/cpp/parse4.cpp deleted file mode 100644 index 111fb90e90d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Int16.Parse/cpp/parse4.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// Parse4.cpp : main project file. - -using namespace System; -using namespace System::Globalization; - -int main(array ^args) -{ - // - String^ stringToConvert; - Int16 number; - - stringToConvert = " 214 "; - try - { - number = Int16::Parse(stringToConvert, CultureInfo::InvariantCulture); - Console::WriteLine("Converted '{0}' to {1}.", stringToConvert, number); - } - catch (FormatException ^e) - { - Console::WriteLine("Unable to parse '{0}'.", stringToConvert); - } - catch (OverflowException ^e) - { - Console::WriteLine("'{0'} is out of range of the Int16 data type.", - stringToConvert); - } - - stringToConvert = " + 214"; - try - { - number = Int16::Parse(stringToConvert, CultureInfo::InvariantCulture); - Console::WriteLine("Converted '{0}' to {1}.", stringToConvert, number); - } - catch (FormatException ^e) - { - Console::WriteLine("Unable to parse '{0}'.", stringToConvert); - } - catch (OverflowException ^e) - { - Console::WriteLine("'{0'} is out of range of the Int16 data type.", - stringToConvert); - } - - stringToConvert = " +214 "; - try - { - number = Int16::Parse(stringToConvert, CultureInfo::InvariantCulture); - Console::WriteLine("Converted '{0}' to {1}.", stringToConvert, number); - } - catch (FormatException ^e) - { - Console::WriteLine("Unable to parse '{0}'.", stringToConvert); - } - catch (OverflowException ^e) - { - Console::WriteLine("'{0'} is out of range of the Int16 data type.", - stringToConvert); - } - // The example displays the following output to the console: - // Converted ' 214 ' to 214. - // Unable to parse ' + 214'. - // Converted ' +214 ' to 214. - // - Console::ReadLine(); - return 0; -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Int32.Parse/cpp/parse1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Int32.Parse/cpp/parse1.cpp deleted file mode 100644 index 3eb4dcbf5d3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Int32.Parse/cpp/parse1.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// -using namespace System; - -void main() -{ - array^ values = { "+13230", "-0", "1,390,146", "$190,235,421,127", - "0xFA1B", "163042", "-10", "007", "2147483647", - "2147483648", "16e07", "134985.0", "-12034", - "-2147483648", "-2147483649" }; - for each (String^ value in values) - { - try { - Int32 number = Int32::Parse(value); - Console::WriteLine("{0} --> {1}", value, number); - } - catch (FormatException^ e) { - Console::WriteLine("{0}: Bad Format", value); - } - catch (OverflowException^ e) { - Console::WriteLine("{0}: Overflow", value); - } - } -} -// The example displays the following output: -// +13230 --> 13230 -// -0 --> 0 -// 1,390,146: Bad Format -// $190,235,421,127: Bad Format -// 0xFA1B: Bad Format -// 163042 --> 163042 -// -10 --> -10 -// 007 --> 7 -// 2147483647 --> 2147483647 -// 2147483648: Overflow -// 16e07: Bad Format -// 134985.0: Bad Format -// -12034 --> -12034 -// -2147483648 --> -2147483648 -// -2147483649: Overflow -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Int32.Parse/cpp/parse2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Int32.Parse/cpp/parse2.cpp deleted file mode 100644 index 763b56c34a5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Int32.Parse/cpp/parse2.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// -using namespace System; -using namespace System::Globalization; - -public ref class ParseInt32 -{ -public: - static void Main() - { - Convert("104.0", NumberStyles::AllowDecimalPoint); - Convert("104.9", NumberStyles::AllowDecimalPoint); - Convert(" $17,198,064.42", NumberStyles::AllowCurrencySymbol | - NumberStyles::Number); - Convert("103E06", NumberStyles::AllowExponent); - Convert("-1,345,791", NumberStyles::AllowThousands); - Convert("(1,345,791)", NumberStyles::AllowThousands | - NumberStyles::AllowParentheses); - } - -private: - static void Convert(String^ value, NumberStyles style) - { - try - { - int number = Int32::Parse(value, style); - Console::WriteLine("Converted '{0}' to {1}.", value, number); - } - catch (FormatException^) - { - Console::WriteLine("Unable to convert '{0}'.", value); - } - catch (OverflowException^) - { - Console::WriteLine("'{0}' is out of range of the Int32 type.", value); - } - } -}; - -int main() -{ - ParseInt32::Main(); -} -// The example displays the following output to the console: -// Converted '104.0' to 104. -// '104.9' is out of range of the Int32 type. -// ' $17,198,064.42' is out of range of the Int32 type. -// Converted '103E06' to 103000000. -// Unable to convert '-1,345,791'. -// Converted '(1,345,791)' to -1345791. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Int32.Parse/cpp/parse3.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Int32.Parse/cpp/parse3.cpp deleted file mode 100644 index 6d7ea5b521f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Int32.Parse/cpp/parse3.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// -using namespace System; -using namespace System::Globalization; - -public ref class ParseInt32 -{ -public: - static void Main() - { - Convert("12,000", NumberStyles::Float | NumberStyles::AllowThousands, - gcnew CultureInfo("en-GB")); - Convert("12,000", NumberStyles::Float | NumberStyles::AllowThousands, - gcnew CultureInfo("fr-FR")); - Convert("12,000", NumberStyles::Float, gcnew CultureInfo("en-US")); - - Convert("12 425,00", NumberStyles::Float | NumberStyles::AllowThousands, - gcnew CultureInfo("sv-SE")); - Convert("12,425.00", NumberStyles::Float | NumberStyles::AllowThousands, - NumberFormatInfo::InvariantInfo); - Convert("631,900", NumberStyles::Integer | NumberStyles::AllowDecimalPoint, - gcnew CultureInfo("fr-FR")); - Convert("631,900", NumberStyles::Integer | NumberStyles::AllowDecimalPoint, - gcnew CultureInfo("en-US")); - Convert("631,900", NumberStyles::Integer | NumberStyles::AllowThousands, - gcnew CultureInfo("en-US")); - } - -private: - static void Convert(String^ value, NumberStyles style, - IFormatProvider^ provider) - { - try - { - int number = Int32::Parse(value, style, provider); - Console::WriteLine("Converted '{0}' to {1}.", value, number); - } - catch (FormatException^) - { - Console::WriteLine("Unable to convert '{0}'.", value); - } - catch (OverflowException^) - { - Console::WriteLine("'{0}' is out of range of the Int32 type.", value); - } - } -}; - -int main() -{ - ParseInt32::Main(); -} -// This example displays the following output to the console: -// Converted '12,000' to 12000. -// Converted '12,000' to 12. -// Unable to convert '12,000'. -// Converted '12 425,00' to 12425. -// Converted '12,425.00' to 12425. -// '631,900' is out of range of the Int32 type. -// Unable to convert '631,900'. -// Converted '631,900' to 631900. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Int32.ToString/cpp/ToString1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Int32.ToString/cpp/ToString1.cpp deleted file mode 100644 index 490a4147b45..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Int32.ToString/cpp/ToString1.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// -using namespace System; - -void main() -{ - int value = -16325; - // Display value using default ToString method. - Console::WriteLine(value.ToString()); - // Display value using some standard format specifiers. - Console::WriteLine(value.ToString("G")); - Console::WriteLine(value.ToString("C")); - Console::WriteLine(value.ToString("D")); - Console::WriteLine(value.ToString("F")); - Console::WriteLine(value.ToString("N")); - Console::WriteLine(value.ToString("X")); -} -// The example displays the following output: -// -16325 -// -16325 -// ($16,325.00) -// -16325 -// -16325.00 -// -16,325.00 -// FFFFC03B -// - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Int32.ToString/cpp/ToString2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Int32.ToString/cpp/ToString2.cpp deleted file mode 100644 index 9db3bc117d2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Int32.ToString/cpp/ToString2.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// -using namespace System; -using namespace System::Globalization; - -void main() -{ - int value = -16325; - // Display value using the invariant culture. - Console::WriteLine(value.ToString(CultureInfo::InvariantCulture)); - // Display value using the en-GB culture. - Console::WriteLine(value.ToString(CultureInfo::CreateSpecificCulture("en-GB"))); - // Display value using the de-DE culture. - Console::WriteLine(value.ToString(CultureInfo::CreateSpecificCulture("de-DE"))); -} -// The example displays the following output: -// -16325 -// -16325 -// -16325 -// - - - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Int32.ToString/cpp/ToString3.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Int32.ToString/cpp/ToString3.cpp deleted file mode 100644 index 890b1ae948c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Int32.ToString/cpp/ToString3.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// -using namespace System; - -void main() -{ - int value = -16325; - String^ specifier; - - // Use standard numeric format specifiers. - specifier = "G"; - Console::WriteLine("{0}: {1}", specifier, value.ToString(specifier)); - - specifier = "C"; - Console::WriteLine("{0}: {1}", specifier, value.ToString(specifier)); - - specifier = "D8"; - Console::WriteLine("{0}: {1}", specifier, value.ToString(specifier)); - - specifier = "E4"; - Console::WriteLine("{0}: {1}", specifier, value.ToString(specifier)); - - specifier = "e3"; - Console::WriteLine("{0}: {1}", specifier, value.ToString(specifier)); - - specifier = "F"; - Console::WriteLine("{0}: {1}", specifier, value.ToString(specifier)); - - specifier = "N"; - Console::WriteLine("{0}: {1}", specifier, value.ToString(specifier)); - - specifier = "P"; - Console::WriteLine("{0}: {1}", specifier, (value/100000).ToString(specifier)); - - specifier = "X"; - Console::WriteLine("{0}: {1}", specifier, value.ToString(specifier)); - - // Use custom numeric format specifiers. - specifier = "0,0.000"; - Console::WriteLine("{0}: {1}", specifier, value.ToString(specifier)); - - specifier = "#,#.00#;(#,#.00#)"; - Console::WriteLine("{0}: {1}", specifier, (value*-1).ToString(specifier)); -} -// The example displays the following output: -// G: -16325 -// C: ($16,325.00) -// D8: -00016325 -// E4: -1.6325E+004 -// e3: -1.633e+004 -// F: -16325.00 -// N: -16,325.00 -// P: 0.00 % -// X: FFFFC03B -// 0,0.000: -16,325.000 -// #,#.00#;(#,#.00#): 16,325.00 -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Int32.ToString/cpp/ToString4.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Int32.ToString/cpp/ToString4.cpp deleted file mode 100644 index 60f27268433..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Int32.ToString/cpp/ToString4.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// -using namespace System; -using namespace System::Globalization; - -void main() -{ - // Define cultures whose formatting conventions are to be used. - array^ cultures = { CultureInfo::CreateSpecificCulture("en-US"), - CultureInfo::CreateSpecificCulture("fr-FR"), - CultureInfo::CreateSpecificCulture("es-ES") }; - int positiveNumber = 1679; - int negativeNumber = -3045; - array^ specifiers = {"G", "C", "D8", "E2", "F", "N", "P", "X8"}; - - for each (String^ specifier in specifiers) - { - for each (CultureInfo^ culture in cultures) - { - // Display values with "G" format specifier. - Console::WriteLine("{0} format using {1} culture: {2, 16} {3, 16}", - specifier, culture->Name, - positiveNumber.ToString(specifier, culture), - negativeNumber.ToString(specifier, culture)); - } - Console::WriteLine(); - } -} -// The example displays the following output: -// G format using en-US culture: 1679 -3045 -// G format using fr-FR culture: 1679 -3045 -// G format using es-ES culture: 1679 -3045 -// -// C format using en-US culture: $1,679.00 ($3,045.00) -// C format using fr-FR culture: 1 679,00 € -3 045,00 € -// C format using es-ES culture: 1.679,00 € -3.045,00 € -// -// D8 format using en-US culture: 00001679 -00003045 -// D8 format using fr-FR culture: 00001679 -00003045 -// D8 format using es-ES culture: 00001679 -00003045 -// -// E2 format using en-US culture: 1.68E+003 -3.05E+003 -// E2 format using fr-FR culture: 1,68E+003 -3,05E+003 -// E2 format using es-ES culture: 1,68E+003 -3,05E+003 -// -// F format using en-US culture: 1679.00 -3045.00 -// F format using fr-FR culture: 1679,00 -3045,00 -// F format using es-ES culture: 1679,00 -3045,00 -// -// N format using en-US culture: 1,679.00 -3,045.00 -// N format using fr-FR culture: 1 679,00 -3 045,00 -// N format using es-ES culture: 1.679,00 -3.045,00 -// -// P format using en-US culture: 167,900.00 % -304,500.00 % -// P format using fr-FR culture: 167 900,00 % -304 500,00 % -// P format using es-ES culture: 167.900,00 % -304.500,00 % -// -// X8 format using en-US culture: 0000068F FFFFF41B -// X8 format using fr-FR culture: 0000068F FFFFF41B -// X8 format using es-ES culture: 0000068F FFFFF41B -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Int32.TryParse/cpp/int32.tryparse1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Int32.TryParse/cpp/int32.tryparse1.cpp deleted file mode 100644 index 8772bdc80e3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Int32.TryParse/cpp/int32.tryparse1.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// ConsoleApplication1.cpp : Defines the entry point for the console application. -// - - -// -using namespace System; - - - void TryToParse(String^ value) - { - Int32 number; - bool result = Int32::TryParse(value, number); - if (result) { - Console::WriteLine("Converted '{0}' to {1}.", value, number); - } - else { - if (value == nullptr) value = ""; - Console::WriteLine("Attempted conversion of '{0}' failed.", value); - } - } - - -void main() -{ - TryToParse(nullptr); - TryToParse("160519"); - TryToParse("9432.0"); - TryToParse("16,667"); - TryToParse(" -322 "); - TryToParse("+4302"); - TryToParse("(100);"); - TryToParse("01FA"); -} -// The example displays the following output: -// Attempted conversion of '' failed. -// Converted '160519' to 160519. -// Attempted conversion of '9432.0' failed. -// Attempted conversion of '16,667' failed. -// Converted ' -322 ' to -322. -// Converted '+4302' to 4302. -// Attempted conversion of '(100);' failed. -// Attempted conversion of '01FA' failed. -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Int32.TryParse/cpp/int32.tryparse2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Int32.TryParse/cpp/int32.tryparse2.cpp deleted file mode 100644 index 0639d8b9dc6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Int32.TryParse/cpp/int32.tryparse2.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// Int32.TryParse2.cpp : Defines the entry point for the console application. -// - - -// -using namespace System; -using namespace System::Globalization; - -void CallTryParse(String^ stringToConvert, NumberStyles styles) -{ - Int32 number; - CultureInfo^ provider; - - // If currency symbol is allowed, use en-US culture. - if (((Int32) (styles & NumberStyles::AllowCurrencySymbol)) > 0) - provider = gcnew CultureInfo("en-US"); - else - provider = CultureInfo::InvariantCulture; - - bool result = Int32::TryParse(stringToConvert, styles, - provider, number); - if (result) - Console::WriteLine("Converted '{0}' to {1}.", stringToConvert, number); - else - Console::WriteLine("Attempted conversion of '{0}' failed.", - Convert::ToString(stringToConvert)); -} - -void main() -{ - String^ numericString; - NumberStyles styles; - - numericString = "106779"; - styles = NumberStyles::Integer; - CallTryParse(numericString, styles); - - numericString = "-30677"; - styles = NumberStyles::None; - CallTryParse(numericString, styles); - - styles = NumberStyles::AllowLeadingSign; - CallTryParse(numericString, styles); - - numericString = "301677-"; - CallTryParse(numericString, styles); - - styles = styles | NumberStyles::AllowTrailingSign; - CallTryParse(numericString, styles); - - numericString = "$10634"; - styles = NumberStyles::Integer; - CallTryParse(numericString, styles); - - styles = NumberStyles::Integer | NumberStyles::AllowCurrencySymbol; - CallTryParse(numericString, styles); - - numericString = "10345.00"; - styles = NumberStyles::Integer | NumberStyles::AllowDecimalPoint; - CallTryParse(numericString, styles); - - numericString = "10345.72"; - styles = NumberStyles::Integer | NumberStyles::AllowDecimalPoint; - CallTryParse(numericString, styles); - - numericString = "22,593"; - styles = NumberStyles::Integer | NumberStyles::AllowThousands; - CallTryParse(numericString, styles); - - numericString = "12E-01"; - styles = NumberStyles::Integer | NumberStyles::AllowExponent; - CallTryParse(numericString, styles); - - numericString = "12E03"; - CallTryParse(numericString, styles); - - numericString = "80c1"; - CallTryParse(numericString, NumberStyles::HexNumber); - - numericString = "0x80C1"; - CallTryParse(numericString, NumberStyles::HexNumber); - Console::ReadLine(); -} -// The example displays the following output: -// Converted '106779' to 106779. -// Attempted conversion of '-30677' failed. -// Converted '-30677' to -30677. -// Attempted conversion of '301677-' failed. -// Converted '301677-' to -301677. -// Attempted conversion of '$10634' failed. -// Converted '$10634' to 10634. -// Converted '10345.00' to 10345. -// Attempted conversion of '10345.72' failed. -// Converted '22,593' to 22593. -// Attempted conversion of '12E-01' failed. -// Converted '12E03' to 12000. -// Converted '80c1' to 32961. -// Attempted conversion of '0x80C1' failed. -// - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Math.E/CPP/efield.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Math.E/CPP/efield.cpp deleted file mode 100644 index 8a1d8bb47db..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Math.E/CPP/efield.cpp +++ /dev/null @@ -1,66 +0,0 @@ - -// -// Example for the Math::E field. -using namespace System; - -// Approximate E with a power series. -void CalcPowerSeries() -{ - double factorial = 1.0; - double PS = 0.0; - - // Stop iterating when the series converges, - // and prevent a runaway process. - for ( int n = 0; n < 999 && Math::Abs( Math::E - PS ) > 1.0E-15; n++ ) - { - - // Calculate a running factorial. - if ( n > 0 ) - factorial *= (double)n; - - // Calculate and display the power series. - PS += 1.0 / factorial; - Console::WriteLine( "PS({0:D2}) == {1:E16}, Math::E - PS({0:D2}) == {2:E16}", n, PS, Math::E - PS ); - - } -} - -int main() -{ - Console::WriteLine( "This example of Math::E == {0:E16}\n" - "generates the following output.\n", Math::E ); - Console::WriteLine( "Define the power series PS(n) = Sum(k->0,n)[1/k!]" ); - Console::WriteLine( " (limit n->infinity)PS(n) == e" ); - Console::WriteLine( "Display PS(n) and Math::E - PS(n), " - "and stop when delta < 1.0E-15\n" ); - CalcPowerSeries(); -} - -/* -This example of Math::E == 2.7182818284590451E+000 -generates the following output. - -Define the power series PS(n) = Sum(k->0,n)[1/k!] - (limit n->infinity)PS(n) == e -Display PS(n) and Math::E - PS(n), and stop when delta < 1.0E-15 - -PS(00) == 1.0000000000000000E+000, Math::E - PS(00) == 1.7182818284590451E+000 -PS(01) == 2.0000000000000000E+000, Math::E - PS(01) == 7.1828182845904509E-001 -PS(02) == 2.5000000000000000E+000, Math::E - PS(02) == 2.1828182845904509E-001 -PS(03) == 2.6666666666666665E+000, Math::E - PS(03) == 5.1615161792378572E-002 -PS(04) == 2.7083333333333330E+000, Math::E - PS(04) == 9.9484951257120535E-003 -PS(05) == 2.7166666666666663E+000, Math::E - PS(05) == 1.6151617923787498E-003 -PS(06) == 2.7180555555555554E+000, Math::E - PS(06) == 2.2627290348964380E-004 -PS(07) == 2.7182539682539684E+000, Math::E - PS(07) == 2.7860205076724043E-005 -PS(08) == 2.7182787698412700E+000, Math::E - PS(08) == 3.0586177750535626E-006 -PS(09) == 2.7182815255731922E+000, Math::E - PS(09) == 3.0288585284310443E-007 -PS(10) == 2.7182818011463845E+000, Math::E - PS(10) == 2.7312660577649694E-008 -PS(11) == 2.7182818261984929E+000, Math::E - PS(11) == 2.2605521898810821E-009 -PS(12) == 2.7182818282861687E+000, Math::E - PS(12) == 1.7287637987806193E-010 -PS(13) == 2.7182818284467594E+000, Math::E - PS(13) == 1.2285727990501982E-011 -PS(14) == 2.7182818284582302E+000, Math::E - PS(14) == 8.1490370007486490E-013 -PS(15) == 2.7182818284589949E+000, Math::E - PS(15) == 5.0182080713057076E-014 -PS(16) == 2.7182818284590429E+000, Math::E - PS(16) == 2.2204460492503131E-015 -PS(17) == 2.7182818284590455E+000, Math::E - PS(17) == -4.4408920985006262E-016 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Math.Exp/CPP/exp.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Math.Exp/CPP/exp.cpp deleted file mode 100644 index a74b9251364..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Math.Exp/CPP/exp.cpp +++ /dev/null @@ -1,96 +0,0 @@ - -// -// Example for the Math::Exp( double ) method. -using namespace System; - -// Evaluate logarithmic/exponential identity with a given argument. -void UseLnExp( double arg ) -{ - - // Evaluate e ^ ln(X) == ln(e ^ X) == X. - Console::WriteLine( "\n Math::Exp(Math::Log({0})) == {1:E16}\n" - " Math::Log(Math::Exp({0})) == {2:E16}", arg, Math::Exp( Math::Log( arg ) ), Math::Log( Math::Exp( arg ) ) ); -} - - -// Evaluate exponential identities that are functions of two arguments. -void UseTwoArgs( double argX, double argY ) -{ - - // Evaluate (e ^ X) * (e ^ Y) == e ^ (X + Y). - Console::WriteLine( "\nMath::Exp({0}) * Math::Exp({1}) == {2:E16}" - "\n Math::Exp({0} + {1}) == {3:E16}", argX, argY, Math::Exp( argX ) * Math::Exp( argY ), Math::Exp( argX + argY ) ); - - // Evaluate (e ^ X) ^ Y == e ^ (X * Y). - Console::WriteLine( " Math::Pow(Math::Exp({0}), {1}) == {2:E16}" - "\n Math::Exp({0} * {1}) == {3:E16}", argX, argY, Math::Pow( Math::Exp( argX ), argY ), Math::Exp( argX * argY ) ); - - // Evaluate X ^ Y == e ^ (Y * ln(X)). - Console::WriteLine( " Math::Pow({0}, {1}) == {2:E16}" - "\nMath::Exp({1} * Math::Log({0})) == {3:E16}", argX, argY, Math::Pow( argX, argY ), Math::Exp( argY * Math::Log( argX ) ) ); -} - -int main() -{ - Console::WriteLine( "This example of Math::Exp( double ) " - "generates the following output.\n" ); - Console::WriteLine( "Evaluate [e ^ ln(X) == ln(e ^ X) == X] " - "with selected values for X:" ); - UseLnExp( 0.1 ); - UseLnExp( 1.2 ); - UseLnExp( 4.9 ); - UseLnExp( 9.9 ); - Console::WriteLine( "\nEvaluate these identities with " - "selected values for X and Y:" ); - Console::WriteLine( " (e ^ X) * (e ^ Y) == e ^ (X + Y)" ); - Console::WriteLine( " (e ^ X) ^ Y == e ^ (X * Y)" ); - Console::WriteLine( " X ^ Y == e ^ (Y * ln(X))" ); - UseTwoArgs( 0.1, 1.2 ); - UseTwoArgs( 1.2, 4.9 ); - UseTwoArgs( 4.9, 9.9 ); -} - -/* -This example of Math::Exp( double ) generates the following output. - -Evaluate [e ^ ln(X) == ln(e ^ X) == X] with selected values for X: - - Math::Exp(Math::Log(0.1)) == 1.0000000000000001E-001 - Math::Log(Math::Exp(0.1)) == 1.0000000000000008E-001 - - Math::Exp(Math::Log(1.2)) == 1.2000000000000000E+000 - Math::Log(Math::Exp(1.2)) == 1.2000000000000000E+000 - - Math::Exp(Math::Log(4.9)) == 4.9000000000000012E+000 - Math::Log(Math::Exp(4.9)) == 4.9000000000000004E+000 - - Math::Exp(Math::Log(9.9)) == 9.9000000000000004E+000 - Math::Log(Math::Exp(9.9)) == 9.9000000000000004E+000 - -Evaluate these identities with selected values for X and Y: - (e ^ X) * (e ^ Y) == e ^ (X + Y) - (e ^ X) ^ Y == e ^ (X * Y) - X ^ Y == e ^ (Y * ln(X)) - -Math::Exp(0.1) * Math::Exp(1.2) == 3.6692966676192444E+000 - Math::Exp(0.1 + 1.2) == 3.6692966676192444E+000 - Math::Pow(Math::Exp(0.1), 1.2) == 1.1274968515793757E+000 - Math::Exp(0.1 * 1.2) == 1.1274968515793757E+000 - Math::Pow(0.1, 1.2) == 6.3095734448019331E-002 -Math::Exp(1.2 * Math::Log(0.1)) == 6.3095734448019344E-002 - -Math::Exp(1.2) * Math::Exp(4.9) == 4.4585777008251705E+002 - Math::Exp(1.2 + 4.9) == 4.4585777008251716E+002 - Math::Pow(Math::Exp(1.2), 4.9) == 3.5780924170885260E+002 - Math::Exp(1.2 * 4.9) == 3.5780924170885277E+002 - Math::Pow(1.2, 4.9) == 2.4433636334442981E+000 -Math::Exp(4.9 * Math::Log(1.2)) == 2.4433636334442981E+000 - -Math::Exp(4.9) * Math::Exp(9.9) == 2.6764450551890982E+006 - Math::Exp(4.9 + 9.9) == 2.6764450551891015E+006 - Math::Pow(Math::Exp(4.9), 9.9) == 1.1684908531676833E+021 - Math::Exp(4.9 * 9.9) == 1.1684908531676829E+021 - Math::Pow(4.9, 9.9) == 6.8067718210957060E+006 -Math::Exp(9.9 * Math::Log(4.9)) == 6.8067718210956985E+006 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Math.Log_Overloads/CPP/loggen.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Math.Log_Overloads/CPP/loggen.cpp deleted file mode 100644 index aa7f305520b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Math.Log_Overloads/CPP/loggen.cpp +++ /dev/null @@ -1,66 +0,0 @@ - -// -// Example for the Math::Log( double ) and Math::Log( double, double ) methods. -using namespace System; - -// Evaluate logarithmic identities that are functions of two arguments. -void UseBaseAndArg( double argB, double argX ) -{ - - // Evaluate log(B)[X] == 1 / log(X)[B]. - Console::WriteLine( "\n Math::Log({1}, {0}) == {2:E16}" - "\n 1.0 / Math::Log({0}, {1}) == {3:E16}", argB, argX, Math::Log( argX, argB ), 1.0 / Math::Log( argB, argX ) ); - - // Evaluate log(B)[X] == ln[X] / ln[B]. - Console::WriteLine( " Math::Log({1}) / Math::Log({0}) == {2:E16}", argB, argX, Math::Log( argX ) / Math::Log( argB ) ); - - // Evaluate log(B)[X] == log(B)[e] * ln[X]. - Console::WriteLine( "Math::Log(Math::E, {0}) * Math::Log({1}) == {2:E16}", argB, argX, Math::Log( Math::E, argB ) * Math::Log( argX ) ); -} - -void main() -{ - Console::WriteLine( "This example of Math::Log( double ) and " - "Math::Log( double, double )\n" - "generates the following output.\n" ); - Console::WriteLine( "Evaluate these identities with " - "selected values for X and B (base):" ); - Console::WriteLine( " log(B)[X] == 1 / log(X)[B]" ); - Console::WriteLine( " log(B)[X] == ln[X] / ln[B]" ); - Console::WriteLine( " log(B)[X] == log(B)[e] * ln[X]" ); - UseBaseAndArg( 0.1, 1.2 ); - UseBaseAndArg( 1.2, 4.9 ); - UseBaseAndArg( 4.9, 9.9 ); - UseBaseAndArg( 9.9, 0.1 ); -} - -/* -This example of Math::Log( double ) and Math::Log( double, double ) -generates the following output. - -Evaluate these identities with selected values for X and B (base): - log(B)[X] == 1 / log(X)[B] - log(B)[X] == ln[X] / ln[B] - log(B)[X] == log(B)[e] * ln[X] - - Math::Log(1.2, 0.1) == -7.9181246047624818E-002 - 1.0 / Math::Log(0.1, 1.2) == -7.9181246047624818E-002 - Math::Log(1.2) / Math::Log(0.1) == -7.9181246047624818E-002 -Math::Log(Math::E, 0.1) * Math::Log(1.2) == -7.9181246047624804E-002 - - Math::Log(4.9, 1.2) == 8.7166610085093179E+000 - 1.0 / Math::Log(1.2, 4.9) == 8.7166610085093161E+000 - Math::Log(4.9) / Math::Log(1.2) == 8.7166610085093179E+000 -Math::Log(Math::E, 1.2) * Math::Log(4.9) == 8.7166610085093179E+000 - - Math::Log(9.9, 4.9) == 1.4425396251981288E+000 - 1.0 / Math::Log(4.9, 9.9) == 1.4425396251981288E+000 - Math::Log(9.9) / Math::Log(4.9) == 1.4425396251981288E+000 -Math::Log(Math::E, 4.9) * Math::Log(9.9) == 1.4425396251981288E+000 - - Math::Log(0.1, 9.9) == -1.0043839404494075E+000 - 1.0 / Math::Log(9.9, 0.1) == -1.0043839404494075E+000 - Math::Log(0.1) / Math::Log(9.9) == -1.0043839404494075E+000 -Math::Log(Math::E, 9.9) * Math::Log(0.1) == -1.0043839404494077E+000 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Math.SinCos/CPP/sincos.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Math.SinCos/CPP/sincos.cpp deleted file mode 100644 index e16651faef4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Math.SinCos/CPP/sincos.cpp +++ /dev/null @@ -1,120 +0,0 @@ - -// -// Example for the trigonometric Math.Sin( double ) -// and Math.Cos( double ) methods. -using namespace System; - -// Evaluate trigonometric identities with a given angle. -void UseSineCosine( double degrees ) -{ - double angle = Math::PI * degrees / 180.0; - double sinAngle = Math::Sin( angle ); - double cosAngle = Math::Cos( angle ); - - // Evaluate sin^2(X) + cos^2(X) == 1. - Console::WriteLine( "\n Math::Sin({0} deg) == {1:E16}\n" - " Math::Cos({0} deg) == {2:E16}", degrees, Math::Sin( angle ), Math::Cos( angle ) ); - Console::WriteLine( "(Math::Sin({0} deg))^2 + (Math::Cos({0} deg))^2 == {1:E16}", degrees, sinAngle * sinAngle + cosAngle * cosAngle ); - - // Evaluate sin(2 * X) == 2 * sin(X) * cos(X). - Console::WriteLine( " Math::Sin({0} deg) == {1:E16}", 2.0 * degrees, Math::Sin( 2.0 * angle ) ); - Console::WriteLine( " 2 * Math::Sin({0} deg) * Math::Cos({0} deg) == {1:E16}", degrees, 2.0 * sinAngle * cosAngle ); - - // Evaluate cos(2 * X) == cos^2(X) - sin^2(X). - Console::WriteLine( " Math::Cos({0} deg) == {1:E16}", 2.0 * degrees, Math::Cos( 2.0 * angle ) ); - Console::WriteLine( "(Math::Cos({0} deg))^2 - (Math::Sin({0} deg))^2 == {1:E16}", degrees, cosAngle * cosAngle - sinAngle * sinAngle ); -} - - -// Evaluate trigonometric identities that are functions of two angles. -void UseTwoAngles( double degreesX, double degreesY ) -{ - double angleX = Math::PI * degreesX / 180.0; - double angleY = Math::PI * degreesY / 180.0; - - // Evaluate sin(X + Y) == sin(X) * cos(Y) + cos(X) * sin(Y). - Console::WriteLine( "\n Math::Sin({0} deg) * Math::Cos({1} deg) +\n" - " Math::Cos({0} deg) * Math::Sin({1} deg) == {2:E16}", degreesX, degreesY, Math::Sin( angleX ) * Math::Cos( angleY ) + Math::Cos( angleX ) * Math::Sin( angleY ) ); - Console::WriteLine( " Math::Sin({0} deg) == {1:E16}", degreesX + degreesY, Math::Sin( angleX + angleY ) ); - - // Evaluate cos(X + Y) == cos(X) * cos(Y) - sin(X) * sin(Y). - Console::WriteLine( " Math::Cos({0} deg) * Math::Cos({1} deg) -\n" - " Math::Sin({0} deg) * Math::Sin({1} deg) == {2:E16}", degreesX, degreesY, Math::Cos( angleX ) * Math::Cos( angleY ) - Math::Sin( angleX ) * Math::Sin( angleY ) ); - Console::WriteLine( " Math::Cos({0} deg) == {1:E16}", degreesX + degreesY, Math::Cos( angleX + angleY ) ); -} - -int main() -{ - Console::WriteLine( "This example of trigonometric " - "Math::Sin( double ) and Math::Cos( double )\n" - "generates the following output.\n" ); - Console::WriteLine( "Convert selected values for X to radians \n" - "and evaluate these trigonometric identities:" ); - Console::WriteLine( " sin^2(X) + cos^2(X) == 1\n" - " sin(2 * X) == 2 * sin(X) * cos(X)" ); - Console::WriteLine( " cos(2 * X) == cos^2(X) - sin^2(X)" ); - UseSineCosine( 15.0 ); - UseSineCosine( 30.0 ); - UseSineCosine( 45.0 ); - Console::WriteLine( "\nConvert selected values for X and Y to radians \n" - "and evaluate these trigonometric identities:" ); - Console::WriteLine( " sin(X + Y) == sin(X) * cos(Y) + cos(X) * sin(Y)" ); - Console::WriteLine( " cos(X + Y) == cos(X) * cos(Y) - sin(X) * sin(Y)" ); - UseTwoAngles( 15.0, 30.0 ); - UseTwoAngles( 30.0, 45.0 ); -} - -/* -This example of trigonometric Math::Sin( double ) and Math::Cos( double ) -generates the following output. - -Convert selected values for X to radians -and evaluate these trigonometric identities: - sin^2(X) + cos^2(X) == 1 - sin(2 * X) == 2 * sin(X) * cos(X) - cos(2 * X) == cos^2(X) - sin^2(X) - - Math::Sin(15 deg) == 2.5881904510252074E-001 - Math::Cos(15 deg) == 9.6592582628906831E-001 -(Math::Sin(15 deg))^2 + (Math::Cos(15 deg))^2 == 1.0000000000000000E+000 - Math::Sin(30 deg) == 4.9999999999999994E-001 - 2 * Math::Sin(15 deg) * Math::Cos(15 deg) == 4.9999999999999994E-001 - Math::Cos(30 deg) == 8.6602540378443871E-001 -(Math::Cos(15 deg))^2 - (Math::Sin(15 deg))^2 == 8.6602540378443871E-001 - - Math::Sin(30 deg) == 4.9999999999999994E-001 - Math::Cos(30 deg) == 8.6602540378443871E-001 -(Math::Sin(30 deg))^2 + (Math::Cos(30 deg))^2 == 1.0000000000000000E+000 - Math::Sin(60 deg) == 8.6602540378443860E-001 - 2 * Math::Sin(30 deg) * Math::Cos(30 deg) == 8.6602540378443860E-001 - Math::Cos(60 deg) == 5.0000000000000011E-001 -(Math::Cos(30 deg))^2 - (Math::Sin(30 deg))^2 == 5.0000000000000022E-001 - - Math::Sin(45 deg) == 7.0710678118654746E-001 - Math::Cos(45 deg) == 7.0710678118654757E-001 -(Math::Sin(45 deg))^2 + (Math::Cos(45 deg))^2 == 1.0000000000000000E+000 - Math::Sin(90 deg) == 1.0000000000000000E+000 - 2 * Math::Sin(45 deg) * Math::Cos(45 deg) == 1.0000000000000000E+000 - Math::Cos(90 deg) == 6.1230317691118863E-017 -(Math::Cos(45 deg))^2 - (Math::Sin(45 deg))^2 == 2.2204460492503131E-016 - -Convert selected values for X and Y to radians -and evaluate these trigonometric identities: - sin(X + Y) == sin(X) * cos(Y) + cos(X) * sin(Y) - cos(X + Y) == cos(X) * cos(Y) - sin(X) * sin(Y) - - Math::Sin(15 deg) * Math::Cos(30 deg) + - Math::Cos(15 deg) * Math::Sin(30 deg) == 7.0710678118654746E-001 - Math::Sin(45 deg) == 7.0710678118654746E-001 - Math::Cos(15 deg) * Math::Cos(30 deg) - - Math::Sin(15 deg) * Math::Sin(30 deg) == 7.0710678118654757E-001 - Math::Cos(45 deg) == 7.0710678118654757E-001 - - Math::Sin(30 deg) * Math::Cos(45 deg) + - Math::Cos(30 deg) * Math::Sin(45 deg) == 9.6592582628906831E-001 - Math::Sin(75 deg) == 9.6592582628906820E-001 - Math::Cos(30 deg) * Math::Cos(45 deg) - - Math::Sin(30 deg) * Math::Sin(45 deg) == 2.5881904510252085E-001 - Math::Cos(75 deg) == 2.5881904510252096E-001 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Math.SinhCosh/CPP/sinhcosh.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Math.SinhCosh/CPP/sinhcosh.cpp deleted file mode 100644 index c3fdb8d9939..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Math.SinhCosh/CPP/sinhcosh.cpp +++ /dev/null @@ -1,115 +0,0 @@ - -// -// Example for the hyperbolic Math.Sinh( double ) -// and Math.Cosh( double ) methods. -using namespace System; - -// Evaluate hyperbolic identities with a given argument. -void UseSinhCosh( double arg ) -{ - double sinhArg = Math::Sinh( arg ); - double coshArg = Math::Cosh( arg ); - - // Evaluate cosh^2(X) - sinh^2(X) == 1. - Console::WriteLine( "\n Math::Sinh({0}) == {1:E16}\n" - " Math::Cosh({0}) == {2:E16}", arg, Math::Sinh( arg ), Math::Cosh( arg ) ); - Console::WriteLine( "(Math::Cosh({0}))^2 - (Math::Sinh({0}))^2 == {1:E16}", arg, coshArg * coshArg - sinhArg * sinhArg ); - - // Evaluate sinh(2 * X) == 2 * sinh(X) * cosh(X). - Console::WriteLine( " Math::Sinh({0}) == {1:E16}", 2.0 * arg, Math::Sinh( 2.0 * arg ) ); - Console::WriteLine( " 2 * Math::Sinh({0}) * Math::Cosh({0}) == {1:E16}", arg, 2.0 * sinhArg * coshArg ); - - // Evaluate cosh(2 * X) == cosh^2(X) + sinh^2(X). - Console::WriteLine( " Math::Cosh({0}) == {1:E16}", 2.0 * arg, Math::Cosh( 2.0 * arg ) ); - Console::WriteLine( "(Math::Cosh({0}))^2 + (Math::Sinh({0}))^2 == {1:E16}", arg, coshArg * coshArg + sinhArg * sinhArg ); -} - - -// Evaluate hyperbolic identities that are functions of two arguments. -void UseTwoArgs( double argX, double argY ) -{ - - // Evaluate sinh(X + Y) == sinh(X) * cosh(Y) + cosh(X) * sinh(Y). - Console::WriteLine( "\n Math::Sinh({0}) * Math::Cosh({1}) +\n" - " Math::Cosh({0}) * Math::Sinh({1}) == {2:E16}", argX, argY, Math::Sinh( argX ) * Math::Cosh( argY ) + Math::Cosh( argX ) * Math::Sinh( argY ) ); - Console::WriteLine( " Math::Sinh({0}) == {1:E16}", argX + argY, Math::Sinh( argX + argY ) ); - - // Evaluate cosh(X + Y) == cosh(X) * cosh(Y) + sinh(X) * sinh(Y). - Console::WriteLine( " Math::Cosh({0}) * Math::Cosh({1}) +\n" - " Math::Sinh({0}) * Math::Sinh({1}) == {2:E16}", argX, argY, Math::Cosh( argX ) * Math::Cosh( argY ) + Math::Sinh( argX ) * Math::Sinh( argY ) ); - Console::WriteLine( " Math::Cosh({0}) == {1:E16}", argX + argY, Math::Cosh( argX + argY ) ); -} - -int main() -{ - Console::WriteLine( "This example of hyperbolic " - "Math::Sinh( double ) and Math::Cosh( double )\n" - "generates the following output.\n" ); - Console::WriteLine( "Evaluate these hyperbolic identities " - "with selected values for X:" ); - Console::WriteLine( " cosh^2(X) - sinh^2(X) == 1\n" - " sinh(2 * X) == 2 * sinh(X) * cosh(X)" ); - Console::WriteLine( " cosh(2 * X) == cosh^2(X) + sinh^2(X)" ); - UseSinhCosh( 0.1 ); - UseSinhCosh( 1.2 ); - UseSinhCosh( 4.9 ); - Console::WriteLine( "\nEvaluate these hyperbolic identities " - "with selected values for X and Y:" ); - Console::WriteLine( " sinh(X + Y) == sinh(X) * cosh(Y) + cosh(X) * sinh(Y)" ); - Console::WriteLine( " cosh(X + Y) == cosh(X) * cosh(Y) + sinh(X) * sinh(Y)" ); - UseTwoArgs( 0.1, 1.2 ); - UseTwoArgs( 1.2, 4.9 ); -} - -/* -This example of hyperbolic Math::Sinh( double ) and Math::Cosh( double ) -generates the following output. - -Evaluate these hyperbolic identities with selected values for X: - cosh^2(X) - sinh^2(X) == 1 - sinh(2 * X) == 2 * sinh(X) * cosh(X) - cosh(2 * X) == cosh^2(X) + sinh^2(X) - - Math::Sinh(0.1) == 1.0016675001984403E-001 - Math::Cosh(0.1) == 1.0050041680558035E+000 -(Math::Cosh(0.1))^2 - (Math::Sinh(0.1))^2 == 9.9999999999999989E-001 - Math::Sinh(0.2) == 2.0133600254109399E-001 - 2 * Math::Sinh(0.1) * Math::Cosh(0.1) == 2.0133600254109396E-001 - Math::Cosh(0.2) == 1.0200667556190759E+000 -(Math::Cosh(0.1))^2 + (Math::Sinh(0.1))^2 == 1.0200667556190757E+000 - - Math::Sinh(1.2) == 1.5094613554121725E+000 - Math::Cosh(1.2) == 1.8106555673243747E+000 -(Math::Cosh(1.2))^2 - (Math::Sinh(1.2))^2 == 1.0000000000000000E+000 - Math::Sinh(2.4) == 5.4662292136760939E+000 - 2 * Math::Sinh(1.2) * Math::Cosh(1.2) == 5.4662292136760939E+000 - Math::Cosh(2.4) == 5.5569471669655064E+000 -(Math::Cosh(1.2))^2 + (Math::Sinh(1.2))^2 == 5.5569471669655064E+000 - - Math::Sinh(4.9) == 6.7141166550932297E+001 - Math::Cosh(4.9) == 6.7148613134003227E+001 -(Math::Cosh(4.9))^2 - (Math::Sinh(4.9))^2 == 1.0000000000000000E+000 - Math::Sinh(9.8) == 9.0168724361884615E+003 - 2 * Math::Sinh(4.9) * Math::Cosh(4.9) == 9.0168724361884615E+003 - Math::Cosh(9.8) == 9.0168724916400624E+003 -(Math::Cosh(4.9))^2 + (Math::Sinh(4.9))^2 == 9.0168724916400606E+003 - -Evaluate these hyperbolic identities with selected values for X and Y: - sinh(X + Y) == sinh(X) * cosh(Y) + cosh(X) * sinh(Y) - cosh(X + Y) == cosh(X) * cosh(Y) + sinh(X) * sinh(Y) - - Math::Sinh(0.1) * Math::Cosh(1.2) + - Math::Cosh(0.1) * Math::Sinh(1.2) == 1.6983824372926155E+000 - Math::Sinh(1.3) == 1.6983824372926160E+000 - Math::Cosh(0.1) * Math::Cosh(1.2) + - Math::Sinh(0.1) * Math::Sinh(1.2) == 1.9709142303266281E+000 - Math::Cosh(1.3) == 1.9709142303266285E+000 - - Math::Sinh(1.2) * Math::Cosh(4.9) + - Math::Cosh(1.2) * Math::Sinh(4.9) == 2.2292776360739879E+002 - Math::Sinh(6.1) == 2.2292776360739885E+002 - Math::Cosh(1.2) * Math::Cosh(4.9) + - Math::Sinh(1.2) * Math::Sinh(4.9) == 2.2293000647511826E+002 - Math::Cosh(6.1) == 2.2293000647511832E+002 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Math.Tanh/CPP/tanh.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Math.Tanh/CPP/tanh.cpp deleted file mode 100644 index 00a5cb83a3d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Math.Tanh/CPP/tanh.cpp +++ /dev/null @@ -1,87 +0,0 @@ - -// -// Example for the hyperbolic Math::Tanh( double ) method. -using namespace System; - -// Evaluate hyperbolic identities with a given argument. -void UseTanh( double arg ) -{ - double tanhArg = Math::Tanh( arg ); - - // Evaluate tanh(X) == sinh(X) / cosh(X). - Console::WriteLine( "\n Math::Tanh({0}) == {1:E16}\n" - " Math::Sinh({0}) / Math::Cosh({0}) == {2:E16}", arg, tanhArg, (Math::Sinh( arg ) / Math::Cosh( arg )) ); - - // Evaluate tanh(2 * X) == 2 * tanh(X) / (1 + tanh^2(X)). - Console::WriteLine( " 2 * Math::Tanh({0}) /", arg, 2.0 * tanhArg ); - Console::WriteLine( " (1 + (Math::Tanh({0}))^2) == {1:E16}", arg, 2.0 * tanhArg / (1.0 + tanhArg * tanhArg) ); - Console::WriteLine( " Math::Tanh({0}) == {1:E16}", 2.0 * arg, Math::Tanh( 2.0 * arg ) ); -} - - -// Evaluate a hyperbolic identity that is a function of two arguments. -void UseTwoArgs( double argX, double argY ) -{ - - // Evaluate tanh(X + Y) == (tanh(X) + tanh(Y)) / (1 + tanh(X) * tanh(Y)). - Console::WriteLine( "\n (Math::Tanh({0}) + Math::Tanh({1})) /\n" - "(1 + Math::Tanh({0}) * Math::Tanh({1})) == {2:E16}", argX, argY, (Math::Tanh( argX ) + Math::Tanh( argY )) / (1.0 + Math::Tanh( argX ) * Math::Tanh( argY )) ); - Console::WriteLine( " Math::Tanh({0}) == {1:E16}", argX + argY, Math::Tanh( argX + argY ) ); -} - -int main() -{ - Console::WriteLine( "This example of hyperbolic Math::Tanh( double )\n" - "generates the following output." ); - Console::WriteLine( "\nEvaluate these hyperbolic identities " - "with selected values for X:" ); - Console::WriteLine( " tanh(X) == sinh(X) / cosh(X)" ); - Console::WriteLine( " tanh(2 * X) == 2 * tanh(X) / (1 + tanh^2(X))" ); - UseTanh( 0.1 ); - UseTanh( 1.2 ); - UseTanh( 4.9 ); - Console::WriteLine( "\nEvaluate [tanh(X + Y) == " - "(tanh(X) + tanh(Y)) / (1 + tanh(X) * tanh(Y))]" - "\nwith selected values for X and Y:" ); - UseTwoArgs( 0.1, 1.2 ); - UseTwoArgs( 1.2, 4.9 ); -} - -/* -This example of hyperbolic Math::Tanh( double ) -generates the following output. - -Evaluate these hyperbolic identities with selected values for X: - tanh(X) == sinh(X) / cosh(X) - tanh(2 * X) == 2 * tanh(X) / (1 + tanh^2(X)) - - Math::Tanh(0.1) == 9.9667994624955819E-002 - Math::Sinh(0.1) / Math::Cosh(0.1) == 9.9667994624955819E-002 - 2 * Math::Tanh(0.1) / - (1 + (Math::Tanh(0.1))^2) == 1.9737532022490401E-001 - Math::Tanh(0.2) == 1.9737532022490401E-001 - - Math::Tanh(1.2) == 8.3365460701215521E-001 - Math::Sinh(1.2) / Math::Cosh(1.2) == 8.3365460701215521E-001 - 2 * Math::Tanh(1.2) / - (1 + (Math::Tanh(1.2))^2) == 9.8367485769368024E-001 - Math::Tanh(2.4) == 9.8367485769368024E-001 - - Math::Tanh(4.9) == 9.9988910295055444E-001 - Math::Sinh(4.9) / Math::Cosh(4.9) == 9.9988910295055433E-001 - 2 * Math::Tanh(4.9) / - (1 + (Math::Tanh(4.9))^2) == 9.9999999385024030E-001 - Math::Tanh(9.8) == 9.9999999385024030E-001 - -Evaluate [tanh(X + Y) == (tanh(X) + tanh(Y)) / (1 + tanh(X) * tanh(Y))] -with selected values for X and Y: - - (Math::Tanh(0.1) + Math::Tanh(1.2)) / -(1 + Math::Tanh(0.1) * Math::Tanh(1.2)) == 8.6172315931330645E-001 - Math::Tanh(1.3) == 8.6172315931330634E-001 - - (Math::Tanh(1.2) + Math::Tanh(4.9)) / -(1 + Math::Tanh(1.2) * Math::Tanh(4.9)) == 9.9998993913939649E-001 - Math::Tanh(6.1) == 9.9998993913939649E-001 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.OperatingSystem.Clone/CPP/clone.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.OperatingSystem.Clone/CPP/clone.cpp deleted file mode 100644 index f6ba5145e9c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.OperatingSystem.Clone/CPP/clone.cpp +++ /dev/null @@ -1,56 +0,0 @@ - -// -// Example for the OperatingSystem::Clone method. -using namespace System; - -// Copy, clone, and duplicate an OperatingSystem object. -void CopyOperatingSystemObjects() -{ - - // The Version object does not need to correspond to an - // actual OS version. - Version^ verMMBVer = gcnew Version( 5,6,7,8 ); - OperatingSystem^ opCreate1 = gcnew OperatingSystem( PlatformID::Win32NT,verMMBVer ); - - // Create another OperatingSystem object with the same - // parameters as opCreate1. - OperatingSystem^ opCreate2 = gcnew OperatingSystem( PlatformID::Win32NT,verMMBVer ); - - // Clone opCreate1 and copy the opCreate1 reference. - OperatingSystem^ opClone = safe_cast(opCreate1->Clone()); - OperatingSystem^ opCopy = opCreate1; - - // Compare the various objects for equality. - Console::WriteLine( "{0,-50}{1}", "Is the second object the same as the original?", opCreate1->Equals( opCreate2 ) ); - Console::WriteLine( "{0,-50}{1}", "Is the object clone the same as the original?", opCreate1->Equals( opClone ) ); - Console::WriteLine( "{0,-50}{1}", "Is the copied object the same as the original?", opCreate1->Equals( opCopy ) ); -} - -int main() -{ - Console::WriteLine( "This example of OperatingSystem::Clone( ) " - "generates the following output.\n" ); - Console::WriteLine( "Create an OperatingSystem object, and then " - "create another object with the \n" - "same parameters. Clone and copy the original " - "object, and then compare \n" - "each object with the original " - "using the Equals( ) method. Equals( ) \n" - "returns true only when both " - "references refer to the same object.\n" ); - CopyOperatingSystemObjects(); -} - -/* -This example of OperatingSystem::Clone( ) generates the following output. - -Create an OperatingSystem object, and then create another object with the -same parameters. Clone and copy the original object, and then compare -each object with the original using the Equals( ) method. Equals( ) -returns true only when both references refer to the same object. - -Is the second object the same as the original? False -Is the object clone the same as the original? False -Is the copied object the same as the original? True -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.OperatingSystem.Ctor_ToString/CPP/ctor_tostr.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.OperatingSystem.Ctor_ToString/CPP/ctor_tostr.cpp deleted file mode 100644 index 51ca7637c6e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.OperatingSystem.Ctor_ToString/CPP/ctor_tostr.cpp +++ /dev/null @@ -1,60 +0,0 @@ - -// -// Example for the OperatingSystem constructor and the -// OperatingSystem::ToString( ) method. -using namespace System; - -// Create and display an OperatingSystem object. -void BuildOSObj( PlatformID pID, Version^ ver ) -{ - OperatingSystem^ os = gcnew OperatingSystem( pID,ver ); - Console::WriteLine( " {0}", os->ToString() ); -} - -void BuildOperatingSystemObjects() -{ - - // The Version object does not need to correspond to an - // actual OS version. - Version^ verNull = gcnew Version; - Version^ verMajMin = gcnew Version( 3,11 ); - Version^ verMMBld = gcnew Version( 5,25,625 ); - Version^ verMMBVer = gcnew Version( 5,6,7,8 ); - Version^ verString = gcnew Version( "3.5.8.13" ); - - // All PlatformID members are shown here. - BuildOSObj( PlatformID::Win32NT, verNull ); - BuildOSObj( PlatformID::Win32S, verMajMin ); - BuildOSObj( PlatformID::Win32Windows, verMMBld ); - BuildOSObj( PlatformID::WinCE, verMMBVer ); - BuildOSObj( PlatformID::Win32NT, verString ); -} - -int main() -{ - Console::WriteLine( "This example of the OperatingSystem constructor and \n" - "OperatingSystem::ToString( ) generates the following " - "output.\n" ); - Console::WriteLine( "Create and display several different " - "OperatingSystem objects:\n" ); - BuildOperatingSystemObjects(); - Console::WriteLine( "\nThe OS version of the host computer is:\n\n {0}", Environment::OSVersion->ToString() ); -} - -/* -This example of the OperatingSystem constructor and -OperatingSystem::ToString( ) generates the following output. - -Create and display several different OperatingSystem objects: - - Microsoft Windows NT 0.0 - Microsoft Win32S 3.11 - Microsoft Windows 98 5.25.625 - Microsoft Windows CE 5.6.7.8 - Microsoft Windows NT 3.5.8.13 - -The OS version of the host computer is: - - Microsoft Windows NT 5.1.2600.0 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.OperatingSystem.Platform_Version/CPP/plat_ver.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.OperatingSystem.Platform_Version/CPP/plat_ver.cpp deleted file mode 100644 index 955079bbbca..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.OperatingSystem.Platform_Version/CPP/plat_ver.cpp +++ /dev/null @@ -1,64 +0,0 @@ - -// -// Example for the OperatingSystem.Platform and -// OperatingSystem.Version properties. -using namespace System; - -// Create an OperatingSystem object and display the Platform -// and Version properties. -void BuildOSObj( PlatformID pID, Version^ ver ) -{ - OperatingSystem^ opSys = gcnew OperatingSystem( pID,ver ); - PlatformID platform = opSys->Platform; - Version^ version = opSys->Version; - Console::WriteLine( " Platform: {0,-15} Version: {1}", platform, version ); -} - -void BuildOperatingSystemObjects() -{ - - // The Version object does not need to correspond to an - // actual OS version. - Version^ verNull = gcnew Version; - Version^ verString = gcnew Version( "3.5.8.13" ); - Version^ verMajMin = gcnew Version( 6,10 ); - Version^ verMMBld = gcnew Version( 5,25,5025 ); - Version^ verMMBVer = gcnew Version( 5,6,7,8 ); - - // All PlatformID members are shown here. - BuildOSObj( PlatformID::Win32NT, verNull ); - BuildOSObj( PlatformID::Win32S, verString ); - BuildOSObj( PlatformID::Win32Windows, verMajMin ); - BuildOSObj( PlatformID::WinCE, verMMBld ); - BuildOSObj( PlatformID::Win32NT, verMMBVer ); -} - -int main() -{ - Console::WriteLine( "This example of OperatingSystem::Platform " - "and OperatingSystem::Version \n" - "generates the following output.\n" ); - Console::WriteLine( "Create several OperatingSystem objects " - "and display their properties:\n" ); - BuildOperatingSystemObjects(); - Console::WriteLine( "\nThe operating system of the host computer is:\n" ); - BuildOSObj( Environment::OSVersion->Platform, Environment::OSVersion->Version ); -} - -/* -This example of OperatingSystem::Platform and OperatingSystem::Version -generates the following output. - -Create several OperatingSystem objects and display their properties: - - Platform: Win32NT Version: 0.0 - Platform: Win32S Version: 3.5.8.13 - Platform: Win32Windows Version: 6.10 - Platform: WinCE Version: 5.25.5025 - Platform: Win32NT Version: 5.6.7.8 - -The operating system of the host computer is: - - Platform: Win32NT Version: 5.1.2600.0 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Random.Ctor/CPP/ctor.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Random.Ctor/CPP/ctor.cpp deleted file mode 100644 index cb05859164c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Random.Ctor/CPP/ctor.cpp +++ /dev/null @@ -1,95 +0,0 @@ - -// -// Example of the Random class constructors and Random::NextDouble() -// method. -using namespace System; -using namespace System::Threading; - -// Generate random numbers from the specified Random object. -void RunIntNDoubleRandoms(Random^ randObj) -{ - - // Generate the first six random integers. - for (int j = 0; j < 6; j++) - Console::Write(" {0,10} ", randObj->Next()); - Console::WriteLine(); - - // Generate the first six random doubles. - for (int j = 0; j < 6; j++) - Console::Write(" {0:F8} ", randObj->NextDouble()); - Console::WriteLine(); -} - - -// Create a Random object with the specified seed. -void FixedSeedRandoms(int seed) -{ - Console::WriteLine("\nRandom numbers from a Random object with seed = {0}:", seed); - Random^ fixRand = gcnew Random(seed); - RunIntNDoubleRandoms(fixRand); -} - - -// Create a random object with a timer-generated seed. -void AutoSeedRandoms() -{ - - // Wait to allow the timer to advance. - Thread::Sleep(1); - Console::WriteLine("\nRandom numbers from a Random object " - "with an auto-generated seed:"); - Random^ autoRand = gcnew Random; - RunIntNDoubleRandoms(autoRand); -} - -int main() -{ - Console::WriteLine("This example of the Random class constructors and Random" - "::NextDouble() \ngenerates the following output.\n"); - Console::WriteLine("Create Random objects, and then generate and " - "display six integers and \nsix doubles from each."); - FixedSeedRandoms(123); - FixedSeedRandoms(123); - FixedSeedRandoms(456); - FixedSeedRandoms(456); - AutoSeedRandoms(); - AutoSeedRandoms(); - AutoSeedRandoms(); -} - -/* -This example of the Random class constructors and Random::NextDouble() -generates an output similar to the following: - -Create Random objects, and then generate and display six integers and -six doubles from each. - -Random numbers from a Random object with seed = 123: - 2114319875 1949518561 1596751841 1742987178 1586516133 103755708 - 0.01700087 0.14935942 0.19470390 0.63008947 0.90976122 0.49519146 - -Random numbers from a Random object with seed = 123: - 2114319875 1949518561 1596751841 1742987178 1586516133 103755708 - 0.01700087 0.14935942 0.19470390 0.63008947 0.90976122 0.49519146 - -Random numbers from a Random object with seed = 456: - 2044805024 1323311594 1087799997 1907260840 179380355 120870348 - 0.21988117 0.21026556 0.39236514 0.42420498 0.24102703 0.47310170 - -Random numbers from a Random object with seed = 456: - 2044805024 1323311594 1087799997 1907260840 179380355 120870348 - 0.21988117 0.21026556 0.39236514 0.42420498 0.24102703 0.47310170 - -Random numbers from a Random object with an auto-generated seed: - 1624372556 1894939458 302472229 588108304 23919954 1085111949 - 0.14595512 0.30162298 0.92267372 0.55707657 0.25430079 0.74143239 - -Random numbers from a Random object with an auto-generated seed: - 2105952511 1753605347 280739490 876793040 1129567796 524571616 - 0.62652210 0.31846701 0.15984073 0.24458755 0.62160607 0.54857684 - -Random numbers from a Random object with an auto-generated seed: - 440048819 1612271236 259006751 1165477776 87731991 2111514930 - 0.10708907 0.33531104 0.39700773 0.93209853 0.98891135 0.35572129 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next.cpp deleted file mode 100644 index 167584f6cc6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next.cpp +++ /dev/null @@ -1,99 +0,0 @@ - -// -// Example of the Random::Next() methods. -using namespace System; - -// Generate random numbers with no bounds specified. -void NoBoundsRandoms(int seed) -{ - Console::WriteLine("\nRandom object, seed = {0}, no bounds:", seed); - Random^ randObj = gcnew Random(seed); - - // Generate six random integers from 0 to int.MaxValue. - for (int j = 0; j < 6; j++) - Console::Write("{0,11} ", randObj->Next()); - Console::WriteLine(); -} - - -// Generate random numbers with an upper bound specified. -void UpperBoundRandoms(int seed, int upper) -{ - Console::WriteLine("\nRandom object, seed = {0}, upper bound = {1}:", seed, upper); - Random^ randObj = gcnew Random(seed); - - // Generate six random integers from 0 to the upper bound. - for (int j = 0; j < 6; j++) - Console::Write("{0,11} ", randObj->Next(upper)); - Console::WriteLine(); -} - - -// Generate random numbers with both bounds specified. -void BothBoundsRandoms(int seed, int lower, int upper) -{ - Console::WriteLine("\nRandom object, seed = {0}, lower = {1}, upper = {2}:", seed, lower, upper); - Random^ randObj = gcnew Random(seed); - - // Generate six random integers from the lower to - // upper bounds. - for (int j = 0; j < 6; j++) - Console::Write("{0,11} ", randObj->Next(lower, upper)); - Console::WriteLine(); -} - -int main() -{ - Console::WriteLine("This example of the Random::Next() methods\n" - "generates the following output.\n"); - Console::WriteLine("Create Random objects all with the same seed and " - "generate\nsequences of numbers with different " - "bounds. Note the effect\nthat the various " - "combinations of bounds have on the sequences."); - NoBoundsRandoms(234); - UpperBoundRandoms(234, Int32::MaxValue); - UpperBoundRandoms(234, 2000000000); - UpperBoundRandoms(234, 200000000); - BothBoundsRandoms(234, 0, Int32::MaxValue); - BothBoundsRandoms(234, Int32::MinValue, Int32::MaxValue); - BothBoundsRandoms(234, -2000000000, 2000000000); - BothBoundsRandoms(234, -200000000, 200000000); - BothBoundsRandoms(234, -2000, 2000); -} - -/* -This example of the Random::Next() methods -generates the following output. - -Create Random objects all with the same seed and generate -sequences of numbers with different bounds. Note the effect -that the various combinations of bounds have on the sequences. - -Random object, seed = 234, no bounds: - 2091148258 1024955023 711273344 1081917183 1833298756 109460588 - -Random object, seed = 234, upper bound = 2147483647: - 2091148258 1024955023 711273344 1081917183 1833298756 109460588 - -Random object, seed = 234, upper bound = 2000000000: - 1947533580 954563751 662424922 1007613896 1707392518 101943116 - -Random object, seed = 234, upper bound = 200000000: - 194753358 95456375 66242492 100761389 170739251 10194311 - -Random object, seed = 234, lower = 0, upper = 2147483647: - 2091148258 1024955023 711273344 1081917183 1833298756 109460588 - -Random object, seed = 234, lower = -2147483648, upper = 2147483647: - 2034812868 -97573602 -724936960 16350718 1519113864 -1928562472 - -Random object, seed = 234, lower = -2000000000, upper = 2000000000: - 1895067160 -90872498 -675150156 15227793 1414785036 -1796113767 - -Random object, seed = 234, lower = -200000000, upper = 200000000: - 189506716 -9087250 -67515016 1522779 141478503 -179611377 - -Random object, seed = 234, lower = -2000, upper = 2000: - 1895 -91 -676 15 1414 -1797 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next1.cpp deleted file mode 100644 index fad6b704dab..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next1.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// -using namespace System; - -void main() -{ - Random^ rnd = gcnew Random(); - array^ malePetNames = { "Rufus", "Bear", "Dakota", "Fido", - "Vanya", "Samuel", "Koani", "Volodya", - "Prince", "Yiska" }; - array^ femalePetNames = { "Maggie", "Penny", "Saya", "Princess", - "Abby", "Laila", "Sadie", "Olivia", - "Starlight", "Talla" }; - - // Generate random indexes for pet names. - int mIndex = rnd->Next(malePetNames->Length); - int fIndex = rnd->Next(femalePetNames->Length); - - // Display the result. - Console::WriteLine("Suggested pet name of the day: "); - Console::WriteLine(" For a male: {0}", malePetNames[mIndex]); - Console::WriteLine(" For a female: {0}", femalePetNames[fIndex]); -} -// The example displays output similar to the following: -// Suggested pet name of the day: -// For a male: Koani -// For a female: Maggie -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next2.cpp deleted file mode 100644 index 6f5970848da..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next2.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// -using namespace System; - -void main() -{ - Random^ rnd = gcnew Random(); - - Console::WriteLine("\n20 random integers from -100 to 100:"); - for (int ctr = 1; ctr <= 20; ctr++) - { - Console::Write("{0,6}", rnd->Next(-100, 101)); - if (ctr % 5 == 0) Console::WriteLine(); - } - - Console::WriteLine("\n20 random integers from 1000 to 10000:"); - for (int ctr = 1; ctr <= 20; ctr++) - { - Console::Write("{0,8}", rnd->Next(1000, 10001)); - if (ctr % 5 == 0) Console::WriteLine(); - } - - Console::WriteLine("\n20 random integers from 1 to 10:"); - for (int ctr = 1; ctr <= 20; ctr++) - { - Console::Write("{0,6}", rnd->Next(1, 11)); - if (ctr % 5 == 0) Console::WriteLine(); - } -} -// The example displays output similar to the following: -// 20 random integers from -100 to 100: -// 65 -95 -10 90 -35 -// -83 -16 -15 -19 41 -// -67 -93 40 12 62 -// -80 -95 67 -81 -21 -// -// 20 random integers from 1000 to 10000: -// 4857 9897 4405 6606 1277 -// 9238 9113 5151 8710 1187 -// 2728 9746 1719 3837 3736 -// 8191 6819 4923 2416 3028 -// -// 20 random integers from 1 to 10: -// 9 8 5 9 9 -// 9 1 2 3 8 -// 1 4 8 10 5 -// 9 7 9 10 5 -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next3.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next3.cpp deleted file mode 100644 index 6f999eb0477..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next3.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// -using namespace System; - -void main() -{ - Console::Write("Number of random numbers to generate: "); - String^ line = Console::ReadLine(); - unsigned int numbers = 0; - Random^ rnd = gcnew Random(); - - if (!UInt32::TryParse(line, numbers)) - numbers = 10; - - for (unsigned int ctr = 1; ctr <= numbers; ctr++) - Console::WriteLine("{0,15:N0}", rnd->Next()); -} -// The example displays output like the following when asked to generate -// 15 random numbers: -// Number of random numbers to generate: 15 -// 1,733,189,596 -// 566,518,090 -// 1,166,108,546 -// 1,931,426,514 -// 1,341,108,291 -// 1,012,698,049 -// 890,578,409 -// 1,377,589,722 -// 2,108,384,181 -// 1,532,939,448 -// 762,207,767 -// 815,074,920 -// 1,521,208,785 -// 1,950,436,671 -// 1,266,596,666 -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next4.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next4.cpp deleted file mode 100644 index 9b547303cfa..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next4.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// -using namespace System; - -void main() -{ - Random^ rnd = gcnew Random(); - array^ malePetNames = { "Rufus", "Bear", "Dakota", "Fido", - "Vanya", "Samuel", "Koani", "Volodya", - "Prince", "Yiska" }; - array^ femalePetNames = { "Maggie", "Penny", "Saya", "Princess", - "Abby", "Laila", "Sadie", "Olivia", - "Starlight", "Talla" }; - - // Generate random indexes for pet names. - int mIndex = rnd->Next(0, malePetNames->Length); - int fIndex = rnd->Next(0, femalePetNames->Length); - - // Display the result. - Console::WriteLine("Suggested pet name of the day: "); - Console::WriteLine(" For a male: {0}", malePetNames[mIndex]); - Console::WriteLine(" For a female: {0}", femalePetNames[fIndex]); -} -// The example displays the following output: -// Suggested pet name of the day: -// For a male: Koani -// For a female: Maggie -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Random.Sample/cpp/sampleex.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Random.Sample/cpp/sampleex.cpp deleted file mode 100644 index 9e0bb8434a9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Random.Sample/cpp/sampleex.cpp +++ /dev/null @@ -1,149 +0,0 @@ -// SampleEx.cpp : main project file. - -// -using namespace System; - -// This derived class converts the uniformly distributed random -// numbers generated by base.Sample() to another distribution. -public ref class RandomProportional : Random -{ - // The Sample method generates a distribution proportional to the value - // of the random numbers, in the range [0.0, 1.0]. -protected: - virtual double Sample() override - { - return Math::Sqrt(Random::Sample()); - } - -public: - RandomProportional() - {} - - virtual int Next() override - { - return (int) (Sample() * Int32::MaxValue); - } -}; - -int main(array ^args) -{ - const int rows = 4, cols = 6; - const int runCount = 1000000; - const int distGroupCount = 10; - const double intGroupSize = - ((double) Int32::MaxValue + 1.0) / (double)distGroupCount; - - RandomProportional ^randObj = gcnew RandomProportional(); - - array^ intCounts = gcnew array(distGroupCount); - array^ realCounts = gcnew array(distGroupCount); - - Console::WriteLine( - "\nThe derived RandomProportional class overrides " + - "the Sample method to \ngenerate random numbers " + - "in the range [0.0, 1.0]. The distribution \nof " + - "the numbers is proportional to their numeric values. " + - "For example, \nnumbers are generated in the " + - "vicinity of 0.75 with three times the \n" + - "probability of those generated near 0.25."); - Console::WriteLine( - "\nRandom doubles generated with the NextDouble() " + - "method:\n"); - - // Generate and display [rows * cols] random doubles. - for (int i = 0; i < rows; i++) - { - for (int j = 0; j < cols; j++) - Console::Write("{0,12:F8}", randObj->NextDouble()); - Console::WriteLine(); - } - - Console::WriteLine( - "\nRandom integers generated with the Next() " + - "method:\n"); - - // Generate and display [rows * cols] random integers. - for (int i = 0; i < rows; i++) - { - for (int j = 0; j < cols; j++) - Console::Write("{0,12}", randObj->Next()); - Console::WriteLine(); - } - - Console::WriteLine( - "\nTo demonstrate the proportional distribution, " + - "{0:N0} random \nintegers and doubles are grouped " + - "into {1} equal value ranges. This \n" + - "is the count of values in each range:\n", - runCount, distGroupCount); - Console::WriteLine( - "{0,21}{1,10}{2,20}{3,10}", "Integer Range", - "Count", "Double Range", "Count"); - Console::WriteLine( - "{0,21}{1,10}{2,20}{3,10}", "-------------", - "-----", "------------", "-----"); - - // Generate random integers and doubles, and then count - // them by group. - for (int i = 0; i < runCount; i++) - { - intCounts[ (int)((double)randObj->Next() / - intGroupSize) ]++; - realCounts[ (int)(randObj->NextDouble() * - (double)distGroupCount) ]++; - } - - // Display the count of each group. - for (int i = 0; i < distGroupCount; i++) - Console::WriteLine( - "{0,10}-{1,10}{2,10:N0}{3,12:N5}-{4,7:N5}{5,10:N0}", - (int)((double)i * intGroupSize), - (int)((double)(i + 1) * intGroupSize - 1.0), - intCounts[ i ], - ((double)i) / (double)distGroupCount, - ((double)(i + 1)) / (double)distGroupCount, - realCounts[ i ]); - return 0; -} - -/* -This example of Random.Sample() displays output similar to the following: - - The derived RandomProportional class overrides the Sample method to - generate random numbers in the range [0.0, 1.0). The distribution - of the numbers is proportional to the number values. For example, - numbers are generated in the vicinity of 0.75 with three times the - probability of those generated near 0.25. - - Random doubles generated with the NextDouble() method: - - 0.59455719 0.17589882 0.83134398 0.35795862 0.91467727 0.54022658 - 0.93716947 0.54817519 0.94685080 0.93705478 0.18582318 0.71272428 - 0.77708682 0.95386216 0.70412393 0.86099417 0.08275804 0.79108316 - 0.71019941 0.84205103 0.41685082 0.58186880 0.89492302 0.73067715 - - Random integers generated with the Next() method: - - 1570755704 1279192549 1747627711 1705700211 1372759203 1849655615 - 2046235980 1210843924 1554274149 1307936697 1480207570 1057595022 - 337854215 844109928 2028310798 1386669369 2073517658 1291729809 - 1537248240 1454198019 1934863511 1640004334 2032620207 534654791 - - To demonstrate the proportional distribution, 1,000,000 random - integers and doubles are grouped into 10 equal value ranges. This - is the count of values in each range: - - Integer Range Count Double Range Count - ------------- ----- ------------ ----- - 0- 214748363 10,079 0.00000-0.10000 10,148 - 214748364- 429496728 29,835 0.10000-0.20000 29,849 - 429496729- 644245093 49,753 0.20000-0.30000 49,948 - 644245094- 858993458 70,325 0.30000-0.40000 69,656 - 858993459-1073741823 89,906 0.40000-0.50000 90,337 - 1073741824-1288490187 109,868 0.50000-0.60000 110,225 - 1288490188-1503238552 130,388 0.60000-0.70000 129,986 - 1503238553-1717986917 149,231 0.70000-0.80000 150,428 - 1717986918-1932735282 170,234 0.80000-0.90000 169,610 - 1932735283-2147483647 190,381 0.90000-1.00000 189,813 -*/ -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Random/cpp/random2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Random/cpp/random2.cpp deleted file mode 100644 index 8fba2211c96..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Random/cpp/random2.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// -using namespace System; - -void main() -{ - // Instantiate random number generator using system-supplied value as seed. - Random^ rand = gcnew Random(); - // Generate and display 5 random byte (integer) values. - array^ bytes = gcnew array(4); - rand->NextBytes(bytes); - Console::WriteLine("Five random byte values:"); - for each (Byte byteValue in bytes) - Console::Write("{0, 5}", byteValue); - Console::WriteLine(); - // Generate and display 5 random integers. - Console::WriteLine("Five random integer values:"); - for (int ctr = 0; ctr <= 4; ctr++) - Console::Write("{0,15:N0}", rand->Next()); - Console::WriteLine(); - // Generate and display 5 random integers between 0 and 100.// - Console::WriteLine("Five random integers between 0 and 100:"); - for (int ctr = 0; ctr <= 4; ctr++) - Console::Write("{0,8:N0}", rand->Next(101)); - Console::WriteLine(); - // Generate and display 5 random integers from 50 to 100. - Console::WriteLine("Five random integers between 50 and 100:"); - for (int ctr = 0; ctr <= 4; ctr++) - Console::Write("{0,8:N0}", rand->Next(50, 101)); - Console::WriteLine(); - // Generate and display 5 random floating point values from 0 to 1. - Console::WriteLine("Five Doubles."); - for (int ctr = 0; ctr <= 4; ctr++) - Console::Write("{0,8:N3}", rand->NextDouble()); - Console::WriteLine(); - // Generate and display 5 random floating point values from 0 to 5. - Console::WriteLine("Five Doubles between 0 and 5."); - for (int ctr = 0; ctr <= 4; ctr++) - Console::Write("{0,8:N3}", rand->NextDouble() * 5); -} -// The example displays output like the following: -// Five random byte values: -// 194 185 239 54 116 -// Five random integer values: -// 507,353,531 1,509,532,693 2,125,074,958 1,409,512,757 652,767,128 -// Five random integers between 0 and 100: -// 16 78 94 79 52 -// Five random integers between 50 and 100: -// 56 66 96 60 65 -// Five Doubles. -// 0.943 0.108 0.744 0.563 0.415 -// Five Doubles between 0 and 5. -// 2.934 3.130 0.292 1.432 4.369 -// - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Single/CPP/singlesample.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Single/CPP/singlesample.cpp deleted file mode 100644 index b32ab193862..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Single/CPP/singlesample.cpp +++ /dev/null @@ -1,163 +0,0 @@ -using namespace System; - -class SingleSample -{ -public: - SingleSample() - { - - // - Single s = 4.55F; - // - - // - Console::WriteLine( "A Single is of type {0}.", s.GetType() ); - // - - // - bool done = false; - String^ inp; - do - { - Console::Write( "Enter a real number: " ); - inp = Console::ReadLine(); - try - { - s = Single::Parse( inp ); - Console::WriteLine( "You entered {0}.", s ); - done = true; - } - catch ( FormatException^ ) - { - Console::WriteLine( "You did not enter a number." ); - } - catch ( Exception^ e ) - { - Console::WriteLine( "An exception occurred while parsing your response: {0}", e ); - } - } - while ( !done ); - // - - // - if ( s > Single::MaxValue ) - { - Console::WriteLine( "Your number is larger than a Single." ); - } - // - - // - if ( s < Single::MinValue ) - { - Console::WriteLine( "Your number is smaller than a Single." ); - } - // - - // - Console::WriteLine( "Epsilon, or the permittivity of a vacuum, has value {0}", Single::Epsilon ); - // - - // - Single zero = 0; - - // This condition will return false. - if ( (0 / zero) == Single::NaN ) - { - Console::WriteLine( "0 / 0 can be tested with Single::NaN." ); - } - else - { - Console::WriteLine( "0 / 0 cannot be tested with Single::NaN; use Single::IsNan() instead." ); - } - // - - // - // This will return true. - if ( Single::IsNaN( 0 / zero ) ) - { - Console::WriteLine( "Single::IsNan() can determine whether a value is not-a-number." ); - } - // - - // - // This will equal Infinity. - Console::WriteLine( "10.0 minus NegativeInfinity equals {0}.", (10.0 - Single::NegativeInfinity) ); - // - - // - // This will equal Infinity. - Console::WriteLine( "PositiveInfinity plus 10.0 equals {0}.", (Single::PositiveInfinity + 10.0) ); - // - - // - // This will return S"true". - Console::WriteLine( "IsInfinity(3.0F / 0) == {0}.", Single::IsInfinity( 3.0F / zero ) ? (String^)"true" : "false" ); - // - - // - // This will return true. - Console::WriteLine( "IsPositiveInfinity(4.0F / 0) == {0}.", Single::IsPositiveInfinity( 4.0F / zero ) ? (String^)"true" : "false" ); - // - - // - // This will return true. - Console::WriteLine( "IsNegativeInfinity(-5.0F / 0) == {0}.", Single::IsNegativeInfinity( -5.0F / zero ) ? (String^)"true" : "false" ); - // - - // - Single a; - a = 500; - - Object^ obj1; - // - - // - // The variables point to the same objects. - Object^ obj2; - obj1 = a; - obj2 = obj1; - - if ( Single::ReferenceEquals( obj1, obj2 ) ) - { - Console::WriteLine( "The variables point to the same Single object." ); - } - else - { - Console::WriteLine( "The variables point to different Single objects." ); - } - // - - // - obj1 = (Single)450; - - if ( a.CompareTo( obj1 ) < 0 ) - { - Console::WriteLine( " {0} is less than {1}.", a, obj1 ); - } - - if ( a.CompareTo( obj1 ) > 0 ) - { - Console::WriteLine( " {0} is greater than {1}.", a, obj1 ); - } - - if ( a.CompareTo( obj1 ) == 0 ) - { - Console::WriteLine( " {0} equals {1}.", a, obj1 ); - } - // - - // - obj1 = (Single)500; - - if ( a.Equals( obj1 ) ) - { - Console::WriteLine( "The value type and reference type values are equal." ); - } - // - } -}; - -int main() -{ - new SingleSample; -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.Class/cpp/system.string.class.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.Class/cpp/system.string.class.cpp deleted file mode 100644 index 851ef4dcfad..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.Class/cpp/system.string.class.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// -using namespace System; -using namespace System::Text; - -void main() -{ - String^ characters = "abc" + L'0' + "def"; - Console::WriteLine(characters->Length); // Displays 7 -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/compare02.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/compare02.cpp deleted file mode 100644 index 9da4bfb57cf..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/compare02.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// -using namespace System; - -void main() -{ - // Create upper-case characters from their Unicode code units. - String^ stringUpper = "\x0041\x0042\x0043"; - - // Create lower-case characters from their Unicode code units. - String^ stringLower = "\x0061\x0062\x0063"; - - // Display the strings. - Console::WriteLine("Comparing '{0}' and '{1}':", - stringUpper, stringLower); - - // Compare the uppercased strings; the result is true. - Console::WriteLine("The Strings are equal when capitalized? {0}", - String::Compare(stringUpper->ToUpper(), stringLower->ToUpper()) == 0 - ? "true" : "false"); - - // The previous method call is equivalent to this Compare method, which ignores case. - Console::WriteLine("The Strings are equal when case is ignored? {0}", - String::Compare(stringUpper, stringLower, true) == 0 - ? "true" : "false"); -} -// The example displays the following output: -// Comparing 'ABC' and 'abc': -// The Strings are equal when capitalized? true -// The Strings are equal when case is ignored? true -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/example.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/example.cpp deleted file mode 100644 index ceae78e341d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/example.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// -using namespace System; -using namespace System::Globalization; - -public ref class Example -{ -public: - static void Main() - { - String^ string1 = "brother"; - String^ string2 = "Brother"; - String^ relation; - int result; - - // Cultural (linguistic) comparison. - result = String::Compare(string1, string2, gcnew CultureInfo("en-US"), - CompareOptions::None); - if (result > 0) - relation = "comes after"; - else if (result == 0) - relation = "is the same as"; - else - relation = "comes before"; - - Console::WriteLine("'{0}' {1} '{2}'.", - string1, relation, string2); - - // Cultural (linguistic) case-insensitive comparison. - result = String::Compare(string1, string2, gcnew CultureInfo("en-US"), - CompareOptions::IgnoreCase); - if (result > 0) - relation = "comes after"; - else if (result == 0) - relation = "is the same as"; - else - relation = "comes before"; - - Console::WriteLine("'{0}' {1} '{2}'.", - string1, relation, string2); - - // Culture-insensitive ordinal comparison. - result = String::CompareOrdinal(string1, string2); - if (result > 0) - relation = "comes after"; - else if (result == 0) - relation = "is the same as"; - else - relation = "comes before"; - - Console::WriteLine("'{0}' {1} '{2}'.", - string1, relation, string2); - } -}; - -int main() -{ - Example::Main(); -} - - -// The example produces the following output: -// 'brother' comes before 'Brother'. -// 'brother' is the same as 'Brother'. -// 'brother' comes after 'Brother'. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/remarks.cpp deleted file mode 100644 index 403d3a1c663..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/remarks.cpp +++ /dev/null @@ -1,197 +0,0 @@ -using namespace System; -using namespace System::Globalization; - -public ref class Example -{ -public: - static void Main() - { - Console::WriteLine("Hi!"); - } -}; - -int main() -{ - Example::Main(); -} - -// System.String.Compare(System.String,System.Int32,System.String,System.Int32,System.Int32) -public ref class CompareSample1_1 -{ - // - static bool IsFileURI(String^ path) - { - return (String::Compare(path, 0, "file:", 0, 5, true) == 0); - } - // -}; - -// System.String.Compare(System.String,System.Int32,System.String,System.Int32,System.Int32) -public ref class CompareSample1_2 -{ - // - static bool IsFileURI(String^ path) - { - return (String::Compare(path, 0, "file:", 0, 5, StringComparison::OrdinalIgnoreCase) == 0); - } - // -}; - -//System.String.Compare(System.String,System.Int32,System.String,System.Int32,System.Int32,System.Boolean) -public class CompareSample2_1 -{ - // - static bool IsFileURI(String^ path) - { - return (String::Compare(path, 0, "file:", 0, 5, true) == 0); - } - // -}; - -//System.String.Compare(System.String,System.Int32,System.String,System.Int32,System.Int32,System.Boolean) -public class CompareSample2_2 -{ - // - static bool IsFileURI(String^ path) - { - return (String::Compare(path, 0, "file:", 0, 5, StringComparison::OrdinalIgnoreCase) == 0); - } - // -}; - - -//System.String.Compare(System.String,System.Int32,System.String,System.Int32,System.Int32, -// System.Boolean,System.Globalization.CultureInfo) -public class CompareSample3_1 -{ - // - static bool IsFileURI(String^ path) - { - return (String::Compare(path, 0, "file:", 0, 5, true) == 0); - } - // -}; - -//System.String.Compare(System.String,System.Int32,System.String,System.Int32,System.Int32, -// System.Boolean,System.Globalization.CultureInfo) -public class CompareSample3_2 -{ - // - static bool IsFileURI(String^ path) - { - return (String::Compare(path, 0, "file:", 0, 5, StringComparison::OrdinalIgnoreCase) == 0); - } - // -}; - -//System.String.Compare(System.String,System.Int32,System.String,System.Int32, -// System.Int32,System.StringComparison) -public class CompareSample4_1 -{ - // - static bool IsFileURI(String^ path) - { - return (String::Compare(path, 0, "file:", 0, 5, true) == 0); - } - // -}; - -//System.String.Compare(System.String,System.Int32,System.String,System.Int32, -// System.Int32,System.StringComparison) -public class CompareSample4_2 -{ - // - static bool IsFileURI(String^ path) - { - return (String::Compare(path, 0, "file:", 0, 5, StringComparison::OrdinalIgnoreCase) == 0); - } - // -}; - -//System.String.Compare(System.String,System.String) -public class CompareSample5_1 -{ - // - static bool IsFileURI(String^ path) - { - return (String::Compare(path, 0, "file:", 0, 5, true) == 0); - } - // -}; - -//System.String.Compare(System.String,System.String) -public class CompareSample5_2 -{ - // - static bool IsFileURI(String^ path) - { - return (String::Compare(path, 0, "file:", 0, 5, StringComparison::OrdinalIgnoreCase) == 0); - } - // -}; - -//System.String.Compare(System.String,System.String,System.Boolean) -public class CompareSample6_1 -{ - // - static bool IsFileURI(String^ path) - { - return (String::Compare(path, 0, "file:", 0, 5, true) == 0); - } - // -}; - -//System.String.Compare(System.String,System.String,System.Boolean) -public class CompareSample6_2 -{ - // - static bool IsFileURI(String^ path) - { - return (String::Compare(path, 0, "file:", 0, 5, StringComparison::OrdinalIgnoreCase) == 0); - } - // -}; - -//System.String.Compare(System.String,System.String,System.Boolean,System.Globalization.CultureInfo) -public class CompareSample7_1 -{ - // - static bool IsFileURI(String^ path) - { - return (String::Compare(path, 0, "file:", 0, 5, true) == 0); - } - // -}; - -//System.String.Compare(System.String,System.String,System.Boolean,System.Globalization.CultureInfo) -public class CompareSample7_2 -{ - // - static bool IsFileURI(String^ path) - { - return (String::Compare(path, 0, "file:", 0, 5, StringComparison::OrdinalIgnoreCase) == 0); - } - // -}; - -//System.String.Compare(System.String,System.String,System.StringComparison) -public class CompareSample8_1 -{ - // - static bool IsFileURI(String^ path) - { - return (String::Compare(path, 0, "file:", 0, 5, true) == 0); - } - // -}; - -//System.String.Compare(System.String,System.String,System.StringComparison) -public class CompareSample8_2 -{ - // - static bool IsFileURI(String^ path) - { - return (String::Compare(path, 0, "file:", 0, 5, StringComparison::OrdinalIgnoreCase) == 0); - } - // -}; diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.CompareCmp/cpp/cmpcmp.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.CompareCmp/cpp/cmpcmp.cpp deleted file mode 100644 index 3c33eb9d8a7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.CompareCmp/cpp/cmpcmp.cpp +++ /dev/null @@ -1,140 +0,0 @@ -// -// This example demonstrates the -// System.String.Compare(String, String, StringComparison) method. - -using namespace System; -using namespace System::Threading; - -void Test(int testStringIndex, int searchStringIndex, - StringComparison comparison, array^ testI, - array^ testNames) -{ - String^ resultFormat = "{0} is {1} {2}"; - String^ resultString = "equal to"; - int comparisonValue = 0; - - comparisonValue = String::Compare(testI[testStringIndex], - testI[searchStringIndex], comparison); - if (comparisonValue < 0) - { - resultString = "less than"; - } - else if (comparisonValue > 0) - { - resultString = "greater than"; - } - Console::WriteLine(resultFormat, testNames[testStringIndex], resultString, - testNames[searchStringIndex]); -} - -int main() -{ - String^ introMessage = - "Compare three versions of the letter I using different " + - "values of StringComparison."; - - // Define an array of strings where each element contains a version of - // the letter I. (An array of strings is used so you can easily modify - // this code example to test additional or different combinations of - // strings.) - - array^ letterVariation = gcnew array(3); - // LATIN SMALL LETTER I (U+0069) - letterVariation[0] = "i"; - // LATIN SMALL LETTER DOTLESS I (U+0131) - letterVariation[1] = L"\u0131"; - // LATIN CAPITAL LETTER I (U+0049) - letterVariation[2] = "I"; - - array^ unicodeNames = { - "LATIN SMALL LETTER I (U+0069)", - "LATIN SMALL LETTER DOTLESS I (U+0131)", - "LATIN CAPITAL LETTER I (U+0049)"}; - - array^ comparisonValues = { - StringComparison::CurrentCulture, - StringComparison::CurrentCultureIgnoreCase, - StringComparison::InvariantCulture, - StringComparison::InvariantCultureIgnoreCase, - StringComparison::Ordinal, - StringComparison::OrdinalIgnoreCase}; - - Console::Clear(); - Console::WriteLine(introMessage); - - // Display the current culture because the culture-specific comparisons - // can produce different results with different cultures. - Console::WriteLine("The current culture is {0}.{1}", - Thread::CurrentThread->CurrentCulture->Name, Environment::NewLine); - - // Determine the relative sort order of three versions of the letter I. - for each (StringComparison stringCmp in comparisonValues) - { - Console::WriteLine("StringComparison.{0}:", stringCmp); - - // LATIN SMALL LETTER I (U+0069) : LATIN SMALL LETTER DOTLESS I - // (U+0131) - Test(0, 1, stringCmp, letterVariation, unicodeNames); - - // LATIN SMALL LETTER I (U+0069) : LATIN CAPITAL LETTER I (U+0049) - Test(0, 2, stringCmp, letterVariation, unicodeNames); - - // LATIN SMALL LETTER DOTLESS I (U+0131) : LATIN CAPITAL LETTER I - // (U+0049) - Test(1, 2, stringCmp, letterVariation, unicodeNames); - - Console::WriteLine(); - } -} - -/* -This code example produces the following results: - -Compare three versions of the letter I using different values of -StringComparison. -The current culture is en-US. - -StringComparison.CurrentCulture: -LATIN SMALL LETTER I (U+0069) is less than LATIN SMALL LETTER - DOTLESS I (U+0131) -LATIN SMALL LETTER I (U+0069) is less than LATIN CAPITAL LETTER I (U+0049) -LATIN SMALL LETTER DOTLESS I (U+0131) is greater than LATIN - CAPITAL LETTER I (U+0049) - -StringComparison.CurrentCultureIgnoreCase: -LATIN SMALL LETTER I (U+0069) is less than LATIN SMALL LETTER - DOTLESS I (U+0131) -LATIN SMALL LETTER I (U+0069) is equal to LATIN CAPITAL LETTER I (U+0049) -LATIN SMALL LETTER DOTLESS I (U+0131) is greater than LATIN - CAPITAL LETTER I (U+0049) - -StringComparison.InvariantCulture: -LATIN SMALL LETTER I (U+0069) is less than LATIN SMALL LETTER - DOTLESS I (U+0131) -LATIN SMALL LETTER I (U+0069) is less than LATIN CAPITAL LETTER I (U+0049) -LATIN SMALL LETTER DOTLESS I (U+0131) is greater than LATIN - CAPITAL LETTER I (U+0049) - -StringComparison.InvariantCultureIgnoreCase: -LATIN SMALL LETTER I (U+0069) is less than LATIN SMALL LETTER - DOTLESS I (U+0131) -LATIN SMALL LETTER I (U+0069) is equal to LATIN CAPITAL LETTER I (U+0049) -LATIN SMALL LETTER DOTLESS I (U+0131) is greater than LATIN - CAPITAL LETTER I (U+0049) - -StringComparison.Ordinal: -LATIN SMALL LETTER I (U+0069) is less than LATIN SMALL LETTER - DOTLESS I (U+0131) -LATIN SMALL LETTER I (U+0069) is greater than LATIN CAPITAL LETTER I (U+0049) -LATIN SMALL LETTER DOTLESS I (U+0131) is greater than LATIN - CAPITAL LETTER I (U+0049) - -StringComparison.OrdinalIgnoreCase: -LATIN SMALL LETTER I (U+0069) is less than LATIN SMALL LETTER - DOTLESS I (U+0131) -LATIN SMALL LETTER I (U+0069) is equal to LATIN CAPITAL LETTER I (U+0049) -LATIN SMALL LETTER DOTLESS I (U+0131) is greater than LATIN - CAPITAL LETTER I (U+0049) - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.EndsWithCmp/cpp/ewcmp.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.EndsWithCmp/cpp/ewcmp.cpp deleted file mode 100644 index 85a57be8c79..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.EndsWithCmp/cpp/ewcmp.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// -// This example demonstrates the -// System.String.EndsWith(String, StringComparison) method. - -using namespace System; -using namespace System::Threading; - -void Test(String^ testString, String^ searchString, - StringComparison comparison) -{ - String^ resultFormat = "\"{0}\" {1} with \"{2}\"."; - String^ resultString = "does not end"; - - if (testString->EndsWith(searchString, comparison)) - { - resultString = "ends"; - } - Console::WriteLine(resultFormat, testString, resultString, searchString); -} - -int main() -{ - String^ introMessage = - "Determine whether a string ends with another string, " + - "using\ndifferent values of StringComparison."; - - array^ comparisonValues = { - StringComparison::CurrentCulture, - StringComparison::CurrentCultureIgnoreCase, - StringComparison::InvariantCulture, - StringComparison::InvariantCultureIgnoreCase, - StringComparison::Ordinal, - StringComparison::OrdinalIgnoreCase}; - - Console::WriteLine(introMessage); - - // Display the current culture because the culture-specific comparisons - // can produce different results with different cultures. - Console::WriteLine("The current culture is {0}.\n", - Thread::CurrentThread->CurrentCulture->Name); - // Perform two tests for each StringComparison - for each (StringComparison stringCmp in comparisonValues) - { - Console::WriteLine("StringComparison.{0}:", stringCmp); - Test("abcXYZ", "XYZ", stringCmp); - Test("abcXYZ", "xyz", stringCmp); - Console::WriteLine(); - } -} - -/* -This code example produces the following results: - -Determine whether a string ends with another string, using -different values of StringComparison. -The current culture is en-US. - -StringComparison.CurrentCulture: -"abcXYZ" ends with "XYZ". -"abcXYZ" does not end with "xyz". - -StringComparison.CurrentCultureIgnoreCase: -"abcXYZ" ends with "XYZ". -"abcXYZ" ends with "xyz". - -StringComparison.InvariantCulture: -"abcXYZ" ends with "XYZ". -"abcXYZ" does not end with "xyz". - -StringComparison.InvariantCultureIgnoreCase: -"abcXYZ" ends with "XYZ". -"abcXYZ" ends with "xyz". - -StringComparison.Ordinal: -"abcXYZ" ends with "XYZ". -"abcXYZ" does not end with "xyz". - -StringComparison.OrdinalIgnoreCase: -"abcXYZ" ends with "XYZ". -"abcXYZ" ends with "xyz". - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.Equality/CPP/equalityop.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.Equality/CPP/equalityop.cpp deleted file mode 100644 index ecbc4947741..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.Equality/CPP/equalityop.cpp +++ /dev/null @@ -1,28 +0,0 @@ - -// -// Example for the String Equality operator. -using namespace System; -void CompareAndDisplay( String^ Comparand ) -{ - String^ Lower = "abcd"; - Console::WriteLine( "\"{0}\" == \"{1}\" ? {2}", Lower, Comparand, Lower == Comparand ); -} - -int main() -{ - Console::WriteLine( "This example of the String Equality operator\n" - "generates the following output.\n" ); - CompareAndDisplay( "ijkl" ); - CompareAndDisplay( "ABCD" ); - CompareAndDisplay( "abcd" ); -} - -/* -This example of the String Equality operator -generates the following output. - -"abcd" == "ijkl" ? False -"abcd" == "ABCD" ? False -"abcd" == "abcd" ? True -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/format4.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/format4.cpp deleted file mode 100644 index 546e49f2c89..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/format4.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// Format4.cpp : Defines the entry point for the console application. -// - -//#include "stdafx.h" - -// -using namespace System; - -void main() -{ - String^ formatString = " {0,10} ({0,8:X8})\n" + - "And {1,10} ({1,8:X8})\n" + - " = {2,10} ({2,8:X8})"; - int value1 = 16932; - int value2 = 15421; - String^ result = String::Format(formatString, - value1, value2, value1 & value2); - Console::WriteLine(result); -} -// The example displays the following output: -// 16932 (00004224) -// And 15421 (00003C3D) -// = 36 (00000024) -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/format5.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/format5.cpp deleted file mode 100644 index 8415cc4c1df..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/format5.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// Format5.cpp : Defines the entry point for the console application. -// - -//#include "stdafx.h" - -// -using namespace System; - -void main() -{ - DateTime date1 = DateTime(2009, 7, 1); - TimeSpan hiTime = TimeSpan(14, 17, 32); - Decimal hiTemp = (Decimal) 62.1; - TimeSpan loTime = TimeSpan(3, 16, 10); - Decimal loTemp = (Decimal)54.8; - - String^ result1 = String::Format("Temperature on {0:d}:\n{1,11}: {2} degrees (hi)\n{3,11}: {4} degrees (lo)", - date1, hiTime, hiTemp, loTime, loTemp); - Console::WriteLine(result1); - Console::WriteLine(); - - String^ result2 = String::Format("Temperature on {0:d}:\n{1,11}: {2} degrees (hi)\n{3,11}: {4} degrees (lo)", - gcnew array { date1, hiTime, hiTemp, loTime, loTemp }); - Console::WriteLine(result2); -} -// The example displays the following output: -// Temperature on 7/1/2009: -// 14:17:32: 62.1 degrees (hi) -// 03:16:10: 54.8 degrees (lo) -// Temperature on 7/1/2009: -// 14:17:32: 62.1 degrees (hi) -// 03:16:10: 54.8 degrees (lo) -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/format7.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/format7.cpp deleted file mode 100644 index 166e0c1c832..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/format7.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// Format7.cpp : Defines the entry point for the console application. -// - -//#include "stdafx.h" - -// -using namespace System; - -void main() -{ - DateTime birthdate = DateTime(1993, 7, 28); - array^ dates = gcnew array { DateTime(1993, 8, 16), - DateTime(1994, 7, 28), - DateTime(2000, 10, 16), - DateTime(2003, 7, 27), - DateTime(2007, 5, 27) }; - - for each (DateTime dateValue in dates) - { - TimeSpan interval = dateValue - birthdate; - // Get the approximate number of years, without accounting for leap years. - int years = ((int)interval.TotalDays) / 365; - // See if adding the number of years exceeds dateValue. - String^ output; - if (birthdate.AddYears(years) <= dateValue) { - output = String::Format("You are now {0} years old.", years); - Console::WriteLine(output); - } - else { - output = String::Format("You are now {0} years old.", years - 1); - Console::WriteLine(output); - } - } -} -// The example displays the following output: -// You are now 0 years old. -// You are now 1 years old. -// You are now 7 years old. -// You are now 9 years old. -// You are now 13 years old. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/format_paramarray1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/format_paramarray1.cpp deleted file mode 100644 index 30af678140b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/format_paramarray1.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Format_ParamArray1.cpp : Defines the entry point for the console application. -// - -//#include "stdafx.h" - -// -using namespace System; - -ref class CityInfo -{ -public: - CityInfo(String^ name, int population, Decimal area, int year) - { - this->Name = name; - this->Population = population; - this->Area = area; - this->Year = year; - } - - String^ Name; - int Population; - Decimal Area; - int Year; -}; - -ref class Example -{ -public: - static void ShowPopulationData(CityInfo^ city) - { - array^ args = gcnew array { city->Name, city->Year, city->Population, city->Area }; - String^ result = String::Format("{0} in {1}: Population {2:N0}, Area {3:N1} sq. feet", - args); - Console::WriteLine(result); - } -}; - -void main() -{ - CityInfo^ nyc2010 = gcnew CityInfo("New York", 8175133, (Decimal) 302.64, 2010); - Example::ShowPopulationData(nyc2010); - CityInfo^ sea2010 = gcnew CityInfo("Seattle", 608660, (Decimal) 83.94, 2010); - Example::ShowPopulationData(sea2010); -} -// The example displays the following output: -// New York in 2010: Population 8,175,133, Area 302.6 sq. feet -// Seattle in 2010: Population 608,660, Area 83.9 sq. feet -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/formatexample2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/formatexample2.cpp deleted file mode 100644 index 1acc61d5d34..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/formatexample2.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// FormatExample2.cpp : Defines the entry point for the console application. -// - -// #include "stdafx.h" - -// -using namespace System; - -ref class CustomerFormatter : IFormatProvider, ICustomFormatter -{ -public: - virtual Object^ GetFormat(Type^ formatType) - { - if (formatType == ICustomFormatter::typeid) - return this; - else - return nullptr; - } - - virtual String^ Format(String^ format, - Object^ arg, - IFormatProvider^ formatProvider) - { - if (!this->Equals(formatProvider)) - { - return nullptr; - } - else - { - if (String::IsNullOrEmpty(format)) - format = "G"; - - String^ customerString = arg->ToString(); - if (customerString->Length < 8) - customerString = customerString->PadLeft(8, '0'); - - format = format->ToUpper(); - if (format == L"G") - return customerString->Substring(0, 1) + "-" + - customerString->Substring(1, 5) + "-" + - customerString->Substring(6); - else if (format == L"S") - return customerString->Substring(0, 1) + "/" + - customerString->Substring(1, 5) + "/" + - customerString->Substring(6); - else if (format == L"P") - return customerString->Substring(0, 1) + "." + - customerString->Substring(1, 5) + "." + - customerString->Substring(6); - else - throw gcnew FormatException( - String::Format("The '{0}' format specifier is not supported.", format)); - } - } -}; - -void main() -{ - int acctNumber = 79203159; - Console::WriteLine(String::Format(gcnew CustomerFormatter, "{0}", acctNumber)); - Console::WriteLine(String::Format(gcnew CustomerFormatter, "{0:G}", acctNumber)); - Console::WriteLine(String::Format(gcnew CustomerFormatter, "{0:S}", acctNumber)); - Console::WriteLine(String::Format(gcnew CustomerFormatter, "{0:P}", acctNumber)); - try { - Console::WriteLine(String::Format(gcnew CustomerFormatter, "{0:X}", acctNumber)); - } - catch (FormatException^ e) { - Console::WriteLine(e->Message); - } -} -// The example displays the following output: -// 7-92031-59 -// 7-92031-59 -// 7/92031/59 -// 7.92031.59 -// The 'X' format specifier is not supported. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/formatexample4.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/formatexample4.cpp deleted file mode 100644 index a0a958f9dc8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/formatexample4.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// FormatExample4.cpp : Defines the entry point for the console application. -// - -//#include "stdafx.h" - - -// -using namespace System; -using namespace System::Collections::Generic; - -void main() -{ - Dictionary^ temperatureInfo = gcnew Dictionary(); - temperatureInfo->Add(DateTime(2010, 6, 1, 14, 0, 0), 87.46); - temperatureInfo->Add(DateTime(2010, 12, 1, 10, 0, 0), 36.81); - - Console::WriteLine("Temperature Information:\n"); - String^ output; - for each (KeyValuePair^ item in temperatureInfo) - { - output = String::Format("Temperature at {0,8:t} on {0,9:d}: {1,5:N1}°F", - item->Key, item->Value); - Console::WriteLine(output); - } -} -// The example displays the following output: -// Temperature Information: -// -// Temperature at 2:00 PM on 6/1/2010: 87.5°F -// Temperature at 10:00 AM on 12/1/2010: 36.8°F -// - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/formatoverload1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/formatoverload1.cpp deleted file mode 100644 index 34c12932dfc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/formatoverload1.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// FormatOverload1.cpp : Defines the entry point for the console application. -// - -//#include "stdafx.h" - -// -using namespace System; - -void main() -{ - DateTime^ dat = gcnew DateTime(2012, 1, 17, 9, 30, 0); - String^ city = "Chicago"; - int temp = -16; - String^ output = String::Format("At {0} in {1}, the temperature was {2} degrees.", - dat, city, temp); - Console::WriteLine(output); -} -// The example displays the following output: -// At 1/17/2012 9:30:00 AM in Chicago, the temperature was -16 degrees. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/formatoverload2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/formatoverload2.cpp deleted file mode 100644 index 6ac7fe64f84..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/formatoverload2.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// FormatOverload2.cpp : Defines the entry point for the console application. -// - -//#include "stdafx.h" - -// -using namespace System; - -void main() -{ - // Create array of 5-tuples with population data for three U.S. cities, 1940-1950. - array^>^ cities = gcnew array^> - { gcnew Tuple("Los Angeles", DateTime(1940, 1, 1), 1504277, - DateTime(1950, 1, 1), 1970358), - gcnew Tuple("New York", DateTime(1940, 1, 1), 7454995, - DateTime(1950, 1, 1), 7891957), - gcnew Tuple("Chicago", DateTime(1940, 1, 1), 3396808, - DateTime(1950, 1, 1), 3620962), - gcnew Tuple("Detroit", DateTime(1940, 1, 1), 1623452, - DateTime(1950, 1, 1), 1849568) }; - - // Display header - String^ header = String::Format("{0,-12}{1,8}{2,12}{1,8}{2,12}{3,14}\n", - "City", "Year", "Population", "Change (%)"); - Console::WriteLine(header); - String^ output; - for each (Tuple^ city in cities) { - output = String::Format("{0,-12}{1,8:yyyy}{2,12:N0}{3,8:yyyy}{4,12:N0}{5,14:P1}", - city->Item1, city->Item2, city->Item3, city->Item4, city->Item5, - (city->Item5 - city->Item3)/ (double)city->Item3); - Console::WriteLine(output); - } -} -// The example displays the following output: -// City Year Population Year Population Change (%) -// -// Los Angeles 1940 1,504,277 1950 1,970,358 31.0 % -// New York 1940 7,454,995 1950 7,891,957 5.9 % -// Chicago 1940 3,396,808 1950 3,620,962 6.6 % -// Detroit 1940 1,623,452 1950 1,849,568 13.9 % -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/formatsyntax1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/formatsyntax1.cpp deleted file mode 100644 index c0e1e10820b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/formatsyntax1.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// FormatSyntax1.cpp : Defines the entry point for the console application. -// - -//#include "stdafx.h" - -using namespace System; - -void main() -{ - String^ value = -// -String::Format("{0,-10:C}", (Decimal) 126347.89); -// -} - - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/interceptor2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/interceptor2.cpp deleted file mode 100644 index a5be70b67be..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/interceptor2.cpp +++ /dev/null @@ -1,122 +0,0 @@ -// Interceptor2.cpp : Defines the entry point for the console application. -// - -//#include "stdafx.h" - -// -using namespace System; -using namespace System::Globalization; - -ref class InterceptProvider : IFormatProvider, ICustomFormatter -{ -public: - virtual Object^ GetFormat(Type^ formatType) - { - if (formatType == ICustomFormatter::typeid) - return this; - else - return nullptr; - } - - virtual String^ Format(String^ format, Object^ obj, IFormatProvider^ provider) - { - // Display information about method call. - String^ formatString = format != nullptr ? format : ""; - Console::WriteLine("Provider: {0}, Object: {1}, Format String: {2}", - provider, obj != nullptr ? obj : "", formatString); - - if (obj == nullptr) return String::Empty; - - // If this is a byte and the "R" format string, format it with Roman numerals. - if (obj->GetType() == Byte::typeid && formatString->ToUpper()->Equals("R")) { - Byte value = (Byte) obj; - int remainder; - int result; - String^ returnString = String::Empty; - - // Get the hundreds digit(s) - result = Math::DivRem(value, 100, remainder); - if (result > 0) - returnString = gcnew String('C', result); - value = (Byte) remainder; - // Get the 50s digit - result = Math::DivRem(value, 50, remainder); - if (result == 1) - returnString += "L"; - value = (Byte) remainder; - // Get the tens digit. - result = Math::DivRem(value, 10, remainder); - if (result > 0) - returnString += gcnew String('X', result); - value = (Byte) remainder; - // Get the fives digit. - result = Math::DivRem(value, 5, remainder); - if (result > 0) - returnString += "V"; - value = (Byte) remainder; - // Add the ones digit. - if (remainder > 0) - returnString += gcnew String('I', remainder); - - // Check whether we have too many X characters. - int pos = returnString->IndexOf("XXXX"); - if (pos >= 0) { - int xPos = returnString->IndexOf("L"); - if ((xPos >= 0) & (xPos == pos - 1)) - returnString = returnString->Replace("LXXXX", "XC"); - else - returnString = returnString->Replace("XXXX", "XL"); - } - // Check whether we have too many I characters - pos = returnString->IndexOf("IIII"); - if (pos >= 0) - if (returnString->IndexOf("V") >= 0) - returnString = returnString->Replace("VIIII", "IX"); - else - returnString = returnString->Replace("IIII", "IV"); - - return returnString; - } - - // Use default for all other formatting. - if (obj->GetType() == IFormattable::typeid) - return ((IFormattable^) obj)->ToString(format, CultureInfo::CurrentCulture); - else - return obj->ToString(); - } -}; - -void main() -{ - int n = 10; - double value = 16.935; - DateTime day = DateTime::Now; - InterceptProvider^ provider = gcnew InterceptProvider(); - Console::WriteLine(String::Format(provider, "{0:N0}: {1:C2} on {2:d}\n", n, value, day)); - Console::WriteLine(String::Format(provider, "{0}: {1:F}\n", "Today: ", - (DayOfWeek) DateTime::Now.DayOfWeek)); - Console::WriteLine(String::Format(provider, "{0:X}, {1}, {2}\n", - (Byte) 2, (Byte) 12, (Byte) 199)); - Console::WriteLine(String::Format(provider, "{0:R}, {1:R}, {2:R}\n", - (Byte) 2, (Byte) 12, (Byte) 199)); -} -// The example displays the following output: -// Provider: InterceptProvider, Object: 10, Format String: N0 -// Provider: InterceptProvider, Object: 16.935, Format String: C2 -// Provider: InterceptProvider, Object: 1/31/2013 6:10:28 PM, Format String: d -// 10: $16.94 on 1/31/2013 -// -// Provider: InterceptProvider, Object: Today: , Format String: -// Provider: InterceptProvider, Object: Thursday, Format String: F -// Today: : Thursday -// -// Provider: InterceptProvider, Object: 2, Format String: X -// Provider: InterceptProvider, Object: 12, Format String: -// Provider: InterceptProvider, Object: 199, Format String: -// 2, 12, 199 -// -// Provider: InterceptProvider, Object: 2, Format String: R -// Provider: InterceptProvider, Object: 12, Format String: R -// Provider: InterceptProvider, Object: 199, Format String: R -// II, XII, CXCIX -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/starting1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/starting1.cpp deleted file mode 100644 index d74de7f473c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/starting1.cpp +++ /dev/null @@ -1,80 +0,0 @@ -using namespace System; -using namespace System::Text; - -ref class Example -{ - public: - static void Snippet31() - { - // - String^ s = String::Format("At {0}, the temperature is {1}°C.", - DateTime::Now, 20.4); - // Output similar to: 'At 4/10/2015 9:29:41 AM, the temperature is 20.4°C.' - // - Console::WriteLine(s); - } - - static void Snippet32() - { - // - String^ s = String::Format("It is now {0:d} at {0:t}", - DateTime::Now); - // Output similar to: 'It is now 4/10/2015 at 10:04 AM' - // - Console::WriteLine(s); - } - - static void Snippet33() - { - // - array^ years = { 2013, 2014, 2015 }; - array^ population = { 1025632, 1105967, 1148203 }; - StringBuiler^ sb = gcnew StringBuilder(); - sb->Append(String::Format("{0,6} {1,15}\n\n", "Year", "Population")); - for(int index = 0; index < years->Length; index++) - sb->AppendFormat("{0,6} {1,15:N0}\n", - years[index], population[index]); - // Result: - // Year Population - // - // 2013 1,025,632 - // 2014 1,105,967 - // 2015 1,148,203 - // - Console::WriteLine(sb); - } - - static void Snippet34() - { - // - array^ years = { 2013, 2014, 2015 }; - array^ population = { 1025632, 1105967, 1148203 }; - String^ s = String::Format("{0,-10} {1,-10}\n\n", "Year", "Population"); - for(int index = 0; index < years->Length; index++) - s += String::Format("{0,-10} {1,-10:N0}\n", - years[index], population[index]); - // Result: - // Year Population - // - // 2013 1,025,632 - // 2014 1,105,967 - // 2015 1,148,203 - // - Console::WriteLine("\n{0}", s); - } -}; - -void main() -{ - // - Decimal temp = (Decimal)20.4; - String^ s = String::Format("The temperature is {0}°C.", temp); - Console::WriteLine(s); - // Displays 'The temperature is 20.4°C.' - // - - Example::Snippet31(); - Example::Snippet32(); - Example::Snippet33(); - Example::Snippet34(); -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/starting2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/starting2.cpp deleted file mode 100644 index 068c5e9cd1c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/starting2.cpp +++ /dev/null @@ -1,37 +0,0 @@ -using namespace System; - -ref class Example -{ - public: - - void Main() - { - // - Decimal pricePerOunce = (Decimal)17.36; - String^ s = String::Format("The current price is {0} per ounce.", - pricePerOunce); - // Result: The current price is 17.36 per ounce. - // - Console::WriteLine(s); - ShowFormatted(); - } - - void ShowFormatted() - { - // - Decimal pricePerOunce = (Decimal)17.36; - String^ s = String::Format("The current price is {0:C2} per ounce.", - pricePerOunce); - // Result if current culture is en-US: - // The current price is $17.36 per ounce. - // - Console::WriteLine(s); - } -}; - - -void main() -{ - Example^ ex = gcnew Example(); - ex->Main(); -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.GetEnumerator/CPP/getenumerator.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.GetEnumerator/CPP/getenumerator.cpp deleted file mode 100644 index cf52d962e88..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.GetEnumerator/CPP/getenumerator.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// -using namespace System; - -void EnumerateAndDisplay(String^ phrase) -{ - Console::WriteLine("The characters in the string \"{0}\" are:", - phrase); - - int CharCount = 0; - int controlChars = 0; - int alphanumeric = 0; - int punctuation = 0; - - for each (Char ch in phrase) { - Console::Write("'{0}' ", (! Char::IsControl(ch)) ? ch.ToString() : - "0x" + Convert::ToUInt16(ch).ToString("X4")); - if (Char::IsLetterOrDigit(ch)) - alphanumeric++; - else if (Char::IsControl(ch)) - controlChars++; - else if (Char::IsPunctuation(ch)) - punctuation++; - CharCount++; - } - - Console::WriteLine("\n Total characters: {0,3}", CharCount); - Console::WriteLine(" Alphanumeric characters: {0,3}", alphanumeric); - Console::WriteLine(" Punctuation characters: {0,3}", punctuation); - Console::WriteLine(" Control Characters: {0,3}\n", controlChars); -} - -int main() -{ - EnumerateAndDisplay("Test Case"); - EnumerateAndDisplay("This is a sentence."); - EnumerateAndDisplay("Has\ttwo\ttabs"); - EnumerateAndDisplay("Two\nnew\nlines"); -} -// The example displays the following output: -// The characters in the string "Test Case" are: -// 'T' 'e' 's' 't' ' ' 'C' 'a' 's' 'e' -// Total characters: 9 -// Alphanumeric characters: 8 -// Punctuation characters: 0 -// Control Characters: 0 -// -// The characters in the string "This is a sentence." are: -// 'T' 'h' 'i' 's' ' ' 'i' 's' ' ' 'a' ' ' 's' 'e' 'n' 't' 'e' 'n' 'c' 'e' '.' -// Total characters: 19 -// Alphanumeric characters: 15 -// Punctuation characters: 1 -// Control Characters: 0 -// -// The characters in the string "Has two tabs" are: -// 'H' 'a' 's' '0x0009' 't' 'w' 'o' '0x0009' 't' 'a' 'b' 's' -// Total characters: 12 -// Alphanumeric characters: 10 -// Punctuation characters: 0 -// Control Characters: 2 -// -// The characters in the string "Two -// new -// lines" are: -// 'T' 'w' 'o' '0x000A' 'n' 'e' 'w' '0x000A' 'l' 'i' 'n' 'e' 's' -// Total characters: 13 -// Alphanumeric characters: 11 -// Punctuation characters: 0 -// Control Characters: 2 -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.GetHashCode/CPP/gethashcode.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.GetHashCode/CPP/gethashcode.cpp deleted file mode 100644 index d0860d3d34b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.GetHashCode/CPP/gethashcode.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// -using namespace System; - -void DisplayHashCode( String^ Operand ) -{ - int HashCode = Operand->GetHashCode(); - Console::WriteLine( "The hash code for \"{0}\" is: 0x{1:X8}, {1}", Operand, HashCode ); -} - -int main() -{ - DisplayHashCode( "" ); - DisplayHashCode( "a" ); - DisplayHashCode( "ab" ); - DisplayHashCode( "abc" ); - DisplayHashCode( "abd" ); - DisplayHashCode( "abe" ); - DisplayHashCode( "abcdef" ); - DisplayHashCode( "abcdeg" ); - DisplayHashCode( "abcdeh" ); - DisplayHashCode( "abcdei" ); - DisplayHashCode( "Abcdeg" ); - DisplayHashCode( "Abcdeh" ); - DisplayHashCode( "Abcdei" ); -} - -/* -This example displays output like the following: - The hash code for "" is: 0x2D2816FE, 757602046 - The hash code for "a" is: 0xCDCAB7BF, -842352705 - The hash code for "ab" is: 0xCDE8B7BF, -840386625 - The hash code for "abc" is: 0x2001D81A, 536991770 - The hash code for "abd" is: 0xC2A94CB5, -1029092171 - The hash code for "abe" is: 0x6550C150, 1699791184 - The hash code for "abcdef" is: 0x1762906D, 392335469 - The hash code for "abcdeg" is: 0x1763906D, 392401005 - The hash code for "abcdeh" is: 0x175C906D, 391942253 - The hash code for "abcdei" is: 0x175D906D, 392007789 - The hash code for "Abcdeg" is: 0x1763954D, 392402253 - The hash code for "Abcdeh" is: 0x175C954D, 391943501 - The hash code for "Abcdei" is: 0x175D954D, 392009037 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.IndexOf/CPP/indexof_c.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.IndexOf/CPP/indexof_c.cpp deleted file mode 100644 index 129189e1c03..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.IndexOf/CPP/indexof_c.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// -using namespace System; - -void main() -{ - // Create a Unicode String with 5 Greek Alpha characters. - String^ szGreekAlpha = gcnew String(L'\x0391',5); - - // Create a Unicode String with a 3 Greek Omega characters. - String^ szGreekOmega = L"\x03A9\x03A9\x03A9"; - - String^ szGreekLetters = String::Concat(szGreekOmega, szGreekAlpha, - szGreekOmega->Clone()); - - // Display the entire string. - Console::WriteLine(szGreekLetters); - - // The first index of Alpha. - int ialpha = szGreekLetters->IndexOf( L'\x0391'); - // The first index of Omega. - int iomega = szGreekLetters->IndexOf(L'\x03A9'); - - Console::WriteLine("First occurrence of the Greek letter Alpha: Index {0}", - ialpha); - Console::WriteLine("First occurrence of the Greek letter Omega: Index {0}", - iomega); -} -// The example displays the following output: -// The string: OOO?????OOO -// First occurrence of the Greek letter Alpha: Index 3 -// First occurrence of the Greek letter Omega: Index 0 -// - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.IndexOf/CPP/indexofcii.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.IndexOf/CPP/indexofcii.cpp deleted file mode 100644 index 536ce88ab56..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.IndexOf/CPP/indexofcii.cpp +++ /dev/null @@ -1,61 +0,0 @@ - -// -// Example for the String::IndexOf( Char, int, int ) method. -using namespace System; -void FindAllChar( Char target, String^ searched ) -{ - Console::Write( "The character '{0}' occurs at position(s): ", target ); - int startIndex = -1; - int hitCount = 0; - - // Search for all occurrences of the target. - while ( true ) - { - startIndex = searched->IndexOf( target, startIndex + 1, searched->Length - startIndex - 1 ); - - // Exit the loop if the target is not found. - if ( startIndex < 0 ) - break; - - Console::Write( "{0}, ", startIndex ); - hitCount++; - } - - Console::WriteLine( "occurrences: {0}", hitCount ); -} - -int main() -{ - String^ br1 = "0----+----1----+----2----+----3----+----" - "4----+----5----+----6----+----7"; - String^ br2 = "0123456789012345678901234567890123456789" - "0123456789012345678901234567890"; - String^ str = "ABCDEFGHI abcdefghi ABCDEFGHI abcdefghi " - "ABCDEFGHI abcdefghi ABCDEFGHI"; - Console::WriteLine( "This example of String::IndexOf( Char, int, int )\n" - "generates the following output." ); - Console::WriteLine( "{0}{1}{0}{2}{0}{3}{0}", Environment::NewLine, br1, br2, str ); - FindAllChar( 'A', str ); - FindAllChar( 'a', str ); - FindAllChar( 'I', str ); - FindAllChar( 'i', str ); - FindAllChar( '@', str ); - FindAllChar( ' ', str ); -} - -/* -This example of String::IndexOf( Char, int, int ) -generates the following output. - -0----+----1----+----2----+----3----+----4----+----5----+----6----+----7 -01234567890123456789012345678901234567890123456789012345678901234567890 -ABCDEFGHI abcdefghi ABCDEFGHI abcdefghi ABCDEFGHI abcdefghi ABCDEFGHI - -The character 'A' occurs at position(s): 0, 20, 40, 60, occurrences: 4 -The character 'a' occurs at position(s): 10, 30, 50, occurrences: 3 -The character 'I' occurs at position(s): 8, 28, 48, 68, occurrences: 4 -The character 'i' occurs at position(s): 18, 38, 58, occurrences: 3 -The character '@' occurs at position(s): occurrences: 0 -The character ' ' occurs at position(s): 9, 19, 29, 39, 49, 59, occurrences: 6 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.IndexOf/CPP/simple1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.IndexOf/CPP/simple1.cpp deleted file mode 100644 index 777e7856dd8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.IndexOf/CPP/simple1.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// -using namespace System; - -void main() -{ - String^ str = "animal"; - String^ toFind = "n"; - int index = str->IndexOf("n"); - Console::WriteLine("Found '{0}' in '{1}' at position {2}", - toFind, str, index); - -} -// The example displays the following output: -// Found 'n' in 'animal' at position 1 -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.Inequality/CPP/inequalityop.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.Inequality/CPP/inequalityop.cpp deleted file mode 100644 index fb115d56be2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.Inequality/CPP/inequalityop.cpp +++ /dev/null @@ -1,28 +0,0 @@ - -// -// Example for the String Inequality operator. -using namespace System; -void CompareAndDisplay( String^ Comparand ) -{ - String^ Lower = "abcd"; - Console::WriteLine( "\"{0}\" != \"{1}\" ? {2}", Lower, Comparand, Lower != Comparand ); -} - -int main() -{ - Console::WriteLine( "This example of the String Inequality operator\n" - "generates the following output.\n" ); - CompareAndDisplay( "ijkl" ); - CompareAndDisplay( "ABCD" ); - CompareAndDisplay( "abcd" ); -} - -/* -This example of the String Inequality operator -generates the following output. - -"abcd" != "ijkl" ? True -"abcd" != "ABCD" ? True -"abcd" != "abcd" ? False -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.ToUpper/cpp/ToUpperEx.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.ToUpper/cpp/ToUpperEx.cpp deleted file mode 100644 index 9a0970cfcc3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.ToUpper/cpp/ToUpperEx.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// -using namespace System; - -void main() -{ - int n = 0; - for (int ctr = 0x20; ctr <= 0x017F; ctr++) { - String^ string1 = Convert::ToChar(ctr).ToString(); - String^ upperString = string1->ToUpper(); - if (string1 != upperString) { - Console::Write(L"{0} (\u+{1}) --> {2} (\u+{3}) ", - string1, - Convert::ToUInt16(string1[0]).ToString("X4"), - upperString, - Convert::ToUInt16(upperString[0]).ToString("X4")); - n++; - if (n % 2 == 0) Console::WriteLine(); - } - } -} -// The example displays the following output: -// a (\u+0061) --> A (\u+0041) b (\u+0062) --> B (\u+0042) -// c (\u+0063) --> C (\u+0043) d (\u+0064) --> D (\u+0044) -// e (\u+0065) --> E (\u+0045) f (\u+0066) --> F (\u+0046) -// g (\u+0067) --> G (\u+0047) h (\u+0068) --> H (\u+0048) -// i (\u+0069) --> I (\u+0049) j (\u+006A) --> J (\u+004A) -// k (\u+006B) --> K (\u+004B) l (\u+006C) --> L (\u+004C) -// m (\u+006D) --> M (\u+004D) n (\u+006E) --> N (\u+004E) -// o (\u+006F) --> O (\u+004F) p (\u+0070) --> P (\u+0050) -// q (\u+0071) --> Q (\u+0051) r (\u+0072) --> R (\u+0052) -// s (\u+0073) --> S (\u+0053) t (\u+0074) --> T (\u+0054) -// u (\u+0075) --> U (\u+0055) v (\u+0076) --> V (\u+0056) -// w (\u+0077) --> W (\u+0057) x (\u+0078) --> X (\u+0058) -// y (\u+0079) --> Y (\u+0059) z (\u+007A) --> Z (\u+005A) -// à (\u+00E0) --> À (\u+00C0) á (\u+00E1) --> à (\u+00C1) -// â (\u+00E2) -->  (\u+00C2) ã (\u+00E3) --> à (\u+00C3) -// ä (\u+00E4) --> Ä (\u+00C4) Ã¥ (\u+00E5) --> Ã… (\u+00C5) -// æ (\u+00E6) --> Æ (\u+00C6) ç (\u+00E7) --> Ç (\u+00C7) -// è (\u+00E8) --> È (\u+00C8) é (\u+00E9) --> É (\u+00C9) -// ê (\u+00EA) --> Ê (\u+00CA) ë (\u+00EB) --> Ë (\u+00CB) -// ì (\u+00EC) --> ÃŒ (\u+00CC) í (\u+00ED) --> à (\u+00CD) -// î (\u+00EE) --> ÃŽ (\u+00CE) ï (\u+00EF) --> à (\u+00CF) -// ð (\u+00F0) --> à (\u+00D0) ñ (\u+00F1) --> Ñ (\u+00D1) -// ò (\u+00F2) --> Ã’ (\u+00D2) ó (\u+00F3) --> Ó (\u+00D3) -// ô (\u+00F4) --> Ô (\u+00D4) õ (\u+00F5) --> Õ (\u+00D5) -// ö (\u+00F6) --> Ö (\u+00D6) ø (\u+00F8) --> Ø (\u+00D8) -// ù (\u+00F9) --> Ù (\u+00D9) ú (\u+00FA) --> Ú (\u+00DA) -// û (\u+00FB) --> Û (\u+00DB) ü (\u+00FC) --> Ü (\u+00DC) -// ý (\u+00FD) --> à (\u+00DD) þ (\u+00FE) --> Þ (\u+00DE) -// ÿ (\u+00FF) --> Ÿ (\u+0178) Ä (\u+0101) --> Ä€ (\u+0100) -// ă (\u+0103) --> Ä‚ (\u+0102) Ä… (\u+0105) --> Ä„ (\u+0104) -// ć (\u+0107) --> Ć (\u+0106) ĉ (\u+0109) --> Ĉ (\u+0108) -// Ä‹ (\u+010B) --> ÄŠ (\u+010A) Ä (\u+010D) --> ÄŒ (\u+010C) -// Ä (\u+010F) --> ÄŽ (\u+010E) Ä‘ (\u+0111) --> Ä (\u+0110) -// Ä“ (\u+0113) --> Ä’ (\u+0112) Ä• (\u+0115) --> Ä” (\u+0114) -// Ä— (\u+0117) --> Ä– (\u+0116) Ä™ (\u+0119) --> Ę (\u+0118) -// Ä› (\u+011B) --> Äš (\u+011A) Ä (\u+011D) --> Äœ (\u+011C) -// ÄŸ (\u+011F) --> Äž (\u+011E) Ä¡ (\u+0121) --> Ä  (\u+0120) -// Ä£ (\u+0123) --> Ä¢ (\u+0122) Ä¥ (\u+0125) --> Ĥ (\u+0124) -// ħ (\u+0127) --> Ħ (\u+0126) Ä© (\u+0129) --> Ĩ (\u+0128) -// Ä« (\u+012B) --> Ī (\u+012A) Ä­ (\u+012D) --> Ĭ (\u+012C) -// į (\u+012F) --> Ä® (\u+012E) ı (\u+0131) --> I (\u+0049) -// ij (\u+0133) --> IJ (\u+0132) ĵ (\u+0135) --> Ä´ (\u+0134) -// Ä· (\u+0137) --> Ķ (\u+0136) ĺ (\u+013A) --> Ĺ (\u+0139) -// ļ (\u+013C) --> Ä» (\u+013B) ľ (\u+013E) --> Ľ (\u+013D) -// Å€ (\u+0140) --> Ä¿ (\u+013F) Å‚ (\u+0142) --> Å (\u+0141) -// Å„ (\u+0144) --> Ń (\u+0143) ņ (\u+0146) --> Å… (\u+0145) -// ň (\u+0148) --> Ň (\u+0147) Å‹ (\u+014B) --> ÅŠ (\u+014A) -// Å (\u+014D) --> ÅŒ (\u+014C) Å (\u+014F) --> ÅŽ (\u+014E) -// Å‘ (\u+0151) --> Å (\u+0150) Å“ (\u+0153) --> Å’ (\u+0152) -// Å• (\u+0155) --> Å” (\u+0154) Å— (\u+0157) --> Å– (\u+0156) -// Å™ (\u+0159) --> Ř (\u+0158) Å› (\u+015B) --> Åš (\u+015A) -// Å (\u+015D) --> Åœ (\u+015C) ÅŸ (\u+015F) --> Åž (\u+015E) -// Å¡ (\u+0161) --> Å  (\u+0160) Å£ (\u+0163) --> Å¢ (\u+0162) -// Å¥ (\u+0165) --> Ť (\u+0164) ŧ (\u+0167) --> Ŧ (\u+0166) -// Å© (\u+0169) --> Ũ (\u+0168) Å« (\u+016B) --> Ū (\u+016A) -// Å­ (\u+016D) --> Ŭ (\u+016C) ů (\u+016F) --> Å® (\u+016E) -// ű (\u+0171) --> Ű (\u+0170) ų (\u+0173) --> Ų (\u+0172) -// ŵ (\u+0175) --> Å´ (\u+0174) Å· (\u+0177) --> Ŷ (\u+0176) -// ź (\u+017A) --> Ź (\u+0179) ż (\u+017C) --> Å» (\u+017B) -// ž (\u+017E) --> Ž (\u+017D) -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.Trim/cpp/trim1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.Trim/cpp/trim1.cpp deleted file mode 100644 index befd0ecbf85..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.Trim/cpp/trim1.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// -using namespace System; - -void main() -{ - array^ charsToTrim = { L'*', L' ', L'\\' }; - String^ banner = "*** Much Ado About Nothing ***"; - String^ result = banner->Trim(charsToTrim); - Console::WriteLine("Trimmmed\n {0}\nto\n '{1}'", banner, result); -} -// The example displays the following output: -// Trimmmed -// *** Much Ado About Nothing *** -// to -// 'Much Ado About Nothing' -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.String.Trim/cpp/trim2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.String.Trim/cpp/trim2.cpp deleted file mode 100644 index bd9807b395d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.String.Trim/cpp/trim2.cpp +++ /dev/null @@ -1,30 +0,0 @@ -// -using namespace System; - -void main() -{ - Console::Write("Enter your first name: "); - String^ firstName = Console::ReadLine(); - - Console::Write("Enter your middle name or initial: "); - String^ middleName = Console::ReadLine(); - - Console::Write("Enter your last name: "); - String^ lastName = Console::ReadLine(); - - Console::WriteLine(); - Console::WriteLine("You entered '{0}', '{1}', and '{2}'.", - firstName, middleName, lastName); - - String^ name = ((firstName->Trim() + " " + middleName->Trim())->Trim() + " " + - lastName->Trim())->Trim(); - Console::WriteLine("The result is " + name + "."); -} -// The following is possible output from this example: -// Enter your first name: John -// Enter your middle name or initial: -// Enter your last name: Doe -// -// You entered ' John ', '', and ' Doe'. -// The result is John Doe. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.StringComparer/cpp/omni.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.StringComparer/cpp/omni.cpp deleted file mode 100644 index 19daa2e0cd4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.StringComparer/cpp/omni.cpp +++ /dev/null @@ -1,139 +0,0 @@ -// -// This example demonstrates members of the -// System::StringComparer class. - -using namespace System; -using namespace System::Collections; -using namespace System::Collections::Generic; -using namespace System::Globalization; -using namespace System::Threading; - -void Display(List^ stringList, String^ title) -{ - Char firstChar; - int codePoint; - Console::WriteLine(title); - for each (String^ s in stringList) - { - firstChar = s[0]; - codePoint = Convert::ToInt32(firstChar); - Console::WriteLine("0x{0:x}", codePoint); - } - Console::WriteLine(); -} - -int main() -{ - // Create a list of string. - List^ stringList = gcnew List(); - - // Get the tr-TR (Turkish-Turkey) culture. - CultureInfo^ turkishCulture = gcnew CultureInfo("tr-TR"); - - // Get the culture that is associated with the current thread. - CultureInfo^ currentCulture = Thread::CurrentThread->CurrentCulture; - - // Get the standard StringComparers. - StringComparer^ invariant = StringComparer::InvariantCulture; - StringComparer^ invariantIgnoreCase = - StringComparer::InvariantCultureIgnoreCase; - StringComparer^ current = StringComparer::CurrentCulture; - StringComparer^ currentIgnoreCase = - StringComparer::CurrentCultureIgnoreCase; - StringComparer^ ordinal = StringComparer::Ordinal; - StringComparer^ ordinalIgnoreCase = StringComparer::OrdinalIgnoreCase; - - // Create a StringComparer that uses the Turkish culture and ignores - // case. - StringComparer^ turkishIgnoreCase = - StringComparer::Create(turkishCulture, true); - - // Define three strings consisting of different versions of the - // letter I. LATIN CAPITAL LETTER I (U+0049) - String^ capitalLetterI = "I"; - - // LATIN SMALL LETTER I (U+0069) - String^ smallLetterI = "i"; - - // LATIN SMALL LETTER DOTLESS I (U+0131) - String^ smallLetterDotlessI = L"\u0131"; - - // Add the three strings to the list. - stringList->Add(capitalLetterI); - stringList->Add(smallLetterI); - stringList->Add(smallLetterDotlessI); - - // Display the original list order. - Display(stringList, "The original order of the list entries..."); - - // Sort the list using the invariant culture. - stringList->Sort(invariant); - Display(stringList, "Invariant culture..."); - stringList->Sort(invariantIgnoreCase); - Display(stringList, "Invariant culture, ignore case..."); - - // Sort the list using the current culture. - Console::WriteLine("The current culture is \"{0}\".", - currentCulture->Name); - stringList->Sort(current); - Display(stringList, "Current culture..."); - stringList->Sort(currentIgnoreCase); - Display(stringList, "Current culture, ignore case..."); - - // Sort the list using the ordinal value of the character code points. - stringList->Sort(ordinal); - Display(stringList, "Ordinal..."); - stringList->Sort(ordinalIgnoreCase); - Display(stringList, "Ordinal, ignore case..."); - - // Sort the list using the Turkish culture, which treats LATIN SMALL - // LETTER DOTLESS I differently than LATIN SMALL LETTER I. - stringList->Sort(turkishIgnoreCase); - Display(stringList, "Turkish culture, ignore case..."); -} -/* -This code example produces the following results: - -The original order of the list entries... -0x49 -0x69 -0x131 - -Invariant culture... -0x69 -0x49 -0x131 - -Invariant culture, ignore case... -0x49 -0x69 -0x131 - -The current culture is "en-US". -Current culture... -0x69 -0x49 -0x131 - -Current culture, ignore case... -0x49 -0x69 -0x131 - -Ordinal... -0x49 -0x69 -0x131 - -Ordinal, ignore case... -0x69 -0x49 -0x131 - -Turkish culture, ignore case... -0x131 -0x49 -0x69 - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Compare_Equals/CPP/comp_equal.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Compare_Equals/CPP/comp_equal.cpp deleted file mode 100644 index fba1b99c662..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Compare_Equals/CPP/comp_equal.cpp +++ /dev/null @@ -1,64 +0,0 @@ - -// -// Example of the TimeSpan::Compare( TimeSpan, TimeSpan ) and -// TimeSpan::Equals( TimeSpan, TimeSpan ) methods. -using namespace System; -const __wchar_t * protoFmt = L"{0,-38}{1}"; - -// Compare TimeSpan parameters, and display them with the results. -void CompareTimeSpans( TimeSpan Left, TimeSpan Right, String^ RightText ) -{ - String^ dataFmt = gcnew String( protoFmt ); - Console::WriteLine(); - Console::WriteLine( dataFmt, String::Concat( "Right: ", RightText ), Right ); - Console::WriteLine( dataFmt, "TimeSpan::Equals( Left, Right )", TimeSpan::Equals( Left, Right ) ); - Console::WriteLine( dataFmt, "TimeSpan::Compare( Left, Right )", TimeSpan::Compare( Left, Right ) ); -} - -int main() -{ - TimeSpan Left = TimeSpan(2,0,0); - Console::WriteLine( "This example of the TimeSpan::Equals( TimeSpan, TimeSpan " - ") and \nTimeSpan::Compare( TimeSpan, TimeSpan ) " - "methods generates the \nfollowing output by creating " - "several different TimeSpan \nobjects and comparing " - "them with a 2-hour TimeSpan.\n" ); - Console::WriteLine( gcnew String( protoFmt ), "Left: TimeSpan( 2, 0, 0 )", Left ); - - // Create objects to compare with a 2-hour TimeSpan. - CompareTimeSpans( Left, TimeSpan(0,120,0), "TimeSpan( 0, 120, 0 )" ); - CompareTimeSpans( Left, TimeSpan(2,0,1), "TimeSpan( 2, 0, 1 )" ); - CompareTimeSpans( Left, TimeSpan(2,0,-1), "TimeSpan( 2, 0, -1 )" ); - CompareTimeSpans( Left, TimeSpan(72000000000), "TimeSpan( 72000000000 )" ); - CompareTimeSpans( Left, TimeSpan::FromDays( 1.0 / 12. ), "TimeSpan::FromDays( 1 / 12 )" ); -} - -/* -This example of the TimeSpan::Equals( TimeSpan, TimeSpan ) and -TimeSpan::Compare( TimeSpan, TimeSpan ) methods generates the -following output by creating several different TimeSpan -objects and comparing them with a 2-hour TimeSpan. - -Left: TimeSpan( 2, 0, 0 ) 02:00:00 - -Right: TimeSpan( 0, 120, 0 ) 02:00:00 -TimeSpan::Equals( Left, Right ) True -TimeSpan::Compare( Left, Right ) 0 - -Right: TimeSpan( 2, 0, 1 ) 02:00:01 -TimeSpan::Equals( Left, Right ) False -TimeSpan::Compare( Left, Right ) -1 - -Right: TimeSpan( 2, 0, -1 ) 01:59:59 -TimeSpan::Equals( Left, Right ) False -TimeSpan::Compare( Left, Right ) 1 - -Right: TimeSpan( 72000000000 ) 02:00:00 -TimeSpan::Equals( Left, Right ) True -TimeSpan::Compare( Left, Right ) 0 - -Right: TimeSpan::FromDays( 1 / 12 ) 02:00:00 -TimeSpan::Equals( Left, Right ) True -TimeSpan::Compare( Left, Right ) 0 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Compare_Equals/CPP/cto_eq_obj.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Compare_Equals/CPP/cto_eq_obj.cpp deleted file mode 100644 index 3c27f181be1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Compare_Equals/CPP/cto_eq_obj.cpp +++ /dev/null @@ -1,78 +0,0 @@ - -// -// Example of the TimeSpan::CompareTo( Object* ) and -// TimeSpan::Equals( Object* ) methods. -using namespace System; - -// Compare the TimeSpan to the Object parameters, -// and display the Object parameters with the results. -void CompTimeSpanToObject( TimeSpan Left, Object^ Right, String^ RightText ) -{ - Console::WriteLine( "{0,-33}{1}", String::Concat( "Object: ", RightText ), Right ); - Console::WriteLine( "{0,-33}{1}", "Left.Equals( Object )", Left.Equals( Right ) ); - Console::Write( "{0,-33}", "Left.CompareTo( Object )" ); - - // Catch the exception if CompareTo( ) throws one. - try - { - Console::WriteLine( "{0}\n", Left.CompareTo( Right ) ); - } - catch ( Exception^ ex ) - { - Console::WriteLine( "Error: {0}\n", ex->Message ); - } - -} - -int main() -{ - TimeSpan Left = TimeSpan(0,5,0); - Console::WriteLine( "This example of the TimeSpan::Equals( Object* ) " - "and \nTimeSpan::CompareTo( Object* ) methods generates " - "the \nfollowing output by creating several different " - "TimeSpan \nobjects and comparing them with a " - "5-minute TimeSpan.\n" ); - Console::WriteLine( "{0,-33}{1}\n", "Left: TimeSpan( 0, 5, 0 )", Left ); - - // Create objects to compare with a 5-minute TimeSpan. - CompTimeSpanToObject( Left, TimeSpan(0,0,300), "TimeSpan( 0, 0, 300 )" ); - CompTimeSpanToObject( Left, TimeSpan(0,5,1), "TimeSpan( 0, 5, 1 )" ); - CompTimeSpanToObject( Left, TimeSpan(0,5,-1), "TimeSpan( 0, 5, -1 )" ); - CompTimeSpanToObject( Left, TimeSpan(3000000000), "TimeSpan( 3000000000 )" ); - CompTimeSpanToObject( Left, 3000000000L, "__int64 3000000000L" ); - CompTimeSpanToObject( Left, "00:05:00", "String \"00:05:00\"" ); -} - -/* -This example of the TimeSpan::Equals( Object* ) and -TimeSpan::CompareTo( Object* ) methods generates the -following output by creating several different TimeSpan -objects and comparing them with a 5-minute TimeSpan. - -Left: TimeSpan( 0, 5, 0 ) 00:05:00 - -Object: TimeSpan( 0, 0, 300 ) 00:05:00 -Left.Equals( Object ) True -Left.CompareTo( Object ) 0 - -Object: TimeSpan( 0, 5, 1 ) 00:05:01 -Left.Equals( Object ) False -Left.CompareTo( Object ) -1 - -Object: TimeSpan( 0, 5, -1 ) 00:04:59 -Left.Equals( Object ) False -Left.CompareTo( Object ) 1 - -Object: TimeSpan( 3000000000 ) 00:05:00 -Left.Equals( Object ) True -Left.CompareTo( Object ) 0 - -Object: __int64 3000000000L 3000000000 -Left.Equals( Object ) False -Left.CompareTo( Object ) Error: Object must be of type TimeSpan. - -Object: String "00:05:00" 00:05:00 -Left.Equals( Object ) False -Left.CompareTo( Object ) Error: Object must be of type TimeSpan. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Ctor/CPP/ctoriii.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Ctor/CPP/ctoriii.cpp deleted file mode 100644 index f60d07081bb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Ctor/CPP/ctoriii.cpp +++ /dev/null @@ -1,45 +0,0 @@ - -// -// Example of the TimeSpan( int, int, int ) constructor. -using namespace System; - -// Create a TimeSpan object and display its value. -static void CreateTimeSpan( int hours, int minutes, int seconds ) -{ - TimeSpan elapsedTime = TimeSpan(hours,minutes,seconds); - - // Format the constructor for display. - String^ ctor = String::Format( "TimeSpan( {0}, {1}, {2} )", hours, minutes, seconds ); - - // Display the constructor and its value. - Console::WriteLine( "{0,-37}{1,16}", ctor, elapsedTime.ToString() ); -} - -int main() -{ - Console::WriteLine( "This example of the TimeSpan( int, int, int ) " - "\nconstructor generates the following output.\n" ); - Console::WriteLine( "{0,-37}{1,16}", "Constructor", "Value" ); - Console::WriteLine( "{0,-37}{1,16}", "-----------", "-----" ); - CreateTimeSpan( 10, 20, 30 ); - CreateTimeSpan( -10, 20, 30 ); - CreateTimeSpan( 0, 0, 37230 ); - CreateTimeSpan( 1000, 2000, 3000 ); - CreateTimeSpan( 1000, -2000, -3000 ); - CreateTimeSpan( 999999, 999999, 999999 ); -} - -/* -This example of the TimeSpan( int, int, int ) -constructor generates the following output. - -Constructor Value ------------ ----- -TimeSpan( 10, 20, 30 ) 10:20:30 -TimeSpan( -10, 20, 30 ) -09:39:30 -TimeSpan( 0, 0, 37230 ) 10:20:30 -TimeSpan( 1000, 2000, 3000 ) 43.02:10:00 -TimeSpan( 1000, -2000, -3000 ) 40.05:50:00 -TimeSpan( 999999, 999999, 999999 ) 42372.15:25:39 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Ctor/CPP/ctoriiii.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Ctor/CPP/ctoriiii.cpp deleted file mode 100644 index 4a1c4233cf3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Ctor/CPP/ctoriiii.cpp +++ /dev/null @@ -1,42 +0,0 @@ - -// -using namespace System; - -// Create a TimeSpan object and display its value. -void CreateTimeSpan( int days, int hours, int minutes, int seconds ) -{ - TimeSpan elapsedTime = TimeSpan(days,hours,minutes,seconds); - - // Format the constructor for display. - array^boxedParams = gcnew array(4); - boxedParams[ 0 ] = days; - boxedParams[ 1 ] = hours; - boxedParams[ 2 ] = minutes; - boxedParams[ 3 ] = seconds; - String^ ctor = String::Format( "TimeSpan( {0}, {1}, {2}, {3} )", boxedParams ); - - // Display the constructor and its value. - Console::WriteLine( "{0,-44}{1,16}", ctor, elapsedTime.ToString() ); -} - -int main() -{ - Console::WriteLine( "{0,-44}{1,16}", "Constructor", "Value" ); - Console::WriteLine( "{0,-44}{1,16}", "-----------", "-----" ); - CreateTimeSpan( 10, 20, 30, 40 ); - CreateTimeSpan( -10, 20, 30, 40 ); - CreateTimeSpan( 0, 0, 0, 937840 ); - CreateTimeSpan( 1000, 2000, 3000, 4000 ); - CreateTimeSpan( 1000, -2000, -3000, -4000 ); - CreateTimeSpan( 999999, 999999, 999999, 999999 ); -} -// The example displays the following output: -// Constructor Value -// ----------- ----- -// TimeSpan( 10, 20, 30, 40 ) 10.20:30:40 -// TimeSpan( -10, 20, 30, 40 ) -9.03:29:20 -// TimeSpan( 0, 0, 0, 937840 ) 10.20:30:40 -// TimeSpan( 1000, 2000, 3000, 4000 ) 1085.11:06:40 -// TimeSpan( 1000, -2000, -3000, -4000 ) 914.12:53:20 -// TimeSpan( 999999, 999999, 999999, 999999 ) 1042371.15:25:39 -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Ctor/CPP/ctoriiiii.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Ctor/CPP/ctoriiiii.cpp deleted file mode 100644 index 2806b7c4188..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Ctor/CPP/ctoriiiii.cpp +++ /dev/null @@ -1,51 +0,0 @@ - -// -// Example of the TimeSpan( int, int, int, int, int ) constructor. -using namespace System; - -// Create a TimeSpan object and display its value. -void CreateTimeSpan( int days, int hours, int minutes, int seconds, int millisec ) -{ - TimeSpan elapsedTime = TimeSpan(days,hours,minutes,seconds,millisec); - - // Format the constructor for display. - array^boxedParams = gcnew array(5); - boxedParams[ 0 ] = days; - boxedParams[ 1 ] = hours; - boxedParams[ 2 ] = minutes; - boxedParams[ 3 ] = seconds; - boxedParams[ 4 ] = millisec; - String^ ctor = String::Format( "TimeSpan( {0}, {1}, {2}, {3}, {4} )", boxedParams ); - - // Display the constructor and its value. - Console::WriteLine( "{0,-48}{1,24}", ctor, elapsedTime.ToString() ); -} - -int main() -{ - Console::WriteLine( "This example of the TimeSpan( int, int, int, int, int ) " - "\nconstructor generates the following output.\n" ); - Console::WriteLine( "{0,-48}{1,16}", "Constructor", "Value" ); - Console::WriteLine( "{0,-48}{1,16}", "-----------", "-----" ); - CreateTimeSpan( 10, 20, 30, 40, 50 ); - CreateTimeSpan( -10, 20, 30, 40, 50 ); - CreateTimeSpan( 0, 0, 0, 0, 937840050 ); - CreateTimeSpan( 1111, 2222, 3333, 4444, 5555 ); - CreateTimeSpan( 1111, -2222, -3333, -4444, -5555 ); - CreateTimeSpan( 99999, 99999, 99999, 99999, 99999 ); -} - -/* -This example of the TimeSpan( int, int, int, int, int ) -constructor generates the following output. - -Constructor Value ------------ ----- -TimeSpan( 10, 20, 30, 40, 50 ) 10.20:30:40.0500000 -TimeSpan( -10, 20, 30, 40, 50 ) -9.03:29:19.9500000 -TimeSpan( 0, 0, 0, 0, 937840050 ) 10.20:30:40.0500000 -TimeSpan( 1111, 2222, 3333, 4444, 5555 ) 1205.22:47:09.5550000 -TimeSpan( 1111, -2222, -3333, -4444, -5555 ) 1016.01:12:50.4450000 -TimeSpan( 99999, 99999, 99999, 99999, 99999 ) 104236.05:27:18.9990000 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Ctor/CPP/ctorl.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Ctor/CPP/ctorl.cpp deleted file mode 100644 index d5dd9f79124..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Ctor/CPP/ctorl.cpp +++ /dev/null @@ -1,54 +0,0 @@ - -// -// Example of the TimeSpan( __int64 ) constructor. -using namespace System; - -// Create a TimeSpan object and display its value. -void CreateTimeSpan( __int64 ticks ) -{ - TimeSpan elapsedTime = TimeSpan(ticks); - - // Format the constructor for display. - String^ ctor = String::Format( "TimeSpan( {0} )", ticks ); - - // Pad the end of a TimeSpan string with spaces if - // it does not contain milliseconds. - String^ elapsedStr = elapsedTime.ToString(); - int pointIndex = elapsedStr->IndexOf( ':' ); - pointIndex = elapsedStr->IndexOf( '.', pointIndex ); - if ( pointIndex < 0 ) - elapsedStr = String::Concat( elapsedStr, " " ); - - - // Display the constructor and its value. - Console::WriteLine( "{0,-33}{1,24}", ctor, elapsedStr ); -} - -int main() -{ - Console::WriteLine( "This example of the TimeSpan( __int64 ) constructor " - "\ngenerates the following output.\n" ); - Console::WriteLine( "{0,-33}{1,16}", "Constructor", "Value" ); - Console::WriteLine( "{0,-33}{1,16}", "-----------", "-----" ); - CreateTimeSpan( 1 ); - CreateTimeSpan( 999999 ); - CreateTimeSpan( -1000000000000 ); - CreateTimeSpan( 18012202000000 ); - CreateTimeSpan( 999999999999999999 ); - CreateTimeSpan( 1000000000000000000 ); -} - -/* -This example of the TimeSpan( __int64 ) constructor -generates the following output. - -Constructor Value ------------ ----- -TimeSpan( 1 ) 00:00:00.0000001 -TimeSpan( 999999 ) 00:00:00.0999999 -TimeSpan( -1000000000000 ) -1.03:46:40 -TimeSpan( 18012202000000 ) 20.20:20:20.2000000 -TimeSpan( 999999999999999999 ) 1157407.09:46:39.9999999 -TimeSpan( 1000000000000000000 ) 1157407.09:46:40 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Dura_Nega_Unary/CPP/dura_nega_una.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Dura_Nega_Unary/CPP/dura_nega_una.cpp deleted file mode 100644 index 82a2aebbbc8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Dura_Nega_Unary/CPP/dura_nega_una.cpp +++ /dev/null @@ -1,48 +0,0 @@ - -// -// Example of the TimeSpan::Duration( ) and TimeSpan::Negate( ) methods, -// and the TimeSpan Unary Negation and Unary Plus operators. -using namespace System; -const __wchar_t * protoFmt = L"{0,22}{1,22}{2,22}"; -void ShowDurationNegate( TimeSpan interval ) -{ - - // Display the TimeSpan value and the results of the - // Duration and Negate methods. - Console::WriteLine( gcnew String( protoFmt ), interval, interval.Duration(), interval.Negate() ); -} - -int main() -{ - Console::WriteLine( "This example of TimeSpan::Duration( ), " - "TimeSpan::Negate( ), \nand the TimeSpan Unary " - "Negation and Unary Plus operators \n" - "generates the following output.\n" ); - Console::WriteLine( gcnew String( protoFmt ), "TimeSpan", "Duration( )", "Negate( )" ); - Console::WriteLine( gcnew String( protoFmt ), "--------", "-----------", "---------" ); - - // Create TimeSpan objects and apply the Unary Negation - // and Unary Plus operators to them. - ShowDurationNegate( TimeSpan(1) ); - ShowDurationNegate( TimeSpan( -1234567) ); - ShowDurationNegate( +TimeSpan(0,0,10,-20,-30) ); - ShowDurationNegate( +TimeSpan(0,-10,20,-30,40) ); - ShowDurationNegate( -TimeSpan(1,10,20,40,160) ); - ShowDurationNegate( -TimeSpan( -10,-20,-30,-40,-50) ); -} - -/* -This example of TimeSpan::Duration( ), TimeSpan::Negate( ), -and the TimeSpan Unary Negation and Unary Plus operators -generates the following output. - - TimeSpan Duration( ) Negate( ) - -------- ----------- --------- - 00:00:00.0000001 00:00:00.0000001 -00:00:00.0000001 - -00:00:00.1234567 00:00:00.1234567 00:00:00.1234567 - 00:09:39.9700000 00:09:39.9700000 -00:09:39.9700000 - -09:40:29.9600000 09:40:29.9600000 09:40:29.9600000 - -1.10:20:40.1600000 1.10:20:40.1600000 1.10:20:40.1600000 - 10.20:30:40.0500000 10.20:30:40.0500000 -10.20:30:40.0500000 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Fields/CPP/fields.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Fields/CPP/fields.cpp deleted file mode 100644 index c72d87bcf54..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Fields/CPP/fields.cpp +++ /dev/null @@ -1,58 +0,0 @@ - -// -// Example of the TimeSpan fields. -using namespace System; - -// Pad the end of a TimeSpan string with spaces if it does not -// contain milliseconds. -String^ Align( TimeSpan interval ) -{ - String^ intervalStr = interval.ToString(); - int pointIndex = intervalStr->IndexOf( ':' ); - pointIndex = intervalStr->IndexOf( '.', pointIndex ); - if ( pointIndex < 0 ) - intervalStr = String::Concat( intervalStr, " " ); - - return intervalStr; -} - -int main() -{ - String^ numberFmt = "{0,-22}{1,18:N0}"; - String^ timeFmt = "{0,-22}{1,26}"; - Console::WriteLine( "This example of the fields of the TimeSpan class" - "\ngenerates the following output.\n" ); - Console::WriteLine( numberFmt, "Field", "Value" ); - Console::WriteLine( numberFmt, "-----", "-----" ); - - // Display the maximum, minimum, and zero TimeSpan values. - Console::WriteLine( timeFmt, "Maximum TimeSpan", Align( TimeSpan::MaxValue ) ); - Console::WriteLine( timeFmt, "Minimum TimeSpan", Align( TimeSpan::MinValue ) ); - Console::WriteLine( timeFmt, "Zero TimeSpan", Align( TimeSpan::Zero ) ); - Console::WriteLine(); - - // Display the ticks-per-time-unit fields. - Console::WriteLine( numberFmt, "Ticks per day", TimeSpan::TicksPerDay ); - Console::WriteLine( numberFmt, "Ticks per hour", TimeSpan::TicksPerHour ); - Console::WriteLine( numberFmt, "Ticks per minute", TimeSpan::TicksPerMinute ); - Console::WriteLine( numberFmt, "Ticks per second", TimeSpan::TicksPerSecond ); - Console::WriteLine( numberFmt, "Ticks per millisecond", TimeSpan::TicksPerMillisecond ); -} - -/* -This example of the fields of the TimeSpan class -generates the following output. - -Field Value ------ ----- -Maximum TimeSpan 10675199.02:48:05.4775807 -Minimum TimeSpan -10675199.02:48:05.4775808 -Zero TimeSpan 00:00:00 - -Ticks per day 864,000,000,000 -Ticks per hour 36,000,000,000 -Ticks per minute 600,000,000 -Ticks per second 10,000,000 -Ticks per millisecond 10,000 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.From/CPP/fromdays.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.From/CPP/fromdays.cpp deleted file mode 100644 index 1ad4da8b17d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.From/CPP/fromdays.cpp +++ /dev/null @@ -1,58 +0,0 @@ - -// -// Example of the TimeSpan::FromDays( double ) method. -using namespace System; -void GenTimeSpanFromDays( double days ) -{ - - // Create a TimeSpan object and TimeSpan string from - // a number of days. - TimeSpan interval = TimeSpan::FromDays( days ); - String^ timeInterval = interval.ToString(); - - // Pad the end of the TimeSpan string with spaces if it - // does not contain milliseconds. - int pIndex = timeInterval->IndexOf( ':' ); - pIndex = timeInterval->IndexOf( '.', pIndex ); - if ( pIndex < 0 ) - timeInterval = String::Concat( timeInterval, " " ); - - Console::WriteLine( "{0,21}{1,26}", days, timeInterval ); -} - -int main() -{ - Console::WriteLine( "This example of TimeSpan::FromDays( double )\n" - "generates the following output.\n" ); - Console::WriteLine( "{0,21}{1,18}", "FromDays", "TimeSpan" ); - Console::WriteLine( "{0,21}{1,18}", "--------", "--------" ); - GenTimeSpanFromDays( 0.000000006 ); - GenTimeSpanFromDays( 0.000000017 ); - GenTimeSpanFromDays( 0.000123456 ); - GenTimeSpanFromDays( 1.234567898 ); - GenTimeSpanFromDays( 12345.678987654 ); - GenTimeSpanFromDays( 0.000011574 ); - GenTimeSpanFromDays( 0.000694444 ); - GenTimeSpanFromDays( 0.041666666 ); - GenTimeSpanFromDays( 1 ); - GenTimeSpanFromDays( 20.84745602 ); -} - -/* -This example of TimeSpan::FromDays( double ) -generates the following output. - - FromDays TimeSpan - -------- -------- - 6E-09 00:00:00.0010000 - 1.7E-08 00:00:00.0010000 - 0.000123456 00:00:10.6670000 - 1.234567898 1.05:37:46.6660000 - 12345.678987654 12345.16:17:44.5330000 - 1.1574E-05 00:00:01 - 0.000694444 00:01:00 - 0.041666666 01:00:00 - 1 1.00:00:00 - 20.84745602 20.20:20:20.2000000 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.From/CPP/fromhours.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.From/CPP/fromhours.cpp deleted file mode 100644 index 291263f4c76..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.From/CPP/fromhours.cpp +++ /dev/null @@ -1,58 +0,0 @@ - -// -// Example of the TimeSpan::FromHours( double ) method. -using namespace System; -void GenTimeSpanFromHours( double hours ) -{ - - // Create a TimeSpan object and TimeSpan string from - // a number of hours. - TimeSpan interval = TimeSpan::FromHours( hours ); - String^ timeInterval = interval.ToString(); - - // Pad the end of the TimeSpan string with spaces if it - // does not contain milliseconds. - int pIndex = timeInterval->IndexOf( ':' ); - pIndex = timeInterval->IndexOf( '.', pIndex ); - if ( pIndex < 0 ) - timeInterval = String::Concat( timeInterval, " " ); - - Console::WriteLine( "{0,21}{1,26}", hours, timeInterval ); -} - -int main() -{ - Console::WriteLine( "This example of TimeSpan::FromHours( double )\n" - "generates the following output.\n" ); - Console::WriteLine( "{0,21}{1,18}", "FromHours", "TimeSpan" ); - Console::WriteLine( "{0,21}{1,18}", "---------", "--------" ); - GenTimeSpanFromHours( 0.0000002 ); - GenTimeSpanFromHours( 0.0000003 ); - GenTimeSpanFromHours( 0.0012345 ); - GenTimeSpanFromHours( 12.3456789 ); - GenTimeSpanFromHours( 123456.7898765 ); - GenTimeSpanFromHours( 0.0002777 ); - GenTimeSpanFromHours( 0.0166666 ); - GenTimeSpanFromHours( 1 ); - GenTimeSpanFromHours( 24 ); - GenTimeSpanFromHours( 500.3389445 ); -} - -/* -This example of TimeSpan::FromHours( double ) -generates the following output. - - FromHours TimeSpan - --------- -------- - 2E-07 00:00:00.0010000 - 3E-07 00:00:00.0010000 - 0.0012345 00:00:04.4440000 - 12.3456789 12:20:44.4440000 - 123456.7898765 5144.00:47:23.5550000 - 0.0002777 00:00:01 - 0.0166666 00:01:00 - 1 01:00:00 - 24 1.00:00:00 - 500.3389445 20.20:20:20.2000000 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.From/CPP/frommillisec.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.From/CPP/frommillisec.cpp deleted file mode 100644 index abaa9a05413..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.From/CPP/frommillisec.cpp +++ /dev/null @@ -1,58 +0,0 @@ - -// -// Example of the TimeSpan::FromMilliseconds( double ) method. -using namespace System; -void GenTimeSpanFromMillisec( Double millisec ) -{ - - // Create a TimeSpan object and TimeSpan string from - // a number of milliseconds. - TimeSpan interval = TimeSpan::FromMilliseconds( millisec ); - String^ timeInterval = interval.ToString(); - - // Pad the end of the TimeSpan string with spaces if it - // does not contain milliseconds. - int pIndex = timeInterval->IndexOf( ':' ); - pIndex = timeInterval->IndexOf( '.', pIndex ); - if ( pIndex < 0 ) - timeInterval = String::Concat( timeInterval, " " ); - - Console::WriteLine( "{0,21}{1,26}", millisec, timeInterval ); -} - -int main() -{ - Console::WriteLine( "This example of TimeSpan::FromMilliseconds( double )\n" - "generates the following output.\n" ); - Console::WriteLine( "{0,21}{1,18}", "FromMilliseconds", "TimeSpan" ); - Console::WriteLine( "{0,21}{1,18}", "----------------", "--------" ); - GenTimeSpanFromMillisec( 1 ); - GenTimeSpanFromMillisec( 1.5 ); - GenTimeSpanFromMillisec( 12345.6 ); - GenTimeSpanFromMillisec( 123456789.8 ); - GenTimeSpanFromMillisec( 1234567898765.4 ); - GenTimeSpanFromMillisec( 1000 ); - GenTimeSpanFromMillisec( 60000 ); - GenTimeSpanFromMillisec( 3600000 ); - GenTimeSpanFromMillisec( 86400000 ); - GenTimeSpanFromMillisec( 1801220200 ); -} - -/* -This example of TimeSpan::FromMilliseconds( double ) -generates the following output. - - FromMilliseconds TimeSpan - ---------------- -------- - 1 00:00:00.0010000 - 1.5 00:00:00.0020000 - 12345.6 00:00:12.3460000 - 123456789.8 1.10:17:36.7900000 - 1234567898765.4 14288.23:31:38.7650000 - 1000 00:00:01 - 60000 00:01:00 - 3600000 01:00:00 - 86400000 1.00:00:00 - 1801220200 20.20:20:20.2000000 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.From/CPP/fromminutes.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.From/CPP/fromminutes.cpp deleted file mode 100644 index 79a767372f3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.From/CPP/fromminutes.cpp +++ /dev/null @@ -1,58 +0,0 @@ - -// -// Example of the TimeSpan::FromMinutes( double ) method. -using namespace System; -void GenTimeSpanFromMinutes( double minutes ) -{ - - // Create a TimeSpan object and TimeSpan string from - // a number of minutes. - TimeSpan interval = TimeSpan::FromMinutes( minutes ); - String^ timeInterval = interval.ToString(); - - // Pad the end of the TimeSpan string with spaces if it - // does not contain milliseconds. - int pIndex = timeInterval->IndexOf( ':' ); - pIndex = timeInterval->IndexOf( '.', pIndex ); - if ( pIndex < 0 ) - timeInterval = String::Concat( timeInterval, " " ); - - Console::WriteLine( "{0,21}{1,26}", minutes, timeInterval ); -} - -int main() -{ - Console::WriteLine( "This example of TimeSpan::FromMinutes( double )\n" - "generates the following output.\n" ); - Console::WriteLine( "{0,21}{1,18}", "FromMinutes", "TimeSpan" ); - Console::WriteLine( "{0,21}{1,18}", "-----------", "--------" ); - GenTimeSpanFromMinutes( 0.00001 ); - GenTimeSpanFromMinutes( 0.00002 ); - GenTimeSpanFromMinutes( 0.12345 ); - GenTimeSpanFromMinutes( 1234.56789 ); - GenTimeSpanFromMinutes( 12345678.98765 ); - GenTimeSpanFromMinutes( 0.01666 ); - GenTimeSpanFromMinutes( 1 ); - GenTimeSpanFromMinutes( 60 ); - GenTimeSpanFromMinutes( 1440 ); - GenTimeSpanFromMinutes( 30020.33667 ); -} - -/* -This example of TimeSpan::FromMinutes( double ) -generates the following output. - - FromMinutes TimeSpan - ----------- -------- - 1E-05 00:00:00.0010000 - 2E-05 00:00:00.0010000 - 0.12345 00:00:07.4070000 - 1234.56789 20:34:34.0730000 - 12345678.98765 8573.09:18:59.2590000 - 0.01666 00:00:01 - 1 00:01:00 - 60 01:00:00 - 1440 1.00:00:00 - 30020.33667 20.20:20:20.2000000 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.From/CPP/fromseconds.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.From/CPP/fromseconds.cpp deleted file mode 100644 index 7ff5d2de047..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.From/CPP/fromseconds.cpp +++ /dev/null @@ -1,58 +0,0 @@ - -// -// Example of the TimeSpan::FromSeconds( double ) method. -using namespace System; -void GenTimeSpanFromSeconds( double seconds ) -{ - - // Create a TimeSpan object and TimeSpan string from - // a number of seconds. - TimeSpan interval = TimeSpan::FromSeconds( seconds ); - String^ timeInterval = interval.ToString(); - - // Pad the end of the TimeSpan string with spaces if it - // does not contain milliseconds. - int pIndex = timeInterval->IndexOf( ':' ); - pIndex = timeInterval->IndexOf( '.', pIndex ); - if ( pIndex < 0 ) - timeInterval = String::Concat( timeInterval, " " ); - - Console::WriteLine( "{0,21}{1,26}", seconds, timeInterval ); -} - -int main() -{ - Console::WriteLine( "This example of TimeSpan::FromSeconds( double )\n" - "generates the following output.\n" ); - Console::WriteLine( "{0,21}{1,18}", "FromSeconds", "TimeSpan" ); - Console::WriteLine( "{0,21}{1,18}", "-----------", "--------" ); - GenTimeSpanFromSeconds( 0.001 ); - GenTimeSpanFromSeconds( 0.0015 ); - GenTimeSpanFromSeconds( 12.3456 ); - GenTimeSpanFromSeconds( 123456.7898 ); - GenTimeSpanFromSeconds( 1234567898.7654 ); - GenTimeSpanFromSeconds( 1 ); - GenTimeSpanFromSeconds( 60 ); - GenTimeSpanFromSeconds( 3600 ); - GenTimeSpanFromSeconds( 86400 ); - GenTimeSpanFromSeconds( 1801220.2 ); -} - -/* -This example of TimeSpan::FromSeconds( double ) -generates the following output. - - FromSeconds TimeSpan - ----------- -------- - 0.001 00:00:00.0010000 - 0.0015 00:00:00.0020000 - 12.3456 00:00:12.3460000 - 123456.7898 1.10:17:36.7900000 - 1234567898.7654 14288.23:31:38.7650000 - 1 00:00:01 - 60 00:01:00 - 3600 01:00:00 - 86400 1.00:00:00 - 1801220.2 20.20:20:20.2000000 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.From/CPP/fromticks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.From/CPP/fromticks.cpp deleted file mode 100644 index 489db154b67..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.From/CPP/fromticks.cpp +++ /dev/null @@ -1,58 +0,0 @@ - -// -// Example of the TimeSpan::FromTicks( __int64 ) method. -using namespace System; -void GenTimeSpanFromTicks( __int64 ticks ) -{ - - // Create a TimeSpan object and TimeSpan string from - // a number of ticks. - TimeSpan interval = TimeSpan::FromTicks( ticks ); - String^ timeInterval = interval.ToString(); - - // Pad the end of the TimeSpan string with spaces if it - // does not contain milliseconds. - int pIndex = timeInterval->IndexOf( ':' ); - pIndex = timeInterval->IndexOf( '.', pIndex ); - if ( pIndex < 0 ) - timeInterval = String::Concat( timeInterval, " " ); - - Console::WriteLine( "{0,21}{1,26}", ticks, timeInterval ); -} - -int main() -{ - Console::WriteLine( "This example of TimeSpan::FromTicks( __int64 )\n" - "generates the following output.\n" ); - Console::WriteLine( "{0,21}{1,18}", "FromTicks", "TimeSpan" ); - Console::WriteLine( "{0,21}{1,18}", "---------", "--------" ); - GenTimeSpanFromTicks( 1 ); - GenTimeSpanFromTicks( 12345 ); - GenTimeSpanFromTicks( 123456789 ); - GenTimeSpanFromTicks( 1234567898765 ); - GenTimeSpanFromTicks( 12345678987654321 ); - GenTimeSpanFromTicks( 10000000 ); - GenTimeSpanFromTicks( 600000000 ); - GenTimeSpanFromTicks( 36000000000 ); - GenTimeSpanFromTicks( 864000000000 ); - GenTimeSpanFromTicks( 18012202000000 ); -} - -/* -This example of TimeSpan::FromTicks( __int64 ) -generates the following output. - - FromTicks TimeSpan - --------- -------- - 1 00:00:00.0000001 - 12345 00:00:00.0012345 - 123456789 00:00:12.3456789 - 1234567898765 1.10:17:36.7898765 - 12345678987654321 14288.23:31:38.7654321 - 10000000 00:00:01 - 600000000 00:01:00 - 36000000000 01:00:00 - 864000000000 1.00:00:00 - 18012202000000 20.20:20:20.2000000 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.GetHashCode/CPP/hashcode.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.GetHashCode/CPP/hashcode.cpp deleted file mode 100644 index 9c57a8242fa..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.GetHashCode/CPP/hashcode.cpp +++ /dev/null @@ -1,73 +0,0 @@ - -// -// Example for the TimeSpan::GetHashCode( ) method. -using namespace System; -void DisplayHashCode( TimeSpan interval ) -{ - - // Create a hash code and a string representation of - // the TimeSpan parameter. - String^ timeInterval = interval.ToString(); - int hashCode = interval.GetHashCode(); - - // Pad the end of the TimeSpan string with spaces if it - // does not contain milliseconds. - int pIndex = timeInterval->IndexOf( ':' ); - pIndex = timeInterval->IndexOf( '.', pIndex ); - if ( pIndex < 0 ) - timeInterval = String::Concat( timeInterval, " " ); - - Console::WriteLine( "{0,22} 0x{1:X8}, {1}", timeInterval, hashCode ); -} - -int main() -{ - Console::WriteLine( "This example of TimeSpan::GetHashCode( ) generates " - "the following \noutput, which displays " - "the hash codes of representative TimeSpan \n" - "objects in hexadecimal and decimal formats.\n" ); - Console::WriteLine( "{0,22} {1,10}", "TimeSpan ", "Hash Code" ); - Console::WriteLine( "{0,22} {1,10}", "-------- ", "---------" ); - DisplayHashCode( TimeSpan(0) ); - DisplayHashCode( TimeSpan(1) ); - DisplayHashCode( TimeSpan(0,0,0,0,1) ); - DisplayHashCode( TimeSpan(0,0,1) ); - DisplayHashCode( TimeSpan(0,1,0) ); - DisplayHashCode( TimeSpan(1,0,0) ); - DisplayHashCode( TimeSpan(36000000001) ); - DisplayHashCode( TimeSpan(0,1,0,0,1) ); - DisplayHashCode( TimeSpan(1,0,1) ); - DisplayHashCode( TimeSpan(1,0,0,0) ); - DisplayHashCode( TimeSpan(864000000001) ); - DisplayHashCode( TimeSpan(1,0,0,0,1) ); - DisplayHashCode( TimeSpan(1,0,0,1) ); - DisplayHashCode( TimeSpan(100,0,0,0) ); - DisplayHashCode( TimeSpan(100,0,0,0,1) ); - DisplayHashCode( TimeSpan(100,0,0,1) ); -} - -/* -This example of TimeSpan::GetHashCode( ) generates the following -output, which displays the hash codes of representative TimeSpan -objects in hexadecimal and decimal formats. - - TimeSpan Hash Code - -------- --------- - 00:00:00 0x00000000, 0 - 00:00:00.0000001 0x00000001, 1 - 00:00:00.0010000 0x00002710, 10000 - 00:00:01 0x00989680, 10000000 - 00:01:00 0x23C34600, 600000000 - 01:00:00 0x61C46808, 1640261640 - 01:00:00.0000001 0x61C46809, 1640261641 - 01:00:00.0010000 0x61C48F18, 1640271640 - 01:00:01 0x625CFE88, 1650261640 - 1.00:00:00 0x2A69C0C9, 711573705 - 1.00:00:00.0000001 0x2A69C0C8, 711573704 - 1.00:00:00.0010000 0x2A69E7D9, 711583705 - 1.00:00:01 0x2B025649, 721573449 - 100.00:00:00 0x914F4E94, -1857073516 - 100.00:00:00.0010000 0x914F6984, -1857066620 - 100.00:00:01 0x91E7D814, -1847076844 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Properties/CPP/properties.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Properties/CPP/properties.cpp deleted file mode 100644 index 6e3817f134c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Properties/CPP/properties.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// -using namespace System; - -static void ShowTimeSpanProperties(TimeSpan interval) -{ - Console::WriteLine("{0,21}", interval ); - Console::WriteLine("{0,-12}{1,8} {2,-18}{3,21:N3}", - "Days", interval.Days, "TotalDays", - interval.TotalDays); - Console::WriteLine("{0,-12}{1,8} {2,-18}{3,21:N3}", - "Hours", interval.Hours, "TotalHours", - interval.TotalHours); - Console::WriteLine("{0,-12}{1,8} {2,-18}{3,21:N3}", - "Minutes", interval.Minutes, "TotalMinutes", - interval.TotalMinutes); - Console::WriteLine("{0,-12}{1,8} {2,-18}{3,21:N3}", - "Seconds", interval.Seconds, "TotalSeconds", - interval.TotalSeconds); - Console::WriteLine("{0,-12}{1,8} {2,-18}{3,21:N3}", - "Milliseconds", interval.Milliseconds, - "TotalMilliseconds", interval.TotalMilliseconds); - Console::WriteLine("{0,-12}{1,8} {2,-18}{3,21:N0}", - nullptr, nullptr, "Ticks", interval.Ticks); -} - -void main() -{ - // Create and display a TimeSpan value of 1 tick. - Console::Write("\n{0,-45}", "TimeSpan( 1 )"); - ShowTimeSpanProperties(TimeSpan(1)); - - // Create a TimeSpan value with a large number of ticks. - Console::Write("\n{0,-45}", "TimeSpan( 111222333444555 )"); - ShowTimeSpanProperties( TimeSpan(111222333444555)); - - // This TimeSpan has all fields specified. - Console::Write("\n{0,-45}", "TimeSpan( 10, 20, 30, 40, 50 )"); - ShowTimeSpanProperties( TimeSpan(10,20,30,40,50)); - - // This TimeSpan has all fields overflowing. - Console::Write("\n{0,-45}", "TimeSpan( 1111, 2222, 3333, 4444, 5555 )"); - ShowTimeSpanProperties( TimeSpan(1111,2222,3333,4444,5555)); - - // This TimeSpan is based on a number of days. - Console::Write("\n{0,-45}", "FromDays( 20.84745602 )"); - ShowTimeSpanProperties( TimeSpan::FromDays( 20.84745602 )); -} -// The example displays the following output if the current culture is en-US: -// TimeSpan( 1 ) 00:00:00.0000001 -// Days 0 TotalDays 0.000 -// Hours 0 TotalHours 0.000 -// Minutes 0 TotalMinutes 0.000 -// Seconds 0 TotalSeconds 0.000 -// Milliseconds 0 TotalMilliseconds 0.000 -// Ticks 1 -// -// TimeSpan( 111222333444555 ) 128.17:30:33.3444555 -// Days 128 TotalDays 128.730 -// Hours 17 TotalHours 3,089.509 -// Minutes 30 TotalMinutes 185,370.556 -// Seconds 33 TotalSeconds 11,122,233.344 -// Milliseconds 344 TotalMilliseconds 11,122,233,344.456 -// Ticks 111,222,333,444,555 -// -// TimeSpan( 10, 20, 30, 40, 50 ) 10.20:30:40.0500000 -// Days 10 TotalDays 10.855 -// Hours 20 TotalHours 260.511 -// Minutes 30 TotalMinutes 15,630.668 -// Seconds 40 TotalSeconds 937,840.050 -// Milliseconds 50 TotalMilliseconds 937,840,050.000 -// Ticks 9,378,400,500,000 -// -// TimeSpan( 1111, 2222, 3333, 4444, 5555 ) 1205.22:47:09.5550000 -// Days 1205 TotalDays 1,205.949 -// Hours 22 TotalHours 28,942.786 -// Minutes 47 TotalMinutes 1,736,567.159 -// Seconds 9 TotalSeconds 104,194,029.555 -// Milliseconds 555 TotalMilliseconds 104,194,029,555.000 -// Ticks 1,041,940,295,550,000 -// -// FromDays( 20.84745602 ) 20.20:20:20.2000000 -// Days 20 TotalDays 20.847 -// Hours 20 TotalHours 500.339 -// Minutes 20 TotalMinutes 30,020.337 -// Seconds 20 TotalSeconds 1,801,220.200 -// Milliseconds 200 TotalMilliseconds 1,801,220,200.000 -// Ticks 18,012,202,000,000 -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.RelationalOps/CPP/relationalops.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.RelationalOps/CPP/relationalops.cpp deleted file mode 100644 index 526f4e39d00..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.RelationalOps/CPP/relationalops.cpp +++ /dev/null @@ -1,76 +0,0 @@ - -// -// Example of the TimeSpan relational operators. -using namespace System; -const __wchar_t * protoFmt = L"{0,35} {1}"; - -// Compare TimeSpan parameters, and display them with the results. -void CompareTimeSpans( TimeSpan Left, TimeSpan Right, String^ RightText ) -{ - String^ dataFmt = gcnew String( protoFmt ); - Console::WriteLine(); - Console::WriteLine( dataFmt, String::Concat( "Right: ", RightText ), Right ); - Console::WriteLine( dataFmt, "Left == Right", Left == Right ); - Console::WriteLine( dataFmt, "Left > Right", Left > Right ); - Console::WriteLine( dataFmt, "Left >= Right", Left >= Right ); - Console::WriteLine( dataFmt, "Left != Right", Left != Right ); - Console::WriteLine( dataFmt, "Left < Right", Left < Right ); - Console::WriteLine( dataFmt, "Left <= Right", Left <= Right ); -} - -int main() -{ - TimeSpan Left = TimeSpan(2,0,0); - Console::WriteLine( "This example of the TimeSpan relational operators " - "generates \nthe following output. It creates several " - "different TimeSpan \nobjects and compares them with " - "a 2-hour TimeSpan.\n" ); - Console::WriteLine( gcnew String( protoFmt ), "Left: TimeSpan( 2, 0, 0 )", Left ); - - // Create objects to compare with a 2-hour TimeSpan. - CompareTimeSpans( Left, TimeSpan(0,120,0), "TimeSpan( 0, 120, 0 )" ); - CompareTimeSpans( Left, TimeSpan(2,0,1), "TimeSpan( 2, 0, 1 )" ); - CompareTimeSpans( Left, TimeSpan(2,0,-1), "TimeSpan( 2, 0, -1 )" ); - CompareTimeSpans( Left, TimeSpan::FromDays( 1.0 / 12. ), "TimeSpan::FromDays( 1 / 12 )" ); -} - -/* -This example of the TimeSpan relational operators generates -the following output. It creates several different TimeSpan -objects and compares them with a 2-hour TimeSpan. - - Left: TimeSpan( 2, 0, 0 ) 02:00:00 - - Right: TimeSpan( 0, 120, 0 ) 02:00:00 - Left == Right True - Left > Right False - Left >= Right True - Left != Right False - Left < Right False - Left <= Right True - - Right: TimeSpan( 2, 0, 1 ) 02:00:01 - Left == Right False - Left > Right False - Left >= Right False - Left != Right True - Left < Right True - Left <= Right True - - Right: TimeSpan( 2, 0, -1 ) 01:59:59 - Left == Right False - Left > Right True - Left >= Right True - Left != Right True - Left < Right False - Left <= Right False - -Right: TimeSpan::FromDays( 1 / 12 ) 02:00:00 - Left == Right True - Left > Right False - Left >= Right True - Left != Right False - Left < Right False - Left <= Right True -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.TimeZone.Class/CPP/tzclass.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.TimeZone.Class/CPP/tzclass.cpp deleted file mode 100644 index e1a104a5583..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.TimeZone.Class/CPP/tzclass.cpp +++ /dev/null @@ -1,61 +0,0 @@ - -// -// Example of selected TimeZone class elements. -using namespace System; -using namespace System::Globalization; -int main() -{ - String^ dataFmt = "{0,-30}{1}"; - String^ timeFmt = "{0,-30}{1:yyyy-MM-dd HH:mm}"; - Console::WriteLine( "This example of selected TimeZone class " - "elements generates the following \n" - "output, which varies depending on the " - "time zone in which it is run.\n" ); - - // Get the local time zone and the current local time and year. - TimeZone^ localZone = TimeZone::CurrentTimeZone; - DateTime currentDate = DateTime::Now; - int currentYear = currentDate.Year; - - // Display the names for standard time and daylight saving - // time for the local time zone. - Console::WriteLine( dataFmt, "Standard time name:", localZone->StandardName ); - Console::WriteLine( dataFmt, "Daylight saving time name:", localZone->DaylightName ); - - // Display the current date and time and show if they occur - // in daylight saving time. - Console::WriteLine( String::Concat( "\n", timeFmt ), "Current date and time:", currentDate ); - Console::WriteLine( dataFmt, "Daylight saving time?", localZone->IsDaylightSavingTime( currentDate ) ); - - // Get the current Coordinated Universal Time (UTC) and UTC - // offset. - DateTime currentUTC = localZone->ToUniversalTime( currentDate ); - TimeSpan currentOffset = localZone->GetUtcOffset( currentDate ); - Console::WriteLine( timeFmt, "Coordinated Universal Time:", currentUTC ); - Console::WriteLine( dataFmt, "UTC offset:", currentOffset ); - - // Get the DaylightTime object for the current year. - DaylightTime^ daylight = localZone->GetDaylightChanges( currentYear ); - - // Display the daylight saving time range for the current year. - Console::WriteLine( "\nDaylight saving time for year {0}:", currentYear ); - Console::WriteLine( "{0:yyyy-MM-dd HH:mm} to " - "{1:yyyy-MM-dd HH:mm}, delta: {2}", daylight->Start, daylight->End, daylight->Delta ); -} - -/* -This example of selected TimeZone class elements generates the following -output, which varies depending on the time zone in which it is run. - -Standard time name: Pacific Standard Time -Daylight saving time name: Pacific Daylight Time - -Current date and time: 2006-01-06 16:47 -Daylight saving time? False -Coordinated Universal Time: 2006-01-07 00:47 -UTC offset: -08:00:00 - -Daylight saving time for year 2006: -2006-04-02 02:00 to 2006-10-29 02:00, delta: 01:00:00 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Type.BindGenericParameters/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Type.BindGenericParameters/CPP/source.cpp deleted file mode 100644 index 3ac30b92e74..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Type.BindGenericParameters/CPP/source.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Collections::Generic; - -namespace Example -{ - public ref class Test - { - public: - static void CreateConstructedType(void) - { - Console::WriteLine("\r\n--- Create a constructed type" - " from the generic Dictionary`2 type."); - - // Create a type object representing - // the generic Dictionary`2 type. - Type^ genericType = Type::GetType( - "System.Collections.Generic.Dictionary`2"); - if (genericType != nullptr) - { - DisplayTypeInfo(genericType); - } - else - { - Console::WriteLine("The type is not found"); - return; - } - - // Create an array of types to substitute for the type - // parameters of Dictionary`2. - // The key is of type string, and the type to be - // contained in the Dictionary`2 is Test. - array^ typeArgs = {String::typeid, Test::typeid}; - Type^ constructedType = - genericType->MakeGenericType(typeArgs); - DisplayTypeInfo(constructedType); - - // Compare the type objects obtained above to type objects - // obtained using typeof() and GetGenericTypeDefinition(). - Console::WriteLine("\r\n--- Compare types obtained by" - " different methods:"); - - Type^ definedType = Dictionary::typeid; - Console::WriteLine("\tAre the constructed types " - "equal? {0}", definedType == constructedType); - Console::WriteLine("\tAre the generic types equal? {0}", - definedType->GetGenericTypeDefinition() == genericType); - } - - private: - static void DisplayTypeInfo(Type^ typeToDisplay) - { - Console::WriteLine("\r\n{0}", typeToDisplay); - Console::WriteLine("\tIs this a generic type definition? " - "{0}", typeToDisplay->IsGenericTypeDefinition); - Console::WriteLine("\tIs it a generic type? " - "{0}", typeToDisplay->IsGenericType); - - array^ typeArguments = - typeToDisplay->GetGenericArguments(); - Console::WriteLine("\tList type arguments ({0}):", - typeArguments->Length); - - for each (Type^ typeArgument in typeArguments) - { - Console::WriteLine("\t\t{0}", typeArgument); - } - } - }; -} - -int main(void) -{ - Example::Test::CreateConstructedType(); -} - -/* This example produces the following output: - ---- Create a constructed type from the generic Dictionary`2 type. - -System.Collections.Generic.Dictionary`2[KeyType,ValueType] - Is this a generic type definition? True - Is it a generic type? True - List type arguments (2): - K - V - -System.Collections.Generic.Dictionary`2[System.String, Test] - Is this a generic type definition? False - Is it a generic type? True - List type arguments (2): - System.String - Test - ---- Compare types obtained by different methods: - Are the constructed types equal? True - Are the generic types equal? True - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Type.GetGenericTypeDefinition/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Type.GetGenericTypeDefinition/CPP/source.cpp deleted file mode 100644 index 42acac613e9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Type.GetGenericTypeDefinition/CPP/source.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Collections::Generic; - -public ref class Test -{ -public: - static void Main() - { - Console::Write( L"\r\n--- Get the generic type that " ); - Console::WriteLine( L"defines a constructed type." ); - - // Create a Dictionary of Test objects, using strings for the - // keys. - Dictionary< String^,Test^ >^ d = gcnew Dictionary< String^,Test^ >; - - // Get a Type object representing the constructed type. - // - Type^ constructed = d->GetType(); - DisplayTypeInfo( constructed ); - Type^ myGeneric = constructed->GetGenericTypeDefinition(); - DisplayTypeInfo( myGeneric ); - } - -private: - static void DisplayTypeInfo( Type^ t ) - { - Console::WriteLine( L"\r\n{0}", t ); - Console::WriteLine( L"\tIs this a generic type definition? {0}", - t->IsGenericTypeDefinition ); - Console::WriteLine( L"\tIs it a generic type? {0}", - t->IsGenericType ); - array^typeArguments = t->GetGenericArguments(); - Console::WriteLine( L"\tList type arguments ({0}):", - typeArguments->Length ); - System::Collections::IEnumerator^ myEnum = - typeArguments->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Type^ tParam = safe_cast(myEnum->Current); - Console::WriteLine( L"\t\t{0}", tParam ); - } - } -}; - -int main() -{ - Test::Main(); -} - -/* This example produces the following output: - ---- Get the generic type that defines a constructed type. - -System.Collections.Generic.Dictionary`2[System.String,Test] - Is this a generic type definition? False - Is it a generic type? True - List type arguments (2): - System.String - Test - -System.Collections.Generic.Dictionary`2[TKey,TValue] - Is this a generic type definition? True - Is it a generic type? True - List type arguments (2): - TKey - TValue - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Type.HasUnboundGenericParameters/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Type.HasUnboundGenericParameters/CPP/source.cpp deleted file mode 100644 index bd05647c2bb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Type.HasUnboundGenericParameters/CPP/source.cpp +++ /dev/null @@ -1,108 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Collections::Generic; - -// Define a base class with two type parameters. -generic< class T,class U > -public ref class Base {}; - -// Define a derived class. The derived class inherits from a constructed -// class that meets the following criteria: -// (1) Its generic type definition is Base. -// (2) It specifies int for the first type parameter. -// (3) For the second type parameter, it uses the same type that is used -// for the type parameter of the derived class. -// Thus, the derived class is a generic type with one type parameter, but -// its base class is an open constructed type with one type argument and -// one type parameter. -generic -public ref class Derived : Base {}; - -public ref class Test -{ -public: - static void Main() - { - Console::WriteLine( - L"\r\n--- Display a generic type and the open constructed"); - Console::WriteLine(L" type from which it is derived."); - - // Create a Type object representing the generic type definition - // for the Derived type. Note the absence of type arguments. - // - Type^ derivedType = Derived::typeid; - DisplayGenericTypeInfo(derivedType); - - // Display its open constructed base type. - DisplayGenericTypeInfo(derivedType->BaseType); - } - - -private: - static void DisplayGenericTypeInfo(Type^ t) - { - Console::WriteLine(L"\r\n{0}", t); - Console::WriteLine(L"\tIs this a generic type definition? {0}", - t->IsGenericTypeDefinition); - Console::WriteLine(L"\tIs it a generic type? {0}", t->IsGenericType); - Console::WriteLine(L"\tDoes it have unassigned generic parameters? {0}", - t->ContainsGenericParameters); - if (t->IsGenericType) - { - - // If this is a generic type, display the type arguments. - // - array^typeArguments = t->GetGenericArguments(); - Console::WriteLine(L"\tList type arguments ({0}):", - typeArguments->Length); - System::Collections::IEnumerator^ myEnum = - typeArguments->GetEnumerator(); - while (myEnum->MoveNext()) - { - Type^ tParam = safe_cast(myEnum->Current); - - // IsGenericParameter is true only for generic type - // parameters. - // - if (tParam->IsGenericParameter) - { - Console::WriteLine( - L"\t\t{0} (unassigned - parameter position {1})", - tParam, tParam->GenericParameterPosition); - } - else - { - Console::WriteLine(L"\t\t{0}", tParam); - } - } - } - } -}; - -int main() -{ - Test::Main(); -} - -/* This example produces the following output: - ---- Display a generic type and the open constructed - type from which it is derived. - -Derived`1[V] - Is this a generic type definition? True - Is it a generic type? True - Does it have unassigned generic parameters? True - List type arguments (1): - V (unassigned - parameter position 0) - -Base`2[System.Int32,V] - Is this a generic type definition? False - Is it a generic type? True - Does it have unassigned generic parameters? True - List type arguments (2): - System.Int32 - V (unassigned - parameter position 0) - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsGenericParameter/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsGenericParameter/CPP/source.cpp deleted file mode 100644 index 7382ca1e398..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsGenericParameter/CPP/source.cpp +++ /dev/null @@ -1,101 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Collections::Generic; - -public ref class Test -{ -private: - static void DisplayGenericTypeInfo( Type^ t ) - { - Console::WriteLine( L"\r\n{0}", t ); - Console::WriteLine( L"\tIs this a generic type definition? {0}", - t->IsGenericTypeDefinition ); - Console::WriteLine( L"\tIs it a generic type? {0}", - t->IsGenericType ); - - // - if ( t->IsGenericType ) - { - - // If this is a generic type, display the type arguments. - // - array^typeArguments = t->GetGenericArguments(); - Console::WriteLine( L"\tList type arguments ({0}):", - typeArguments->Length ); - System::Collections::IEnumerator^ myEnum = - typeArguments->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Type^ tParam = safe_cast(myEnum->Current); - - // If this is a type parameter, display its - // position. - // - if ( tParam->IsGenericParameter ) - { - Console::WriteLine( - L"\t\t{0}\t(unassigned - parameter position {1})", - tParam, tParam->GenericParameterPosition ); - } - else - { - Console::WriteLine( L"\t\t{0}", tParam ); - } - } - } - // - } - - -public: - static void Main() - { - Console::Write( L"\r\n--- Display information about a " ); - Console::WriteLine( L"constructed type, its" ); - Console::WriteLine( L" generic type definition, and an ordinary type." ); - - // Create a Dictionary of Test objects, using strings for the - // keys. - Dictionary< String^,Test^ >^ d = gcnew Dictionary< String^,Test^ >; - - // Display information for the constructed type and its generic - // type definition. - DisplayGenericTypeInfo( d->GetType() ); - DisplayGenericTypeInfo( d->GetType()->GetGenericTypeDefinition() ); - - // Display information for an ordinary type. - DisplayGenericTypeInfo( String::typeid ); - } - -}; - -int main() -{ - Test::Main(); -} - -/* This example produces the following output: - ---- Display information about a constructed type, its - generic type definition, and an ordinary type. - -System.Collections.Generic.Dictionary[System.String,Test] - Is this a generic type definition? False - Is it a generic type? True - List type arguments (2): - System.String - Test - -System.Collections.Generic.Dictionary[TKey,TValue] - Is this a generic type definition? True - Is it a generic type? True - List type arguments (2): - TKey (unassigned - parameter position 0) - TValue (unassigned - parameter position 1) - -System.String - Is this a generic type definition? False - Is it a generic type? False - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsGenericType/cpp/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsGenericType/cpp/remarks.cpp deleted file mode 100644 index ae4ef65dd24..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsGenericType/cpp/remarks.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -using namespace System; -using namespace System::Reflection; - -// -generic public ref class Base {}; - -generic public ref class G {}; - -generic public ref class Derived : Base -{ -public: - G^>^ F; - - ref class Nested {}; -}; -// - - -void main() {} - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsGenericType/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsGenericType/cpp/source.cpp deleted file mode 100644 index 39b29ec5a65..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsGenericType/cpp/source.cpp +++ /dev/null @@ -1,110 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -generic public ref class Base {}; - -generic public ref class G {}; - -generic public ref class Derived : Base -{ -public: - G^>^ F; - - ref class Nested {}; -}; - -void DisplayGenericType(Type^ t, String^ caption) -{ - Console::WriteLine("\n{0}", caption); - Console::WriteLine(" Type: {0}", t); - - Console::WriteLine("\t IsGenericType: {0}", - t->IsGenericType); - Console::WriteLine("\t IsGenericTypeDefinition: {0}", - t->IsGenericTypeDefinition); - Console::WriteLine("\tContainsGenericParameters: {0}", - t->ContainsGenericParameters); - Console::WriteLine("\t IsGenericParameter: {0}", - t->IsGenericParameter); -} - -void main() -{ - // Get the generic type definition for Derived, and the base - // type for Derived. - // - Type^ tDerived = Derived::typeid; - Type^ tDerivedBase = tDerived->BaseType; - - // Declare an array of Derived, and get its type. - // - array^>^ d = gcnew array^>(0); - Type^ tDerivedArray = d->GetType(); - - // Get a generic type parameter, the type of a field, and a - // type that is nested in Derived. Notice that in order to - // get the nested type it is necessary to either (1) specify - // the generic type definition Derived::typeid, as shown here, - // or (2) specify a type parameter for Derived. - // - Type^ tT = Base::typeid->GetGenericArguments()[0]; - Type^ tF = tDerived->GetField("F")->FieldType; - Type^ tNested = Derived::Nested::typeid; - - DisplayGenericType(tDerived, "generic Derived"); - DisplayGenericType(tDerivedBase, "Base type of generic Derived"); - DisplayGenericType(tDerivedArray, "Array of Derived"); - DisplayGenericType(tT, "Type parameter T from generic Base"); - DisplayGenericType(tF, "Field type, G^>^"); - DisplayGenericType(tNested, "Nested type in generic Derived"); -} - -/* This code example produces the following output: - -generic Derived - Type: Derived`1[V] - IsGenericType: True - IsGenericTypeDefinition: True - ContainsGenericParameters: True - IsGenericParameter: False - -Base type of generic Derived - Type: Base`2[System.String,V] - IsGenericType: True - IsGenericTypeDefinition: False - ContainsGenericParameters: True - IsGenericParameter: False - -Array of Derived - Type: Derived`1[System.Int32][] - IsGenericType: False - IsGenericTypeDefinition: False - ContainsGenericParameters: False - IsGenericParameter: False - -Type parameter T from generic Base - Type: T - IsGenericType: False - IsGenericTypeDefinition: False - ContainsGenericParameters: True - IsGenericParameter: True - -Field type, G^>^ - Type: G`1[Derived`1[V]] - IsGenericType: True - IsGenericTypeDefinition: False - ContainsGenericParameters: True - IsGenericParameter: False - -Nested type in generic Derived - Type: Derived`1+Nested[V] - IsGenericType: True - IsGenericTypeDefinition: True - ContainsGenericParameters: True - IsGenericParameter: False - */ -// - - - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsGenericTypeDefinition/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsGenericTypeDefinition/CPP/source.cpp deleted file mode 100644 index 7382ca1e398..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsGenericTypeDefinition/CPP/source.cpp +++ /dev/null @@ -1,101 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; -using namespace System::Collections::Generic; - -public ref class Test -{ -private: - static void DisplayGenericTypeInfo( Type^ t ) - { - Console::WriteLine( L"\r\n{0}", t ); - Console::WriteLine( L"\tIs this a generic type definition? {0}", - t->IsGenericTypeDefinition ); - Console::WriteLine( L"\tIs it a generic type? {0}", - t->IsGenericType ); - - // - if ( t->IsGenericType ) - { - - // If this is a generic type, display the type arguments. - // - array^typeArguments = t->GetGenericArguments(); - Console::WriteLine( L"\tList type arguments ({0}):", - typeArguments->Length ); - System::Collections::IEnumerator^ myEnum = - typeArguments->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Type^ tParam = safe_cast(myEnum->Current); - - // If this is a type parameter, display its - // position. - // - if ( tParam->IsGenericParameter ) - { - Console::WriteLine( - L"\t\t{0}\t(unassigned - parameter position {1})", - tParam, tParam->GenericParameterPosition ); - } - else - { - Console::WriteLine( L"\t\t{0}", tParam ); - } - } - } - // - } - - -public: - static void Main() - { - Console::Write( L"\r\n--- Display information about a " ); - Console::WriteLine( L"constructed type, its" ); - Console::WriteLine( L" generic type definition, and an ordinary type." ); - - // Create a Dictionary of Test objects, using strings for the - // keys. - Dictionary< String^,Test^ >^ d = gcnew Dictionary< String^,Test^ >; - - // Display information for the constructed type and its generic - // type definition. - DisplayGenericTypeInfo( d->GetType() ); - DisplayGenericTypeInfo( d->GetType()->GetGenericTypeDefinition() ); - - // Display information for an ordinary type. - DisplayGenericTypeInfo( String::typeid ); - } - -}; - -int main() -{ - Test::Main(); -} - -/* This example produces the following output: - ---- Display information about a constructed type, its - generic type definition, and an ordinary type. - -System.Collections.Generic.Dictionary[System.String,Test] - Is this a generic type definition? False - Is it a generic type? True - List type arguments (2): - System.String - Test - -System.Collections.Generic.Dictionary[TKey,TValue] - Is this a generic type definition? True - Is it a generic type? True - List type arguments (2): - TKey (unassigned - parameter position 0) - TValue (unassigned - parameter position 1) - -System.String - Is this a generic type definition? False - Is it a generic type? False - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsVisible/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsVisible/CPP/source.cpp deleted file mode 100644 index 8332eed2ff0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsVisible/CPP/source.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// -using namespace System; - -private ref class InternalOnly -{ -public: - ref class Nested {}; -}; - -public ref class Example -{ -public: - ref class Nested {}; -}; - - -// Entry point of example -int main() -{ - Type^ classType = InternalOnly::Nested::typeid; - Console::WriteLine( - "Is the {0} class visible outside the assembly? {1}", - classType->FullName, classType->IsVisible); - - classType = Example::Nested::typeid; - Console::WriteLine( - "Is the {0} class visible outside the assembly? {1}", - classType->FullName, classType->IsVisible); -} - -/* This example produces the following output: - -Is the InternalOnly+Nested class visible outside the assembly? False -Is the Example+Nested class visible outside the assembly? True -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Type.MakeXxxType/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Type.MakeXxxType/CPP/source.cpp deleted file mode 100644 index c9c917bc746..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Type.MakeXxxType/CPP/source.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// -using namespace System; -using namespace System::Reflection; - -public ref class Example -{ -public: - static void Main() - { - // Create a Type object that represents a one-dimensional - // array of Example objects. - Type^ t = Example::typeid->MakeArrayType(); - Console::WriteLine( L"\r\nArray of Example: {0}", t ); - - // Create a Type object that represents a two-dimensional - // array of Example objects. - t = Example::typeid->MakeArrayType( 2 ); - Console::WriteLine( L"\r\nTwo-dimensional array of Example: {0}", t ); - - // Demonstrate an exception when an invalid array rank is - // specified. - try - { - t = Example::typeid->MakeArrayType( -1 ); - } - catch ( Exception^ ex ) - { - Console::WriteLine( L"\r\n{0}", ex ); - } - - // Create a Type object that represents a ByRef parameter - // of type Example. - t = Example::typeid->MakeByRefType(); - Console::WriteLine( L"\r\nByRef Example: {0}", t ); - - // Get a Type object representing the Example class, a - // MethodInfo representing the "Test" method, a ParameterInfo - // representing the parameter of type Example, and finally - // a Type object representing the type of this ByRef parameter. - // Compare this Type object with the Type object created using - // MakeByRefType. - Type^ t2 = Example::typeid; - MethodInfo^ mi = t2->GetMethod( L"Test" ); - ParameterInfo^ pi = mi->GetParameters()[ 0 ]; - Type^ pt = pi->ParameterType; - Console::WriteLine( L"Are the ByRef types equal? {0}", (t == pt) ); - - // Create a Type object that represents a pointer to an - // Example object. - t = Example::typeid->MakePointerType(); - Console::WriteLine( L"\r\nPointer to Example: {0}", t ); - } - - // A sample method with a ByRef parameter. - // - void Test( interior_ptr /*e*/ ) - { - } -}; - -int main() -{ - Example::Main(); -} - -/* This example produces output similar to the following: - -Array of Example: Example[] - -Two-dimensional array of Example: Example[,] - -System.IndexOutOfRangeException: Index was outside the bounds of the array. - at System.RuntimeType.MakeArrayType(Int32 rank) in c:\vbl\ndp\clr\src\BCL\System\RtType.cs:line 2999 - at Example.Main() - -ByRef Example: Example& -Are the ByRef types equal? True - -Pointer to Example: Example* - - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Type/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Type/cpp/source.cpp deleted file mode 100644 index b9aab72110f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Type/cpp/source.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// The following code example demonstrates that Type objects are returned -// by the typeid operator, and shows how Type objects are used in reflection -// to explore information about types and to invoke members of types. -// -#using - -using namespace System; -using namespace System::Reflection; - -void main() -{ - // Get a Type object representing the System.String type. - Type^ t = String::typeid; - - MethodInfo^ substr = t->GetMethod("Substring", - gcnew array { int::typeid, int::typeid }); - - Object^ result = - substr->Invoke("Hello, World!", gcnew array { 7, 5 }); - Console::WriteLine("{0} returned \"{1}\".", substr, result); -} - -/* This code example produces the following output: - -System.String Substring(Int32, Int32) returned "World". - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.TypeCode/CPP/iconvertible.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.TypeCode/CPP/iconvertible.cpp deleted file mode 100644 index 84ebc81e817..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.TypeCode/CPP/iconvertible.cpp +++ /dev/null @@ -1,153 +0,0 @@ - -// -using namespace System; - -/// Class that implements IConvertible* -public ref class Complex: public IConvertible -{ -private: - double x; - double y; - -public: - Complex( double x, double y ) - { - this->x = x; - this->y = y; - } - - virtual TypeCode GetTypeCode() - { - return TypeCode::Object; - } - - virtual bool ToBoolean( IFormatProvider^ provider ) - { - if ( (x != 0.0) || (y != 0.0) ) - return true; - else - return false; - } - - double GetDoubleValue() - { - return Math::Sqrt( x * x + y * y ); - } - - virtual Byte ToByte( IFormatProvider^ provider ) - { - return Convert::ToByte( GetDoubleValue() ); - } - - virtual Char ToChar( IFormatProvider^ provider ) - { - return Convert::ToChar( GetDoubleValue() ); - } - - virtual DateTime ToDateTime( IFormatProvider^ provider ) - { - return Convert::ToDateTime( GetDoubleValue() ); - } - - virtual Decimal ToDecimal( IFormatProvider^ provider ) - { - return Convert::ToDecimal( GetDoubleValue() ); - } - - virtual double ToDouble( IFormatProvider^ provider ) - { - return GetDoubleValue(); - } - - virtual short ToInt16( IFormatProvider^ provider ) - { - return Convert::ToInt16( GetDoubleValue() ); - } - - virtual int ToInt32( IFormatProvider^ provider ) - { - return Convert::ToInt32( GetDoubleValue() ); - } - - virtual Int64 ToInt64( IFormatProvider^ provider ) - { - return Convert::ToInt64( GetDoubleValue() ); - } - - virtual signed char ToSByte( IFormatProvider^ provider ) - { - return Convert::ToSByte( GetDoubleValue() ); - } - - virtual float ToSingle( IFormatProvider^ provider ) - { - return Convert::ToSingle( GetDoubleValue() ); - } - - virtual String^ ToString( IFormatProvider^ provider ) - { - return x.ToString() + ", " + y.ToString(); - } - - virtual Object^ ToType( Type^ conversionType, IFormatProvider^ provider ) - { - return Convert::ChangeType( GetDoubleValue(), conversionType ); - } - - virtual UInt16 ToUInt16( IFormatProvider^ provider ) - { - return Convert::ToUInt16( GetDoubleValue() ); - } - - virtual UInt32 ToUInt32( IFormatProvider^ provider ) - { - return Convert::ToUInt32( GetDoubleValue() ); - } - - virtual UInt64 ToUInt64( IFormatProvider^ provider ) - { - return Convert::ToUInt64( GetDoubleValue() ); - } -}; - - -// -void WriteObjectInfo( Object^ testObject ) -{ - TypeCode typeCode = Type::GetTypeCode( testObject->GetType() ); - switch ( typeCode ) - { - case TypeCode::Boolean: - Console::WriteLine( "Boolean: {0}", testObject ); - break; - - case TypeCode::Double: - Console::WriteLine( "Double: {0}", testObject ); - break; - - default: - Console::WriteLine( "{0}: {1}", typeCode, testObject ); - break; - } -} -// - -void main() -{ - Complex^ testComplex = gcnew Complex( 4,7 ); - WriteObjectInfo( testComplex ); - WriteObjectInfo( Convert::ToBoolean( testComplex ) ); - WriteObjectInfo( Convert::ToDecimal( testComplex ) ); - WriteObjectInfo( Convert::ToString( testComplex ) ); -} - -/* -This code example produces the following results: - -Object: ConsoleApplication2.Complex -Boolean: True -Decimal: 8.06225774829855 -String: ( 4 , 7 ) - -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.action.delegate/cpp/delegate.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.action.delegate/cpp/delegate.cpp deleted file mode 100644 index e10fb59e8bb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.action.delegate/cpp/delegate.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// Lambda.cpp : main project file. - -//#include "stdafx.h" - -// -using namespace System; -using namespace System::Windows::Forms; - -public delegate void ShowValue(); - - -public ref class Name -{ -private: - String^ instanceName; - -public: - Name(String^ name) - { - instanceName = name; - } - - void DisplayToConsole() - { - Console::WriteLine(this->instanceName); - } - - void DisplayToWindow() - { - MessageBox::Show(this->instanceName); - } -}; - -int main() -{ - Name^ testName = gcnew Name(L"Koani"); - ShowValue^ showMethod; - showMethod = gcnew ShowValue(testName, &Name::DisplayToWindow); - showMethod(); - return 0; -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.action.delegate/cpp/delegate.vcxproj b/snippets/cpp/VS_Snippets_CLR_System/system.action.delegate/cpp/delegate.vcxproj deleted file mode 100644 index 747bfeb6b76..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.action.delegate/cpp/delegate.vcxproj +++ /dev/null @@ -1,89 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {9EC80F18-EB27-492B-9D70-40C7B2052756} - v4.0 - ManagedCProj - TestWinForms - - - - Application - true - Pure - Unicode - - - Application - false - Pure - Unicode - - - - - - - - - - - - - true - - - false - - - - Level3 - Disabled - WIN32;_DEBUG;%(PreprocessorDefinitions) - - - true - - - Windows - main - - - - - Level3 - WIN32;NDEBUG;%(PreprocessorDefinitions) - Use - - - true - - - Windows - main - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.activation.createinstance~~1/cpp/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.activation.createinstance~~1/cpp/remarks.cpp deleted file mode 100644 index 8dd9c5712f8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.activation.createinstance~~1/cpp/remarks.cpp +++ /dev/null @@ -1,18 +0,0 @@ - -using namespace System; - -public ref class Dummy -{ -// - public: - generic where T:gcnew() - static T Bar() - { - return gcnew T(); - } -// -}; - - -void main() {} - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.array.foreach/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.array.foreach/cpp/source.cpp deleted file mode 100644 index f739b8705dd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.array.foreach/cpp/source.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// The following example demonstrates using the ForEach method. - -// -using namespace System; - -public ref class SamplesArray -{ -public: - static void Main() - { - // create a three element array of integers - array^ intArray = gcnew array {2, 3, 4}; - - // set a delegate for the ShowSquares method - Action^ action = gcnew Action(ShowSquares); - - Array::ForEach(intArray, action); - } - -private: - static void ShowSquares(int val) - { - Console::WriteLine("{0:d} squared = {1:d}", val, val*val); - } -}; - -int main() -{ - SamplesArray::Main(); -} - -/* -This code produces the following output: - -2 squared = 4 -3 squared = 9 -4 squared = 16 -*/ - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.array.getlength/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.array.getlength/cpp/source.cpp deleted file mode 100644 index fb3486b04d4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.array.getlength/cpp/source.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// The following example demonstrates using the Array.GetLength method. - -// -using namespace System; - -public ref class SamplesArray -{ -public: - static void Main() - { - // make a single dimension array - Array^ MyArray1 = Array::CreateInstance(int::typeid, 5); - - // make a 3 dimensional array - Array^ MyArray2 = Array::CreateInstance(int::typeid, 5, 3, 2); - - // make an array container - Array^ BossArray = Array::CreateInstance(Array::typeid, 2); - BossArray->SetValue(MyArray1, 0); - BossArray->SetValue(MyArray2, 1); - - int i = 0, j, rank; - for each (Array^ anArray in BossArray) - { - rank = anArray->Rank; - if (rank > 1) - { - Console::WriteLine("Lengths of {0:d} dimension array[{1:d}]", rank, i); - // show the lengths of each dimension - for (j = 0; j < rank; j++) - { - Console::WriteLine(" Length of dimension({0:d}) = {1:d}", j, anArray->GetLength(j)); - } - } - else - { - Console::WriteLine("Lengths of single dimension array[{0:d}]", i); - } - // show the total length of the entire array or all dimensions - Console::WriteLine(" Total length of the array = {0:d}", anArray->Length); - Console::WriteLine(); - i++; - } - } -}; - -int main() -{ - SamplesArray::Main(); -} - -/* -This code produces the following output: - -Lengths of single dimension array[0] - Total length of the array = 5 - -Lengths of 3 dimension array[1] - Length of dimension(0) = 5 - Length of dimension(1) = 3 - Length of dimension(2) = 2 - Total length of the array = 30 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.array.getupperbound/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.array.getupperbound/cpp/source.cpp deleted file mode 100644 index 62891bfe86f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.array.getupperbound/cpp/source.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// -using namespace System; - -void main() -{ - // Create a one-dimensional integer array. - array^ integers = { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 }; - // Get the upper and lower bound of the array. - int upper = integers->GetUpperBound(0); - int lower = integers->GetLowerBound(0); - Console::WriteLine("Elements from index {0} to {1}:", lower, upper); - // Iterate the array. - for (int ctr = lower; ctr <= upper; ctr++) - Console::Write("{0}{1}{2}", ctr == lower ? " " : "", - integers[ctr], - ctr < upper ? ", " : Environment::NewLine); - - Console::WriteLine(); - - // Create a two-dimensional integer array. - array^ integers2d = { {2, 4}, {3, 9}, {4, 16}, {5, 25}, - {6, 36}, {7, 49}, {8, 64}, {9, 81} }; - // Get the number of dimensions. - int rank = integers2d->Rank; - Console::WriteLine("Number of dimensions: {0}", rank); - for (int ctr = 0; ctr < rank; ctr++) - Console::WriteLine(" Dimension {0}: from {1} to {2}", - ctr, integers2d->GetLowerBound(ctr), - integers2d->GetUpperBound(ctr)); - - // Iterate the 2-dimensional array and display its values. - Console::WriteLine(" Values of array elements:"); - for (int outer = integers2d->GetLowerBound(0); outer <= integers2d->GetUpperBound(0); - outer++) - for (int inner = integers2d->GetLowerBound(1); inner <= integers2d->GetUpperBound(1); - inner++) - Console::WriteLine(" {3}{0}, {1}{4} = {2}", outer, inner, - integers2d->GetValue(outer, inner), "{", "}"); -} -// The example displays the following output: -// Elements from index 0 to 9: -// 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 -// -// Number of dimensions: 2 -// Dimension 0: from 0 to 7 -// Dimension 1: from 0 to 1 -// Values of array elements: -// {0, 0} = 2 -// {0, 1} = 4 -// {1, 0} = 3 -// {1, 1} = 9 -// {2, 0} = 4 -// {2, 1} = 16 -// {3, 0} = 5 -// {3, 1} = 25 -// {4, 0} = 6 -// {4, 1} = 36 -// {5, 0} = 7 -// {5, 1} = 49 -// {6, 0} = 8 -// {6, 1} = 64 -// {7, 0} = 9 -// {7, 1} = 81 -// - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.byte.equals/cpp/eq.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.byte.equals/cpp/eq.cpp deleted file mode 100644 index 7d01f577679..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.byte.equals/cpp/eq.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// Byte.Equals.cpp : main project file. - -// -using namespace System; - -void main() -{ - Byte byteVal1 = 0x7f; - Byte byteVal2 = 127; - Object^ objectVal3 = byteVal2; - - Console::WriteLine("byteVal1 = {0}, byteVal2 = {1}, objectVal3 = {2}\n", - byteVal1, byteVal2, objectVal3); - Console::WriteLine("byteVal1 equals byteVal2?: {0}", byteVal1.Equals(byteVal2)); - Console::WriteLine("byteVal1 equals objectVal3?: {0}", byteVal1.Equals(objectVal3)); -} -/* -This example displays the following output: - byteVal1 = 127, byteVal2 = 127, objectVal3 = 127 - - byteVal1 equals byteVal2?: True - byteVal1 equals objectVal3?: True -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.console.setout/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.console.setout/cpp/source.cpp deleted file mode 100644 index 65a52f0b6cc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.console.setout/cpp/source.cpp +++ /dev/null @@ -1,29 +0,0 @@ - -using namespace System; -using namespace System::IO; - -void main() -{ - try - { -// - Console::WriteLine("Hello World"); - FileStream^ fs = gcnew FileStream("Test.txt", FileMode::Create); - // First, save the standard output. - TextWriter^ tmp = Console::Out; - StreamWriter^ sw = gcnew StreamWriter(fs); - Console::SetOut(sw); - Console::WriteLine("Hello file"); - Console::SetOut(tmp); - Console::WriteLine("Hello World"); - sw->Close(); -// - } - catch (Exception^ ex) - { - Console::WriteLine(ex->Message); - Console::WriteLine(ex->StackTrace); - } -} - - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.console.windowleft/cpp/windowleft1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.console.windowleft/cpp/windowleft1.cpp deleted file mode 100644 index 829d3eb8423..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.console.windowleft/cpp/windowleft1.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Console.WindowLeft.cpp : main project file. - -// -using namespace System; - -void ShowConsoleStatistics() -{ - Console::WriteLine("Console statistics:"); - Console::WriteLine(" Buffer: {0} x {1}", Console::BufferHeight, Console::BufferWidth); - Console::WriteLine(" Window: {0} x {1}", Console::WindowHeight, Console::WindowWidth); - Console::WriteLine(" Window starts at {0}.", Console::WindowLeft); - Console::WriteLine("Press <- or -> to move window, Ctrl+C to exit."); -} - -int main() -{ - ConsoleKeyInfo key; - bool moved = false; - - Console::BufferWidth = 120; - Console::Clear(); - - ShowConsoleStatistics(); - - do { - key = Console::ReadKey(true); - if (key.Key == ConsoleKey::LeftArrow) - { - int pos = Console::WindowLeft - 1; - if (pos >= 0 && pos + Console::WindowWidth <= Console::BufferWidth) - { - Console::WindowLeft = pos; - moved = true; - } - } - else if (key.Key == ConsoleKey::RightArrow) - { - int pos = Console::WindowLeft + 1; - if (pos + Console::WindowWidth <= Console::BufferWidth) - { - Console::WindowLeft = pos; - moved = true; - } - } - if (moved) - { - ShowConsoleStatistics(); - moved = false; - } - Console::WriteLine(); - } while (true); -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.console.write/cpp/con_write.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.console.write/cpp/con_write.cpp deleted file mode 100644 index 2e488e00359..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.console.write/cpp/con_write.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// -using namespace System; - -//void main(array ^args) -void main() -{ - DateTime dateRecorded(2009, 6, 15); - DateTime startTime(1, 1, 1, 0, 30, 0); - TimeSpan interval(12, 0, 0); - - Double temperature1 = 52.8; - Double temperature2 = 63.5; - - Console::Write("Date: {0:d}:\n Temperature at {1:t}: {2}\n Temperature at {3:t}: {4}\n", - dateRecorded, startTime, temperature1, - startTime.Add(interval), temperature2); - Console::ReadLine(); -} -// The example displays the following output: -// Date: 6/15/2009: -// Temperature at 12:30 AM: 52.8 -// Temperature at 12:30 PM: 63.5 -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.convert.changetype/cpp/changetype00.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.convert.changetype/cpp/changetype00.cpp deleted file mode 100644 index 33eb3685a6c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.convert.changetype/cpp/changetype00.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// Convert.ChangeType00.cpp : main project file. - -// -using namespace System; -using namespace System::Globalization; - -ref class InterceptProvider : IFormatProvider -{ -public: - virtual Object^ GetFormat(Type^ formatType) - { - CultureInfo^ culture; - if (formatType == NumberFormatInfo::typeid) { - Console::WriteLine(" Returning a fr-FR numeric format provider."); - - culture = gcnew CultureInfo("fr-FR"); - return culture->NumberFormat; - } - else if (formatType == DateTimeFormatInfo::typeid) { - Console::WriteLine(" Returning an en-US date/time format provider."); - culture = gcnew CultureInfo("en-US"); - return culture->DateTimeFormat; - } - else { - Console::WriteLine(" Requesting a format provider of {0}.", formatType->Name); - return nullptr; - } - } -}; - -void main() -{ - array^ values = gcnew array { 103.5, gcnew DateTime(2010, 12, 26, 14, 34, 0) }; - IFormatProvider^ provider = gcnew InterceptProvider(); - - // Convert value to each of the types represented in TypeCode enum. - for each (Object^ value in values) - { - // Iterate types in TypeCode enum. - for each (TypeCode enumType in (array^) Enum::GetValues(TypeCode::typeid)) - { - if (enumType == TypeCode::DBNull || enumType == TypeCode::Empty) continue; - - try { - Console::WriteLine("{0} ({1}) --> {2} ({3}).", - value, value->GetType()->Name, - Convert::ChangeType(value, enumType, provider), - enumType.ToString()); - } - catch (InvalidCastException^ e) { - Console::WriteLine("Cannot convert a {0} to a {1}", - value->GetType()->Name, enumType.ToString()); - } - catch (OverflowException^ e) { - Console::WriteLine("Overflow: {0} is out of the range of a {1}", - value, enumType.ToString()); - } - } - Console::WriteLine(); - } -} -// The example displays the following output: -// 103.5 (Double) --> 103.5 (Object). -// 103.5 (Double) --> True (Boolean). -// Cannot convert a Double to a Char -// 103.5 (Double) --> 104 (SByte). -// 103.5 (Double) --> 104 (Byte). -// 103.5 (Double) --> 104 (Int16). -// 103.5 (Double) --> 104 (UInt16). -// 103.5 (Double) --> 104 (Int32). -// 103.5 (Double) --> 104 (UInt32). -// 103.5 (Double) --> 104 (Int64). -// 103.5 (Double) --> 104 (UInt64). -// 103.5 (Double) --> 103.5 (Single). -// 103.5 (Double) --> 103.5 (Double). -// 103.5 (Double) --> 103.5 (Decimal). -// Cannot convert a Double to a DateTime -// Returning a fr-FR numeric format provider. -// 103.5 (Double) --> 103,5 (String). -// -// 12/26/2010 2:34:00 PM (DateTime) --> 12/26/2010 2:34:00 PM (Object). -// Cannot convert a DateTime to a Boolean -// Cannot convert a DateTime to a Char -// Cannot convert a DateTime to a SByte -// Cannot convert a DateTime to a Byte -// Cannot convert a DateTime to a Int16 -// Cannot convert a DateTime to a UInt16 -// Cannot convert a DateTime to a Int32 -// Cannot convert a DateTime to a UInt32 -// Cannot convert a DateTime to a Int64 -// Cannot convert a DateTime to a UInt64 -// Cannot convert a DateTime to a Single -// Cannot convert a DateTime to a Double -// Cannot convert a DateTime to a Decimal -// 12/26/2010 2:34:00 PM (DateTime) --> 12/26/2010 2:34:00 PM (DateTime). -// Returning an en-US date/time format provider. -// 12/26/2010 2:34:00 PM (DateTime) --> 12/26/2010 2:34:00 PM (String). -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.convert.changetype/cpp/changetype03.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.convert.changetype/cpp/changetype03.cpp deleted file mode 100644 index 36b41bcee35..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.convert.changetype/cpp/changetype03.cpp +++ /dev/null @@ -1,239 +0,0 @@ -// Convert.ChangeType03.cpp : main project file. - -// -using namespace System; -using namespace System::Globalization; - -public ref class Temperature : IConvertible -{ -private: - Decimal m_Temp; - -public: - Temperature(Decimal temperature) - { - m_Temp = temperature; - } - - property Decimal Celsius { - Decimal get() { return m_Temp; } - } - - property Decimal Kelvin { - Decimal get() { return m_Temp + (Decimal) 273.15; } - } - - property Decimal Fahrenheit { - Decimal get() { return Math::Round((Decimal) (m_Temp * 9 / 5 + 32), 2); } - } - - virtual String^ ToString() - override { - return m_Temp.ToString("N2") + "°C"; - } - - // IConvertible implementations. - virtual TypeCode GetTypeCode() - { - return TypeCode::Object; - } - - virtual bool ToBoolean(IFormatProvider^ provider) - { - if (m_Temp == 0) - return false; - else - return true; - } - - virtual Byte ToByte(IFormatProvider^ provider) - { - if (m_Temp < Byte::MinValue || m_Temp > Byte::MaxValue) - throw gcnew OverflowException(String::Format("{0} is out of range of the Byte type.", - m_Temp)); - else - return Decimal::ToByte(m_Temp); - } - - virtual Char ToChar(IFormatProvider^ provider) - { - throw gcnew InvalidCastException("Temperature to Char conversion is not supported."); - } - - virtual DateTime ToDateTime(IFormatProvider^ provider) - { - throw gcnew InvalidCastException("Temperature to DateTime conversion is not supported."); - } - - virtual Decimal ToDecimal(IFormatProvider^ provider) - { - return m_Temp; - } - - virtual Double ToDouble(IFormatProvider^ provider) - { - return Decimal::ToDouble(m_Temp); - } - - virtual Int16 ToInt16(IFormatProvider^ provider) - { - if (m_Temp < Int16::MinValue || m_Temp > Int16::MaxValue) - throw gcnew OverflowException(String::Format("{0} is out of range of the Int16 type.", - m_Temp)); - else - return Decimal::ToInt16(m_Temp); - } - - virtual Int32 ToInt32(IFormatProvider^ provider) - { - if (m_Temp < Int32::MinValue || m_Temp > Int32::MaxValue) - throw gcnew OverflowException(String::Format("{0} is out of range of the Int32 type.", - m_Temp)); - else - return Decimal::ToInt32(m_Temp); - } - - virtual Int64 ToInt64(IFormatProvider^ provider) - { - if (m_Temp < Int64::MinValue || m_Temp > Int64::MaxValue) - throw gcnew OverflowException(String::Format("{0} is out of range of the Int64 type.", - m_Temp)); - else - return Decimal::ToInt64(m_Temp); - } - - virtual SByte ToSByte(IFormatProvider^ provider) - { - if (m_Temp < SByte::MinValue || m_Temp > SByte::MaxValue) - throw gcnew OverflowException(String::Format("{0} is out of range of the SByte type.", - m_Temp)); - else - return Decimal::ToSByte(m_Temp); - } - - virtual Single ToSingle(IFormatProvider^ provider) - { - return Decimal::ToSingle(m_Temp); - } - - virtual String^ ToString(IFormatProvider^ provider) - { - return m_Temp.ToString("N2", provider) + "°C"; - } - - virtual Object^ ToType(Type^ conversionType, IFormatProvider^ provider) - { - switch (Type::GetTypeCode(conversionType)) - { - case TypeCode::Boolean: - return ToBoolean(nullptr); - case TypeCode::Byte: - return ToByte(nullptr); - case TypeCode::Char: - return ToChar(nullptr); - case TypeCode::DateTime: - return ToDateTime(nullptr); - case TypeCode::Decimal: - return ToDecimal(nullptr); - case TypeCode::Double: - return ToDouble(nullptr); - case TypeCode::Int16: - return ToInt16(nullptr); - case TypeCode::Int32: - return ToInt32(nullptr); - case TypeCode::Int64: - return ToInt64(nullptr); - case TypeCode::Object: - if (Temperature::typeid->Equals(conversionType)) - return this; - else - throw gcnew InvalidCastException(String::Format("Conversion to a {0} is not supported.", - conversionType->Name)); - case TypeCode::SByte: - return ToSByte(nullptr); - case TypeCode::Single: - return ToSingle(nullptr); - case TypeCode::String: - return ToString(provider); - case TypeCode::UInt16: - return ToUInt16(nullptr); - case TypeCode::UInt32: - return ToUInt32(nullptr); - case TypeCode::UInt64: - return ToUInt64(nullptr); - default: - throw gcnew InvalidCastException(String::Format("Conversion to {0} is not supported.", conversionType->Name)); - } - } - - virtual UInt16 ToUInt16(IFormatProvider^ provider) - { - if (m_Temp < UInt16::MinValue || m_Temp > UInt16::MaxValue) - throw gcnew OverflowException(String::Format("{0} is out of range of the UInt16 type.", - m_Temp)); - else - return Decimal::ToUInt16(m_Temp); - } - - virtual UInt32 ToUInt32(IFormatProvider^ provider) - { - if (m_Temp < UInt32::MinValue || m_Temp > UInt32::MaxValue) - throw gcnew OverflowException(String::Format("{0} is out of range of the UInt32 type.", - m_Temp)); - else - return Decimal::ToUInt32(m_Temp); - } - - virtual UInt64 ToUInt64(IFormatProvider^ provider) - { - if (m_Temp < UInt64::MinValue || m_Temp > UInt64::MaxValue) - throw gcnew OverflowException(String::Format("{0} is out of range of the UInt64 type.", - m_Temp)); - else - return Decimal::ToUInt64(m_Temp); - } -}; -// - -// -void main() -{ - Temperature^ cool = gcnew Temperature(5); - array^ targetTypes = gcnew array { SByte::typeid, Int16::typeid, Int32::typeid, - Int64::typeid, Byte::typeid, UInt16::typeid, - UInt32::typeid, UInt64::typeid, Decimal::typeid, - Single::typeid, Double::typeid, String::typeid }; - CultureInfo^ provider = gcnew CultureInfo("fr-FR"); - - for each (Type^ targetType in targetTypes) - { - try { - Object^ value = Convert::ChangeType(cool, targetType, provider); - Console::WriteLine("Converted {0} {1} to {2} {3}.", - cool->GetType()->Name, cool->ToString(), - targetType->Name, value); - } - catch (InvalidCastException^) { - Console::WriteLine("Unsupported {0} --> {1} conversion.", - cool->GetType()->Name, targetType->Name); - } - catch (OverflowException^) { - Console::WriteLine("{0} is out of range of the {1} type.", - cool, targetType->Name); - } - } -} -// The example dosplays the following output: -// Converted Temperature 5.00°C to SByte 5. -// Converted Temperature 5.00°C to Int16 5. -// Converted Temperature 5.00°C to Int32 5. -// Converted Temperature 5.00°C to Int64 5. -// Converted Temperature 5.00°C to Byte 5. -// Converted Temperature 5.00°C to UInt16 5. -// Converted Temperature 5.00°C to UInt32 5. -// Converted Temperature 5.00°C to UInt64 5. -// Converted Temperature 5.00°C to Decimal 5. -// Converted Temperature 5.00°C to Single 5. -// Converted Temperature 5.00°C to Double 5. -// Converted Temperature 5.00°C to String 5,00°C. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.convert.changetype/cpp/changetype_01.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.convert.changetype/cpp/changetype_01.cpp deleted file mode 100644 index 162b7f8fc5b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.convert.changetype/cpp/changetype_01.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// ChangeType01.cpp : main project file. - -// -using namespace System; - -void main() -{ - Double d = -2.345; - int i = (int) Convert::ChangeType(d, TypeCode::Int32); - - Console::WriteLine("The Double {0} when converted to an Int32 is {1}", d, i); - - String^ s = "12/12/2009"; - DateTime dt = (DateTime)Convert::ChangeType(s, DateTime::typeid); - - Console::WriteLine("The String {0} when converted to a Date is {1}", s, dt); -} -// The example displays the following output: -// The Double -2.345 when converted to an Int32 is -2 -// The String 12/12/2009 when converted to a Date is 12/12/2009 12:00:00 AM -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.convert.tobyte/cpp/tobyte1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.convert.tobyte/cpp/tobyte1.cpp deleted file mode 100644 index c114fe2f378..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.convert.tobyte/cpp/tobyte1.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// Convert.ToByte.cpp : main project file. - -// -using namespace System; - -void main() -{ - bool falseFlag = false; - bool trueFlag = true; - - Console::WriteLine("{0} converts to {1}.", falseFlag, - Convert::ToByte(falseFlag)); - Console::WriteLine("{0} converts to {1}.", trueFlag, - Convert::ToByte(trueFlag)); -} -// The example displays the following output: -// False converts to 0. -// True converts to 1. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.datetime.addminutes/cpp/addminutes1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.datetime.addminutes/cpp/addminutes1.cpp deleted file mode 100644 index d4d8b439ff3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.datetime.addminutes/cpp/addminutes1.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// -using namespace System; - -void main() -{ - DateTime dateValue(2013, 9, 15, 12, 0, 0); - - array^ minutes = { .01667, .08333, .16667, .25, .33333, - .5, .66667, 1, 2, 15, 30, 17, 45, - 60, 180, 60 * 24 }; - - for each (Double minute in minutes) - Console::WriteLine("{0} + {1} minute(s) = {2}", dateValue, minute, - dateValue.AddMinutes(minute)); -} -// The example displays the following output on a system whose current culture is en-US: -// 9/15/2013 12:00:00 PM + 0.01667 minute(s) = 9/15/2013 12:00:01 PM -// 9/15/2013 12:00:00 PM + 0.08333 minute(s) = 9/15/2013 12:00:05 PM -// 9/15/2013 12:00:00 PM + 0.16667 minute(s) = 9/15/2013 12:00:10 PM -// 9/15/2013 12:00:00 PM + 0.25 minute(s) = 9/15/2013 12:00:15 PM -// 9/15/2013 12:00:00 PM + 0.33333 minute(s) = 9/15/2013 12:00:20 PM -// 9/15/2013 12:00:00 PM + 0.5 minute(s) = 9/15/2013 12:00:30 PM -// 9/15/2013 12:00:00 PM + 0.66667 minute(s) = 9/15/2013 12:00:40 PM -// 9/15/2013 12:00:00 PM + 1 minute(s) = 9/15/2013 12:01:00 PM -// 9/15/2013 12:00:00 PM + 2 minute(s) = 9/15/2013 12:02:00 PM -// 9/15/2013 12:00:00 PM + 15 minute(s) = 9/15/2013 12:15:00 PM -// 9/15/2013 12:00:00 PM + 30 minute(s) = 9/15/2013 12:30:00 PM -// 9/15/2013 12:00:00 PM + 17 minute(s) = 9/15/2013 12:17:00 PM -// 9/15/2013 12:00:00 PM + 45 minute(s) = 9/15/2013 12:45:00 PM -// 9/15/2013 12:00:00 PM + 60 minute(s) = 9/15/2013 1:00:00 PM -// 9/15/2013 12:00:00 PM + 180 minute(s) = 9/15/2013 3:00:00 PM -// 9/15/2013 12:00:00 PM + 1440 minute(s) = 9/16/2013 12:00:00 PM -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.datetime.now/cpp/now1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.datetime.now/cpp/now1.cpp deleted file mode 100644 index 6392ec34c1a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.datetime.now/cpp/now1.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// -using namespace System; -using namespace System::Globalization; - -void main() -{ - DateTime localDate = DateTime::Now; - array^ cultureNames = { "en-US", "en-GB", "fr-FR", - "de-DE", "ru-RU" }; - - for each (String^ cultureName in cultureNames) { - CultureInfo^ culture = gcnew CultureInfo(cultureName); - Console::WriteLine("{0}: {1}", cultureName, - localDate.ToString(culture)); - } -} -// The example displays the following output: -// en-US: 6/19/2015 10:03:06 AM -// en-GB: 19/06/2015 10:03:06 -// fr-FR: 19/06/2015 10:03:06 -// de-DE: 19.06.2015 10:03:06 -// ru-RU: 19.06.2015 10:03:06 -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.datetime.now/cpp/now2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.datetime.now/cpp/now2.cpp deleted file mode 100644 index 3026aeda282..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.datetime.now/cpp/now2.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// -using namespace System; -using namespace System::Globalization; - -void main() -{ - DateTime localDate = DateTime::Now; - DateTime utcDate = DateTime::UtcNow; - array^ cultureNames = { "en-US", "en-GB", "fr-FR", - "de-DE", "ru-RU" } ; - - for each (String^ cultureName in cultureNames) { - CultureInfo^ culture = gcnew CultureInfo(cultureName); - Console::WriteLine("{0}:", culture->NativeName); - Console::WriteLine(" Local date and time: {0}, {1:G}", - localDate.ToString(culture), localDate.Kind); - Console::WriteLine(" UTC date and time: {0}, {1:G}\n", - utcDate.ToString(culture), utcDate.Kind); - } -} -// The example displays the following output: -// English (United States): -// Local date and time: 6/19/2015 10:35:50 AM, Local -// UTC date and time: 6/19/2015 5:35:50 PM, Utc -// -// English (United Kingdom): -// Local date and time: 19/06/2015 10:35:50, Local -// UTC date and time: 19/06/2015 17:35:50, Utc -// -// français (France): -// Local date and time: 19/06/2015 10:35:50, Local -// UTC date and time: 19/06/2015 17:35:50, Utc -// -// Deutsch (Deutschland): -// Local date and time: 19.06.2015 10:35:50, Local -// UTC date and time: 19.06.2015 17:35:50, Utc -// -// руÑÑкий (РоÑÑиÑ): -// Local date and time: 19.06.2015 10:35:50, Local -// UTC date and time: 19.06.2015 17:35:50, Utc -// - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.decimal.operators.explicit/cpp/tosbyte.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.decimal.operators.explicit/cpp/tosbyte.cpp deleted file mode 100644 index e2e407522b7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.decimal.operators.explicit/cpp/tosbyte.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// -using namespace System; - -void main() -{ - // Define an array of decimal values. - array^ values = { Decimal::Parse("78"), - Decimal(78000,0,0,false,3), - Decimal::Parse("78.999"), - Decimal::Parse("255.999"), - Decimal::Parse("256"), - Decimal::Parse("127.999"), - Decimal::Parse("128"), - Decimal::Parse("-0.999"), - Decimal::Parse("-1"), - Decimal::Parse("-128.999"), - Decimal::Parse("-129") }; - for each (Decimal value in values) { - try { - SByte byteValue = (SByte) value; - Console::WriteLine("{0} ({1}) --> {2} ({3})", value, - value.GetType()->Name, byteValue, - byteValue.GetType()->Name); - } - catch (OverflowException^ e) { - Console::WriteLine("OverflowException: Cannot convert {0}", - value); - } - } -} -// The example displays the following output: -// 78 (Decimal) --> 78 (SByte) -// 78.000 (Decimal) --> 78 (SByte) -// 78.999 (Decimal) --> 78 (SByte) -// OverflowException: Cannot convert 255.999 -// OverflowException: Cannot convert 256 -// 127.999 (Decimal) --> 127 (SByte) -// OverflowException: Cannot convert 128 -// -0.999 (Decimal) --> 0 (SByte) -// -1 (Decimal) --> -1 (SByte) -// -128.999 (Decimal) --> -128 (SByte) -// OverflowException: Cannot convert -129 -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.decimal.operators.explicit/cpp/tosingle1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.decimal.operators.explicit/cpp/tosingle1.cpp deleted file mode 100644 index ddfc63d3603..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.decimal.operators.explicit/cpp/tosingle1.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// -using namespace System; - -void main() -{ - // Define an array of Decimal values. - array^ values = { Decimal::Parse("0.0000000000000000000000000001"), - Decimal::Parse("0.0000000000123456789123456789"), - Decimal::Parse("123"), - Decimal(123000000, 0, 0, false, 6), - Decimal::Parse("123456789.123456789"), - Decimal::Parse("123456789123456789123456789"), - Decimal::MinValue, Decimal::MaxValue }; - // Convert each value to a double. - for each (Decimal value in values) { - float dblValue = (float) value; - Console::WriteLine("{0} ({1}) --> {2} ({3})", value, - value.GetType()->Name, dblValue, - dblValue.GetType()->Name); - } -} -// The example displays the following output: -// 0.0000000000000000000000000001 (Decimal) --> 1E-28 (Single) -// 0.0000000000123456789123456789 (Decimal) --> 1.234568E-11 (Single) -// 123 (Decimal) --> 123 (Single) -// 123.000000 (Decimal) --> 123 (Single) -// 123456789.123456789 (Decimal) --> 1.234568E+08 (Single) -// 123456789123456789123456789 (Decimal) --> 1.234568E+26 (Single) -// -79228162514264337593543950335 (Decimal) --> -7.922816E+28 (Single) -// 79228162514264337593543950335 (Decimal) --> 7.922816E+28 (Single) -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.exception.tostring/cpp/ToStringEx1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.exception.tostring/cpp/ToStringEx1.cpp deleted file mode 100644 index 94a5f963ddb..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.exception.tostring/cpp/ToStringEx1.cpp +++ /dev/null @@ -1,47 +0,0 @@ - -// -using namespace System; - -public ref class TestClass{}; - -int main() -{ - TestClass^ test = gcnew TestClass; - array^ objectsToCompare = { test, test->ToString(), 123, - (123).ToString(), "some text", - "Some Text" }; - String^ s = "some text"; - for each (Object^ objectToCompare in objectsToCompare) { - try { - Int32 i = s->CompareTo(objectToCompare); - Console::WriteLine("Comparing '{0}' with '{1}': {2}", - s, objectToCompare, i); - } - catch (ArgumentException^ e) { - Console::WriteLine("Bad argument: {0} (type {1})", - objectToCompare, - objectToCompare->GetType()->Name); - Console::WriteLine("Exception information: {0}", e); - } - Console::WriteLine(); - } -} -// The example displays the following output: -// Bad argument: TestClass (type TestClass) -// Exception information: System.ArgumentException: Object must be of type String. -// at System.String.CompareTo(Object value) -// at Example.Main() -// -// Comparing 'some text' with 'TestClass': -1 -// -// Bad argument: 123 (type Int32) -// Exception information: System.ArgumentException: Object must be of type String. -// at System.String.CompareTo(Object value) -// at Example.Main() -// -// Comparing 'some text' with '123': 1 -// -// Comparing 'some text' with 'some text': 0 -// -// Comparing 'some text' with 'Some Text': -1 -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.gc.collect int example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.gc.collect int example/CPP/class1.cpp deleted file mode 100644 index ed84d371b80..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.gc.collect int example/CPP/class1.cpp +++ /dev/null @@ -1,54 +0,0 @@ - -// -using namespace System; -const long maxGarbage = 1000; -ref class MyGCCollectClass -{ -public: - void MakeSomeGarbage() - { - Version^ vt; - for ( int i = 0; i < maxGarbage; i++ ) - { - - // Create objects and release them to fill up memory - // with unused objects. - vt = gcnew Version; - - } - } - -}; - -int main() -{ - MyGCCollectClass^ myGCCol = gcnew MyGCCollectClass; - - // Determine the maximum number of generations the system - // garbage collector currently supports. - Console::WriteLine( "The highest generation is {0}", GC::MaxGeneration ); - myGCCol->MakeSomeGarbage(); - - // Determine which generation myGCCol object is stored in. - Console::WriteLine( "Generation: {0}", GC::GetGeneration( myGCCol ) ); - - // Determine the best available approximation of the number - // of bytes currently allocated in managed memory. - Console::WriteLine( "Total Memory: {0}", GC::GetTotalMemory( false ) ); - - // Perform a collection of generation 0 only. - GC::Collect( 0 ); - - // Determine which generation myGCCol object is stored in. - Console::WriteLine( "Generation: {0}", GC::GetGeneration( myGCCol ) ); - Console::WriteLine( "Total Memory: {0}", GC::GetTotalMemory( false ) ); - - // Perform a collection of all generations up to and including 2. - GC::Collect( 2 ); - - // Determine which generation myGCCol object is stored in. - Console::WriteLine( "Generation: {0}", GC::GetGeneration( myGCCol ) ); - Console::WriteLine( "Total Memory: {0}", GC::GetTotalMemory( false ) ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.int32.maxvalue/cpp/maxvalue1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.int32.maxvalue/cpp/maxvalue1.cpp deleted file mode 100644 index b8f17f0074a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.int32.maxvalue/cpp/maxvalue1.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// -using namespace System; - -void main() -{ - array^ numbersToConvert = gcnew array { 162345, 32183, -54000, - Int64::MaxValue/2 }; - Int32 newNumber; - for each (Int64 number in numbersToConvert) - { - if ((number >= Int32::MinValue) && (number <= Int32::MaxValue)) - { - newNumber = Convert::ToInt32(number); - Console::WriteLine("Successfully converted {0} to an Int32.", - newNumber); - } - else - { - Console::WriteLine("Unable to convert {0} to an Int32.", number); - } - } -} -// The example displays the following output to the console: -// Successfully converted 162345 to an Int32. -// Successfully converted 32183 to an Int32. -// Successfully converted -54000 to an Int32. -// Unable to convert 4611686018427387903 to an Int32. -// - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.nullableOfT.class/cpp/tarow.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.nullableOfT.class/cpp/tarow.cpp deleted file mode 100644 index e08099e7418..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.nullableOfT.class/cpp/tarow.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// -using namespace System; - -// Define the "titleAuthor" table of the Microsoft "pubs" database. -value struct titleAuthor -{ - public: - // Author ID; format ###-##-#### - String^ au_id; - // Title ID; format AA#### - String^ title_id; - // Author ORD is nullable. - Nullable au_ord; - // Royalty Percent is nullable. - Nullable royaltyper; - - // Display the values of the titleAuthor array elements. - static void Display(String^ dspTitle, - array^ dspAllTitleAuthors) - { - Console::WriteLine("*** {0} ***", dspTitle); - for each (titleAuthor dspTA in dspAllTitleAuthors) { - Console::WriteLine("Author ID ... {0}", dspTA.au_id); - Console::WriteLine("Title ID .... {0}", dspTA.title_id); - Console::WriteLine("Author ORD .. {0}", dspTA.au_ord.HasValue ? - dspTA.au_ord.Value : -1); - Console::WriteLine("Royalty % ... {0}", dspTA.royaltyper.HasValue ? - dspTA.royaltyper.Value : 0); - Console::WriteLine(); - } - } -}; - -void main() -{ - // Declare and initialize the titleAuthor array. - array^ ta = gcnew array(3); - ta[0].au_id = "712-32-1176"; - ta[0].title_id = "PS3333"; - ta[0].au_ord = 1; - ta[0].royaltyper = 100; - - ta[1].au_id = "213-46-8915"; - ta[1].title_id = "BU1032"; -// ta[1].au_ord = nullptr; -// ta[1].royaltyper = nullptr; - - ta[2].au_id = "672-71-3249"; - ta[2].title_id = "TC7777"; -// ta[2].au_ord = nullptr; - ta[2].royaltyper = 40; - - // Display the values of the array elements, and - // display a legend. - titleAuthor::Display("Title Authors Table", ta); - Console::WriteLine("Legend:"); - Console::WriteLine("An Author ORD of -1 means no value is defined."); - Console::WriteLine("A Royalty % of 0 means no value is defined."); -} -// The example displays the following output: -// *** Title Authors Table *** -// Author ID ... 712-32-1176 -// Title ID .... PS3333 -// Author ORD .. 1 -// Royalty % ... 100 -// -// Author ID ... 213-46-8915 -// Title ID .... BU1032 -// Author ORD .. -1 -// Royalty % ... 0 -// -// Author ID ... 672-71-3249 -// Title ID .... TC7777 -// Author ORD .. -1 -// Royalty % ... 40 -// -// Legend: -// An Author ORD of -1 means no value is defined. -// A Royalty % of 0 means no value is defined. -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.object.tostring/cpp/tostring1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.object.tostring/cpp/tostring1.cpp deleted file mode 100644 index aed41164638..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.object.tostring/cpp/tostring1.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// -using namespace System; - -void main() -{ - Object^ obj = gcnew Object(); - Console::WriteLine(obj->ToString()); -} -// The example displays the following output: -// System.Object -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.object.tostring/cpp/tostring2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.object.tostring/cpp/tostring2.cpp deleted file mode 100644 index 555db31ba29..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.object.tostring/cpp/tostring2.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// -using namespace System; - -namespace Examples -{ - ref class Object1 - { - }; -} - -void main() -{ - Object^ obj1 = gcnew Examples::Object1(); - Console::WriteLine(obj1->ToString()); -} -// The example displays the following output: -// Examples.Object1 -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.object.tostring/cpp/tostring3.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.object.tostring/cpp/tostring3.cpp deleted file mode 100644 index 874d33085c2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.object.tostring/cpp/tostring3.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// -using namespace System; - -ref class Object2 -{ - private: - Object^ value; - - public: - Object2(Object^ value) - { - this->value = value; - } - - virtual String^ ToString() override - { - return Object::ToString() + ": " + value->ToString(); - } -}; - -void main() -{ - Object2^ obj2 = gcnew Object2(L'a'); - Console::WriteLine(obj2->ToString()); - -} -// The example displays the following output: -// Object2: a -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.string.concat/cpp/Concat6.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.string.concat/cpp/Concat6.cpp deleted file mode 100644 index 2f65db80fc4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.string.concat/cpp/Concat6.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// -using namespace System; - -void main() -{ - String^ s1 = "We went to a bookstore, "; - String^ s2 = "a movie, "; - String^ s3 = "and a restaurant."; - - String^ s = String::Concat(s1, s2, s3); - Console::WriteLine(s); -} -// The example displays the following output: -// We went to a bookstore, a movie, and a restaurant. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.string.ctor/cpp/assignment.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.string.ctor/cpp/assignment.cpp deleted file mode 100644 index 013c216996e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.string.ctor/cpp/assignment.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// Assignment.cpp : Defines the entry point for the console application. -// - -//#include "stdafx.h" -// -using namespace System; - -void main() -{ - String^ value1 = L"This is a string."; - String^ value2 = value1; - Console::WriteLine(value1); - Console::WriteLine(value2); -} -// The example displays the following output: -// This is a string. -// This is a string. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.string.ctor/cpp/char1_ctor.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.string.ctor/cpp/char1_ctor.cpp deleted file mode 100644 index a5ea741588d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.string.ctor/cpp/char1_ctor.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// Char1_Ctor.cpp : Defines the entry point for the console application. -// - -//#include "stdafx.h" - -// -using namespace System; - -void main() -{ - wchar_t characters[] = {L'H',L'e',L'l',L'l',L'o',L' ', - L'W',L'o',L'r',L'l',L'd',L'!',L'\x0000'}; - - Char* charPtr = characters; - String^ value = gcnew String(charPtr); - Console::WriteLine(value); -} -// The example displays the following output: -// Hello world! -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.string.ctor/cpp/char2_ctor.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.string.ctor/cpp/char2_ctor.cpp deleted file mode 100644 index 94226ba6f8d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.string.ctor/cpp/char2_ctor.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// Char2_Ctor.cpp : Defines the entry point for the console application. -// - -//#include "stdafx.h" - -// -using namespace System; - - -void main() -{ - wchar_t characters[] = {L'H',L'e',L'l',L'l',L'o',L' ', - L'W',L'o',L'r',L'l',L'd',L'!',L'\x0000'}; - - Char* charPtr = characters; - int length = 0; - Char* iterator = charPtr; - - while (*iterator != '\x0000') - { - if (*iterator == L'!' || *iterator == L'.') - break; - *iterator++; - length++; - } - String^ value = gcnew String(charPtr, 0, length); - Console::WriteLine(value); -} -// The example displays the following output: -// Hello World -// - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.string.ctor/cpp/chptrctor_null.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.string.ctor/cpp/chptrctor_null.cpp deleted file mode 100644 index 312c24bbe53..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.string.ctor/cpp/chptrctor_null.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// -using namespace System; - -void main() -{ - wchar_t chars[] = { L'a', L'b', L'c', L'd', L'\0', L'A', L'B', - L'C', L'D', L'\0' }; - Char* chPtr = chars; - String^ s = gcnew String(chPtr, 0, - sizeof(chars) / sizeof (wchar_t)); - for each (Char ch in s) - Console::Write("{0:X4} ", Convert::ToUInt16(ch)); - Console::WriteLine(); - - s = gcnew String(chPtr); - - for each (Char ch in s) - Console::Write("{0:X4} ", Convert::ToUInt16(ch)); - Console::WriteLine(); -} -// The example displays the following output: -// 0061 0062 0063 0064 0000 0041 0042 0043 0044 0000 -// 0061 0062 0063 0064 -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.string.ctor/cpp/ptrctor_null.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.string.ctor/cpp/ptrctor_null.cpp deleted file mode 100644 index 3116bd1e648..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.string.ctor/cpp/ptrctor_null.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// -using namespace System; - -void main() -{ - char bytes[] = { 0x61, 0x62, 0x063, 0x064, 0x00, 0x41, 0x42,0x43, - 0x44, 0x00 }; - - char* bytePtr = bytes; - String^ s = gcnew String(bytePtr, 0, sizeof(bytes) / sizeof (char)); - - for each (Char ch in s) - Console::Write("{0:X4} ", Convert::ToUInt16(ch)); - - Console::WriteLine(); - - s = gcnew String(bytePtr); - - for each (Char ch in s) - Console::Write("{0:X4} ", Convert::ToUInt16(ch)); - Console::WriteLine(); -} -// The example displays the following output: -// 0061 0062 0063 0064 0000 0041 0042 0043 0044 0000 -// 0061 0062 0063 0064 -// - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.string.isnullorempty/cpp/NullString1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.string.isnullorempty/cpp/NullString1.cpp deleted file mode 100644 index 7902bf7169d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.string.isnullorempty/cpp/NullString1.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -using namespace System; - -void main() -{ - String^ s; - - Console::WriteLine("The value of the string is '{0}'", s); - - try { - Console::WriteLine("String length is {0}", s->Length); - } - catch (NullReferenceException^ e) { - Console::WriteLine(e->Message); - } -} -// The example displays the following output: -// The value of the string is '' -// Object reference not set to an instance of an object. -// - -void Test() -{ - // - String^ s = ""; - Console::WriteLine("The length of '{0}' is {1}.", s, s->Length); - // The example displays the following output: - // The length of '' is 0. - // -} - - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.string.isnullorempty/cpp/isnullorempty1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.string.isnullorempty/cpp/isnullorempty1.cpp deleted file mode 100644 index f7d1b9f1579..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.string.isnullorempty/cpp/isnullorempty1.cpp +++ /dev/null @@ -1,18 +0,0 @@ -using namespace System; - -bool Test( String^ s ) -{ - bool result; - // - result = s == nullptr || s == String::Empty; - // - return result; -} - -int main() -{ - String^ s1; - String^ s2 = ""; - Console::WriteLine( "String s1 {0}.", Test( s1 ) ); - Console::WriteLine( "String s2 {0}.", Test( s2 ) ); -} \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.string.startswith/cpp/StartsWith2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.string.startswith/cpp/StartsWith2.cpp deleted file mode 100644 index c61179db48d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.string.startswith/cpp/StartsWith2.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// -using namespace System; - -void main() -{ - String^ title = "The House of the Seven Gables"; - String^ searchString = "the"; - StringComparison comparison = StringComparison::InvariantCulture; - Console::WriteLine("'{0}':", title); - Console::WriteLine(" Starts with '{0}' ({1:G} comparison): {2}", - searchString, comparison, - title->StartsWith(searchString, comparison)); - - comparison = StringComparison::InvariantCultureIgnoreCase; - Console::WriteLine(" Starts with '{0}' ({1:G} comparison): {2}", - searchString, comparison, - title->StartsWith(searchString, comparison)); - } -// The example displays the following output: -// 'The House of the Seven Gables': -// Starts with 'the' (InvariantCulture comparison): False -// Starts with 'the' (InvariantCultureIgnoreCase comparison): True -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.string.startswith/cpp/startswith1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.string.startswith/cpp/startswith1.cpp deleted file mode 100644 index efd8df82bf8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.string.startswith/cpp/startswith1.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// -using namespace System; - -void main() -{ - array^ strings = gcnew array { {"ABCdef", "abc" }, - {"ABCdef", "abc" }, {"Å“il","oe" }, - { "læring}", "lae" } }; - for (int ctr1 = strings->GetLowerBound(0); ctr1 <= strings->GetUpperBound(0); ctr1++) - { - for each (String^ cmpName in Enum::GetNames(StringComparison::typeid)) - { - StringComparison strCmp = (StringComparison) Enum::Parse(StringComparison::typeid, - cmpName); - String^ instance = strings[ctr1, 0]; - String^ value = strings[ctr1, 1]; - Console::WriteLine("{0} starts with {1}: {2} ({3} comparison)", - instance, value, - instance->StartsWith(value, strCmp), - strCmp); - } - Console::WriteLine(); - } -} - -// The example displays the following output: -// ABCdef starts with abc: False (CurrentCulture comparison) -// ABCdef starts with abc: True (CurrentCultureIgnoreCase comparison) -// ABCdef starts with abc: False (InvariantCulture comparison) -// ABCdef starts with abc: True (InvariantCultureIgnoreCase comparison) -// ABCdef starts with abc: False (Ordinal comparison) -// ABCdef starts with abc: True (OrdinalIgnoreCase comparison) -// -// ABCdef starts with abc: False (CurrentCulture comparison) -// ABCdef starts with abc: True (CurrentCultureIgnoreCase comparison) -// ABCdef starts with abc: False (InvariantCulture comparison) -// ABCdef starts with abc: True (InvariantCultureIgnoreCase comparison) -// ABCdef starts with abc: False (Ordinal comparison) -// ABCdef starts with abc: True (OrdinalIgnoreCase comparison) -// -// Å“il starts with oe: True (CurrentCulture comparison) -// Å“il starts with oe: True (CurrentCultureIgnoreCase comparison) -// Å“il starts with oe: True (InvariantCulture comparison) -// Å“il starts with oe: True (InvariantCultureIgnoreCase comparison) -// Å“il starts with oe: False (Ordinal comparison) -// Å“il starts with oe: False (OrdinalIgnoreCase comparison) -// -// læring} starts with lae: True (CurrentCulture comparison) -// læring} starts with lae: True (CurrentCultureIgnoreCase comparison) -// læring} starts with lae: True (InvariantCulture comparison) -// læring} starts with lae: True (InvariantCultureIgnoreCase comparison) -// læring} starts with lae: False (Ordinal comparison) -// læring} starts with lae: False (OrdinalIgnoreCase comparison) -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.type.basetype/cpp/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.type.basetype/cpp/remarks.cpp deleted file mode 100644 index 7b4d07bf1ce..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.type.basetype/cpp/remarks.cpp +++ /dev/null @@ -1,11 +0,0 @@ - -using namespace System; - -// -generic ref class B { }; -generic ref class C : B { }; -// - - -int main() {} - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.type.declaringtype/cpp/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.type.declaringtype/cpp/remarks.cpp deleted file mode 100644 index 3c606201207..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.type.declaringtype/cpp/remarks.cpp +++ /dev/null @@ -1,12 +0,0 @@ - -using namespace System; -using namespace System::Collections::Generic; - -void main() -{ -// - Type^ t = List::typeid->GetMethod("ConvertAll")->GetGenericArguments()[0]->DeclaringType; -// - Console::WriteLine("Declaring type: {0:s}", t->FullName); -} - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.type.genericparameterposition/cpp/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.type.genericparameterposition/cpp/remarks.cpp deleted file mode 100644 index 887160b2c0e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.type.genericparameterposition/cpp/remarks.cpp +++ /dev/null @@ -1,18 +0,0 @@ - -using namespace System; - -// -generic public ref class B { }; -generic public ref class A -{ -public: - generic B^ GetSomething() - { - return gcnew B(); - } -}; -// - - -int main() {} - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.type.makegenerictype/cpp/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.type.makegenerictype/cpp/remarks.cpp deleted file mode 100644 index 27ef62bdf1a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.type.makegenerictype/cpp/remarks.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -using namespace System; - -// -generic - public ref class Base { }; -generic - public ref class Derived : Base { }; -// - -// -generic public ref class Outermost -{ -public: - generic ref class Inner - { - public: - generic ref class Innermost1 {}; - ref class Innermost2 {}; - }; -}; -// - - -int main() {} - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.version.revision/cpp/rev.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.version.revision/cpp/rev.cpp deleted file mode 100644 index e36381d28c4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.version.revision/cpp/rev.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -// This example demonstrates the Version.Revision, -// MajorRevision, and MinorRevision properties. -using namespace System; - -int main() -{ - String^ formatStandard = "Standard version:\n" + - " major.minor.build.revision = {0}.{1}.{2}.{3}"; - String^ formatInterim = "Interim version:\n" + - " major.minor.build.majRev/minRev = {0}.{1}.{2}.{3}/{4}"; - - Version^ standardVersion = gcnew Version(2, 4, 1128, 2); - Version^ interimVersion = gcnew Version(2, 4, 1128, (100 << 16) + 2); - - Console::WriteLine(formatStandard, standardVersion->Major, - standardVersion->Minor, standardVersion->Build, - standardVersion->Revision); - Console::WriteLine(formatInterim, interimVersion->Major, - interimVersion->Minor, interimVersion->Build, - interimVersion->MajorRevision, interimVersion->MinorRevision); -}; -/* -This code example produces the following results: - -Standard version: -major.minor.build.revision = 2.4.1128.2 -Interim version: -major.minor.build.majRev/minRev = 2.4.1128.100/2 - -*/ -// diff --git a/xml/System.AddIn.Hosting/AddInToken.xml b/xml/System.AddIn.Hosting/AddInToken.xml index d920fc17488..937614eb63f 100644 --- a/xml/System.AddIn.Hosting/AddInToken.xml +++ b/xml/System.AddIn.Hosting/AddInToken.xml @@ -30,38 +30,38 @@ Represents an add-in that can be activated. - object represents an add-in, and its associated pipeline segments, that can be activated. The token contains the name, assembly name, description, publisher, and version of the add-in that it represents. - - Use the method to get a collection of tokens that represent add-ins whose pipelines match a specified host view. Use the method to get a collection of tokens that represent all the pipelines for a specified add-in that match a specified host view. - - To activate an add-in, pass the token that represents the desired add-in to the method. This method returns an instance of the type that represents the host view of the add-in. - - The method has several overloads. When you use an overload that does not require the name of an application domain as one of its parameters, a new application domain for the add-in is automatically created. - - You can use Language-Integrated Query (LINQ) extension methods to perform queries on an , treating the token as a collection of structures. - - - -## Examples - This section contains two examples. The first example activates an add-in that has been selected by using the `ChooseAddIn` method, and the second example shows the `ChooseAddIn` method. - - **Example 1** - - The following example shows how to activate an add-in with a token. - + object represents an add-in, and its associated pipeline segments, that can be activated. The token contains the name, assembly name, description, publisher, and version of the add-in that it represents. + + Use the method to get a collection of tokens that represent add-ins whose pipelines match a specified host view. Use the method to get a collection of tokens that represent all the pipelines for a specified add-in that match a specified host view. + + To activate an add-in, pass the token that represents the desired add-in to the method. This method returns an instance of the type that represents the host view of the add-in. + + The method has several overloads. When you use an overload that does not require the name of an application domain as one of its parameters, a new application domain for the add-in is automatically created. + + You can use Language-Integrated Query (LINQ) extension methods to perform queries on an , treating the token as a collection of structures. + + + +## Examples + This section contains two examples. The first example activates an add-in that has been selected by using the `ChooseAddIn` method, and the second example shows the `ChooseAddIn` method. + + **Example 1** + + The following example shows how to activate an add-in with a token. + :::code language="csharp" source="~/snippets/csharp/System.AddIn.Hosting/AddInController/Overview/P3Host.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet5"::: - - **Example 2** - - The following example shows the custom `ChooseAddIn` method, which enumerates an collection. The user selects a token from this collection to activate the corresponding add-in. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet5"::: + + **Example 2** + + The following example shows the custom `ChooseAddIn` method, which enumerates an collection. The user selects a token from this collection to activate the corresponding add-in. + :::code language="csharp" source="~/snippets/csharp/System.AddIn.Hosting/AddInController/Overview/P3Host.cs" id="Snippet13"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet13"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet13"::: + ]]> Add-Ins and Extensibility @@ -104,19 +104,19 @@ Activates an add-in in the environment of another add-in. The host view of the add-in. - object. - + object. + :::code language="csharp" source="~/snippets/csharp/System.AddIn.Hosting/AddInController/Overview/P3Host.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet8"::: + ]]> Add-Ins and Extensibility @@ -150,21 +150,21 @@ Activates an add-in with a specified trust level in a new application domain. The host view of the add-in. - overload. - - This method sets the base directory for the application domain to be the location of the add-in assembly. It also looks for the configuration file [addinassemblyname].dll.config and, if found, sets it to be the configuration file for the new application domain. - - - -## Examples - The following example shows how to activate an add-in, identified by the chosen token, in an automatically generated application domain with a specified security level. - + overload. + + This method sets the base directory for the application domain to be the location of the add-in assembly. It also looks for the configuration file [addinassemblyname].dll.config and, if found, sets it to be the configuration file for the new application domain. + + + +## Examples + The following example shows how to activate an add-in, identified by the chosen token, in an automatically generated application domain with a specified security level. + :::code language="csharp" source="~/snippets/csharp/System.AddIn.Hosting/AddInController/Overview/P3Host.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet5"::: + ]]> Add-Ins and Extensibility @@ -198,19 +198,19 @@ Activates an add-in in an existing application domain. The host view of the add-in. - overload to generate a new application domain with a specified security level or the overload to include a friendly name for the application domain. - - - -## Examples - The following example activates an add-in in an application domain that is being used by another add-in. The code for the first add-in is provided in the class. - + overload to generate a new application domain with a specified security level or the overload to include a friendly name for the application domain. + + + +## Examples + The following example activates an add-in in an application domain that is being used by another add-in. The code for the first add-in is provided in the class. + :::code language="csharp" source="~/snippets/csharp/System.AddIn.Hosting/AddInController/Overview/P3Host.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet9"::: + ]]> Full-trust permission is demanded. A caller in the call chain does not have sufficient permission. @@ -244,11 +244,11 @@ Activates an add-in with a specified permission set in a new application domain. The host view of the add-in. - @@ -291,19 +291,19 @@ Activates an add-in in an external process, in a new application domain, and with a specified trust level. The host view of the add-in. - @@ -344,11 +344,11 @@ Activates an add-in in an external process, in a new application domain, and with a specified permission set. The host view of the add-in. - @@ -383,13 +383,13 @@ Activates an add-in in a new application domain with a specified name and trust level. The host view of the add-in. - overload. - - This method sets the base directory for the application domain to be the location of the add-in assembly. It also looks for the configuration file `[addinassemblyname].dll.config` and, if found, sets it to be the configuration file for the new application domain. - + overload. + + This method sets the base directory for the application domain to be the location of the add-in assembly. It also looks for the configuration file `[addinassemblyname].dll.config` and, if found, sets it to be the configuration file for the new application domain. + ]]> @@ -414,19 +414,19 @@ Gets the namespace and type of the add-in. The type of the add-in, fully qualified by its namespace. - property. This value is always available on an instance of an object. - - - -## Examples - The following example displays the value of the , , , , , and properties to the console. This code example is part of a larger example provided for the class. - + property. This value is always available on an instance of an object. + + + +## Examples + The following example displays the value of the , , , , , and properties to the console. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.AddIn.Hosting/AddInController/Overview/P3Host.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet7"::: + ]]> @@ -451,19 +451,19 @@ Gets the name of the assembly that contains the add-in. The name of the assembly. - property. This value is always available on an instance of an object. - - - -## Examples - The following example displays the value of the , , , , , and properties to the console. This code example is part of a larger example provided for the class. - + property. This value is always available on an instance of an object. + + + +## Examples + The following example displays the value of the , , , , , and properties to the console. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.AddIn.Hosting/AddInController/Overview/P3Host.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet7"::: + ]]> @@ -488,19 +488,19 @@ Gets the description of the add-in. A description of the add-in, or if the description is not specified in the attribute. - attribute. - - - -## Examples - The following example displays the value of the , , , , , and properties to the console. This code example is part of a larger example provided for the class. - + attribute. + + + +## Examples + The following example displays the value of the , , , , , and properties to the console. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.AddIn.Hosting/AddInController/Overview/P3Host.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet7"::: + ]]> @@ -536,21 +536,21 @@ if the add-in should be directly connected to the host; otherwise, . The default is . - @@ -606,26 +606,24 @@ Returns an enumerator for the qualification data of the pipeline segments that are associated with this token. An enumerator that can be used to iterate through the qualification data of the pipeline segments that are associated with the current token. - structure that identifies the pipeline segment and contains a name/value pair from a attribute applied to that segment. - + structure that identifies the pipeline segment and contains a name/value pair from a attribute applied to that segment. + > [!NOTE] -> The add-in model does not use qualification data that is applied to the host view of the add-in. As a result, when you enumerate qualification data you will not find any items whose property is . - - Alternatively, you can use the property to get a nested set of dictionaries that contain the qualification data of the pipeline segments. - - - -## Examples - The following example lists the qualification data for the pipeline segments associated with each in a collection of tokens. - +> The add-in model does not use qualification data that is applied to the host view of the add-in. As a result, when you enumerate qualification data you will not find any items whose property is . + + Alternatively, you can use the property to get a nested set of dictionaries that contain the qualification data of the pipeline segments. + +## Examples + The following example lists the qualification data for the pipeline segments associated with each in a collection of tokens. + :::code language="csharp" source="~/snippets/csharp/System.AddIn.Hosting/AddInController/Overview/P3Host.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet12"::: + ]]> @@ -673,19 +671,19 @@ Gets the name of the add-in. The name of the add-in. - attribute. This value is always available on an instance of an object. - - - -## Examples - The following example displays the value of the , , , , , and properties to the console. This code example is part of a larger example provided for the class. - + attribute. This value is always available on an instance of an object. + + + +## Examples + The following example displays the value of the , , , , , and properties to the console. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.AddIn.Hosting/AddInController/Overview/P3Host.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet7"::: + ]]> @@ -710,19 +708,19 @@ Gets the publisher of the add-in. The publisher of the add-in, or if the publisher is not specified in the attribute. - attribute. - - - -## Examples - The following example displays the value of the , , , , , and properties to the console. This code example is part of a larger example provided for the class. - + attribute. + + + +## Examples + The following example displays the value of the , , , , , and properties to the console. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.AddIn.Hosting/AddInController/Overview/P3Host.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet7"::: + ]]> @@ -747,28 +745,26 @@ Gets a dictionary of data about the segments in the pipeline associated with the current token. A dictionary whose keys are pipeline segments and whose values are dictionaries of name/value pairs that represent qualification data for each segment. - attribute. You can use this data to identify and work with the types that compose your pipelines. - - This property returns a dictionary of dictionaries. The top dictionary always has six keys. Each key is an value for a segment in the pipeline. Each value is a generic of strings with string keys that contains the segment's qualification data. - - The keys and values of these inner dictionaries are the names and values specified in the attributes for the segments. If no qualification data has been applied to a segment, its dictionary is empty. - + attribute. You can use this data to identify and work with the types that compose your pipelines. + + This property returns a dictionary of dictionaries. The top dictionary always has six keys. Each key is an value for a segment in the pipeline. Each value is a generic of strings with string keys that contains the segment's qualification data. + + The keys and values of these inner dictionaries are the names and values specified in the attributes for the segments. If no qualification data has been applied to a segment, its dictionary is empty. + > [!NOTE] -> The add-in model does not use qualification data that is applied to the host view of the add-in. As a result, the dictionary for is always empty. - - Alternatively, you can obtain qualification data by enumerating an as if it were a collection of structures, using a `foreach` statement (`For Each` in Visual Basic, `for each` in Visual C++). See the example provided for the structure. - - - -## Examples - The following example shows how to examine an add-in's qualification data. - +> The add-in model does not use qualification data that is applied to the host view of the add-in. As a result, the dictionary for is always empty. + + Alternatively, you can obtain qualification data by enumerating an as if it were a collection of structures, using a `foreach` statement in C#. See the example provided for the structure. + +## Examples + The following example shows how to examine an add-in's qualification data. + :::code language="csharp" source="~/snippets/csharp/System.AddIn.Hosting/AddInController/Overview/P3Host.cs" id="Snippet11"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet11"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet11"::: + ]]> @@ -803,18 +799,18 @@ Returns an enumerator for the qualification data of the pipeline segments that are associated with this token. An enumerator that can be used to iterate through the qualification data of the pipeline segments that are associated with the current token. - structure that identifies the pipeline segment and contains the name/value pair from a attribute applied to that segment. - + structure that identifies the pipeline segment and contains the name/value pair from a attribute applied to that segment. + > [!NOTE] -> The add-in model does not use qualification data that is applied to the host view of the add-in. As a result, when you enumerate qualification data you will not find any items whose property is . - - Alternatively, you can use the property to get a nested set of dictionaries containing the qualification data of the pipeline segments. - +> The add-in model does not use qualification data that is applied to the host view of the add-in. As a result, when you enumerate qualification data you will not find any items whose property is . + + Alternatively, you can use the property to get a nested set of dictionaries containing the qualification data of the pipeline segments. + ]]> @@ -862,19 +858,19 @@ Gets the version of the add-in, as specified in the attribute. The version of the add-in, or if the version number is not specified in the attribute. - , , , , , and properties to the console. This code example is part of a larger example provided for the class. - + , , , , , and properties to the console. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.AddIn.Hosting/AddInController/Overview/P3Host.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet7"::: + ]]> diff --git a/xml/System.AddIn.Hosting/QualificationDataItem.xml b/xml/System.AddIn.Hosting/QualificationDataItem.xml index acc729f0253..7dbceb4a742 100644 --- a/xml/System.AddIn.Hosting/QualificationDataItem.xml +++ b/xml/System.AddIn.Hosting/QualificationDataItem.xml @@ -23,23 +23,21 @@ Represents information supplied by the developer of a pipeline segment, for use by the host. - attribute, to provide information that qualifies the use of the segment (for example, the recommended isolation level for the segment). The structure contains one name/value pair and the type of pipeline segment it was applied to. - - Use the property to get a nested set of dictionaries that contains structures for the pipeline segments associated with an . - - Alternatively, use the method to get an enumerator for the structures of the pipeline segments associated with a token, or simply use a `foreach` statement (`For Each` in Visual Basic, `for each` in Visual C++) to treat the token as if it were a collection of structures. - - - -## Examples - The following example lists the qualification data for the pipeline segments associated with each in a collection of tokens. - + attribute, to provide information that qualifies the use of the segment (for example, the recommended isolation level for the segment). The structure contains one name/value pair and the type of pipeline segment it was applied to. + + Use the property to get a nested set of dictionaries that contains structures for the pipeline segments associated with an . + + Alternatively, use the method to get an enumerator for the structures of the pipeline segments associated with a token, or simply use a `foreach` statement (`For Each` in Visual Basic) to treat the token as if it were a collection of structures. + +## Examples + The following example lists the qualification data for the pipeline segments associated with each in a collection of tokens. + :::code language="csharp" source="~/snippets/csharp/System.AddIn.Hosting/AddInController/Overview/P3Host.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet12"::: + ]]> @@ -120,19 +118,19 @@ Gets the name of the qualification data item. The name of the qualification data item. - attribute, to provide information to consumers of the add-in. The property gets the name. Use the property to get the value. - - - -## Examples - The following example lists the qualification data for the pipeline segments associated with each in a collection of tokens. The property is used to display the name of each item. - + attribute, to provide information to consumers of the add-in. The property gets the name. Use the property to get the value. + + + +## Examples + The following example lists the qualification data for the pipeline segments associated with each in a collection of tokens. The property is used to display the name of each item. + :::code language="csharp" source="~/snippets/csharp/System.AddIn.Hosting/AddInController/Overview/P3Host.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet12"::: + ]]> @@ -221,22 +219,22 @@ Gets a value that identifies the pipeline segment the qualification data item was applied to. The kind of pipeline segment the data item was applied to. - [!NOTE] -> The add-in model does not use qualification data that is applied to the host view of the add-in. As a result, when you enumerate qualification data you will not find any items whose property is . - - - -## Examples - The following example lists the qualification data for the pipeline segments associated with each in a collection of tokens. The property is used to display the kind of segment. - +> The add-in model does not use qualification data that is applied to the host view of the add-in. As a result, when you enumerate qualification data you will not find any items whose property is . + + + +## Examples + The following example lists the qualification data for the pipeline segments associated with each in a collection of tokens. The property is used to display the kind of segment. + :::code language="csharp" source="~/snippets/csharp/System.AddIn.Hosting/AddInController/Overview/P3Host.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet12"::: + ]]> @@ -267,19 +265,19 @@ Gets the value of the qualification data item. The value of the item. - attribute, to provide information to consumers of the add-in. The property gets the value. Use the property to get the name. - - - -## Examples - The following example lists the qualification data for the pipeline segments associated with each in a collection of tokens. The property is used to display the value of the item. - + attribute, to provide information to consumers of the add-in. The property gets the value. Use the property to get the name. + + + +## Examples + The following example lists the qualification data for the pipeline segments associated with each in a collection of tokens. The property is used to display the value of the item. + :::code language="csharp" source="~/snippets/csharp/System.AddIn.Hosting/AddInController/Overview/P3Host.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/addinP3Host/vb/p3host.vb" id="Snippet12"::: + ]]> diff --git a/xml/System.CodeDom.Compiler/CodeDomProvider.xml b/xml/System.CodeDom.Compiler/CodeDomProvider.xml index 1684915751d..51531b65953 100644 --- a/xml/System.CodeDom.Compiler/CodeDomProvider.xml +++ b/xml/System.CodeDom.Compiler/CodeDomProvider.xml @@ -68,7 +68,6 @@ ## Examples The following example program can generate and compile source code based on a CodeDOM model of a program that prints "Hello World" using the class. A Windows Forms user interface is provided. The user can select the target programming language from several selections: C#, Visual Basic, and JScript. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDomExample/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCompileUnit/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomExample/VB/source.vb" id="Snippet1"::: @@ -716,7 +715,6 @@ ## Examples The following code example determines the implementation for an input language and displays the configured settings for the language provider. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDom_CompilerInfo/CPP/source.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CodeDomProvider/CreateProvider/source.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDom_CompilerInfo/VB/source.vb" id="Snippet6"::: @@ -892,7 +890,6 @@ ## Examples The following code example creates an instance of . The example displays the provider name, hash code and default file name extension for the new provider instance. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDom_CompilerInfo/CPP/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CodeDomProvider/CreateProvider/source.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDom_CompilerInfo/VB/source.vb" id="Snippet3"::: @@ -950,7 +947,6 @@ ## Examples The following code example shows the use of the method to generate code for a "Hello World" application from a . This example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDomExample/CPP/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCompileUnit/Overview/source.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomExample/VB/source.vb" id="Snippet3"::: @@ -1299,7 +1295,6 @@ ## Examples The following code example enumerates the language providers on the computer and displays the configuration and compiler settings for each language provider. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDom_CompilerInfo/CPP/source.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CodeDomProvider/CreateProvider/source.cs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDom_CompilerInfo/VB/source.vb" id="Snippet8"::: @@ -1367,7 +1362,6 @@ ## Examples The following code example determines the implementation for an input language and displays the configured settings for the language provider. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDom_CompilerInfo/CPP/source.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CodeDomProvider/CreateProvider/source.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDom_CompilerInfo/VB/source.vb" id="Snippet6"::: @@ -1484,7 +1478,6 @@ ## Examples The following code example determines the implementation for an input file name extension and displays the configured settings for the language provider. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDom_CompilerInfo/CPP/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CodeDomProvider/CreateProvider/source.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDom_CompilerInfo/VB/source.vb" id="Snippet5"::: @@ -1602,7 +1595,6 @@ ## Examples The following code example determines the implementation for an input file name extension and displays the configured settings for the language provider. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDom_CompilerInfo/CPP/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CodeDomProvider/CreateProvider/source.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDom_CompilerInfo/VB/source.vb" id="Snippet5"::: @@ -1669,7 +1661,6 @@ ## Examples The following code example determines the implementation for an input language and displays the configured settings for the language provider. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDom_CompilerInfo/CPP/source.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CodeDomProvider/CreateProvider/source.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDom_CompilerInfo/VB/source.vb" id="Snippet6"::: diff --git a/xml/System.CodeDom.Compiler/CodeGeneratorOptions.xml b/xml/System.CodeDom.Compiler/CodeGeneratorOptions.xml index 3b8bd817533..84147d69c04 100644 --- a/xml/System.CodeDom.Compiler/CodeGeneratorOptions.xml +++ b/xml/System.CodeDom.Compiler/CodeGeneratorOptions.xml @@ -33,25 +33,24 @@ Represents a set of options used by a code generator. - is passed to the code generation methods of an implementation to specify options used during code generation. - - The property specifies the string to use for each spacing indentation. The property specifies the placement style for braces indicating the boundaries of code blocks. The property specifies whether to append an `else`, `catch`, or `finally` block, including brackets, at the closing line of each `if` or `try` block. The property specifies whether to insert blank lines between members. - - An implementation can provide custom code generation options which you can set or pass data to using the dictionary indexer, which a code generator can search through to locate additional code generation options. - + is passed to the code generation methods of an implementation to specify options used during code generation. + + The property specifies the string to use for each spacing indentation. The property specifies the placement style for braces indicating the boundaries of code blocks. The property specifies whether to append an `else`, `catch`, or `finally` block, including brackets, at the closing line of each `if` or `try` block. The property specifies whether to insert blank lines between members. + + An implementation can provide custom code generation options which you can set or pass data to using the dictionary indexer, which a code generator can search through to locate additional code generation options. + > [!NOTE] -> This class contains a link demand and an inheritance demand at the class level that applies to all members. A is thrown when either the immediate caller or the derived class does not have full-trust permission. For details about security demands, see [Link Demands](/dotnet/framework/misc/link-demands) and [Inheritance Demands](https://learn.microsoft.com/previous-versions/dotnet/netframework-4.0/x4yx82e6(v=vs.100)). - - - -## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeGeneratorOptionsExample/CPP/class1.cpp" id="Snippet1"::: +> This class contains a link demand and an inheritance demand at the class level that applies to all members. A is thrown when either the immediate caller or the derived class does not have full-trust permission. For details about security demands, see [Link Demands](/dotnet/framework/misc/link-demands) and [Inheritance Demands](https://learn.microsoft.com/previous-versions/dotnet/netframework-4.0/x4yx82e6(v=vs.100)). + + + +## Examples :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CodeGeneratorOptions/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeGeneratorOptionsExample/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeGeneratorOptionsExample/VB/class1.vb" id="Snippet1"::: + ]]> @@ -153,11 +152,11 @@ Gets or sets the style to use for bracing. A string containing the bracing style to use. - @@ -229,11 +228,11 @@ Gets or sets the string to use for indentations. A string containing the characters to use for indentations. - @@ -274,11 +273,11 @@ Gets or sets the object at the specified index. The object associated with the specified name. If no object associated with the specified name exists in the collection, . - @@ -321,11 +320,11 @@ to generate the members in the order in which they occur in the member collection; otherwise, . The default value of this property is . - property to inject #region blocks into code, thus changing the order. - + property to inject #region blocks into code, thus changing the order. + ]]> diff --git a/xml/System.CodeDom.Compiler/CompilerError.xml b/xml/System.CodeDom.Compiler/CompilerError.xml index 689e6be3d65..3d071f378ad 100644 --- a/xml/System.CodeDom.Compiler/CompilerError.xml +++ b/xml/System.CodeDom.Compiler/CompilerError.xml @@ -53,7 +53,6 @@ ## Examples The following example compiles a CodeDOM program graph and provides an example of how to programmatically access CompilerError data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic CompilerError Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerError/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic CompilerError Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.CodeDom.Compiler/CompilerErrorCollection.xml b/xml/System.CodeDom.Compiler/CompilerErrorCollection.xml index 744a1d0b94f..d4d62d63c1e 100644 --- a/xml/System.CodeDom.Compiler/CompilerErrorCollection.xml +++ b/xml/System.CodeDom.Compiler/CompilerErrorCollection.xml @@ -53,7 +53,6 @@ ## Examples The following example demonstrates how to use the 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/CompilerErrorCollectionExample/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerErrorCollection/Overview/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerErrorCollectionExample/VB/class1.vb" id="Snippet1"::: @@ -110,7 +109,6 @@ ## Examples The following example demonstrates how to create an empty instance of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompilerErrorCollectionExample/CPP/class1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerErrorCollection/Overview/class1.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerErrorCollectionExample/VB/class1.vb" id="Snippet2"::: @@ -231,7 +229,6 @@ ## Examples The following example demonstrates how to use the method to add a object to a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompilerErrorCollectionExample/CPP/class1.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerErrorCollection/Overview/class1.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerErrorCollectionExample/VB/class1.vb" id="Snippet3"::: @@ -289,7 +286,6 @@ ## Examples The following example demonstrates how to use the method overload to add an array of objects to a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompilerErrorCollectionExample/CPP/class1.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerErrorCollection/Overview/class1.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerErrorCollectionExample/VB/class1.vb" id="Snippet4"::: @@ -340,7 +336,6 @@ ## Examples The following example demonstrates how to use the method overload to add objects from one to another . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompilerErrorCollectionExample/CPP/class1.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerErrorCollection/Overview/class1.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerErrorCollectionExample/VB/class1.vb" id="Snippet4"::: @@ -393,7 +388,6 @@ ## Examples The following example uses the method to locate a specific object and determine the index value at which it was found. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompilerErrorCollectionExample/CPP/class1.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerErrorCollection/Overview/class1.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerErrorCollectionExample/VB/class1.vb" id="Snippet5"::: @@ -444,7 +438,6 @@ ## Examples The following example demonstrates how to use the method to copy the contents of a to an array, starting at the specified index value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompilerErrorCollectionExample/CPP/class1.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerErrorCollection/Overview/class1.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerErrorCollectionExample/VB/class1.vb" id="Snippet6"::: @@ -571,7 +564,6 @@ ## Examples The following example searches for a specific object and uses the method to determine the index value at which it was found. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompilerErrorCollectionExample/CPP/class1.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerErrorCollection/Overview/class1.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerErrorCollectionExample/VB/class1.vb" id="Snippet5"::: @@ -622,7 +614,6 @@ ## Examples The following example demonstrates how to use the method to insert a object into a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompilerErrorCollectionExample/CPP/class1.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerErrorCollection/Overview/class1.cs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerErrorCollectionExample/VB/class1.vb" id="Snippet8"::: @@ -710,7 +701,6 @@ ## Examples The following example demonstrates how to remove a item from a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompilerErrorCollectionExample/CPP/class1.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerErrorCollection/Overview/class1.cs" id="Snippet9"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerErrorCollectionExample/VB/class1.vb" id="Snippet9"::: diff --git a/xml/System.CodeDom.Compiler/CompilerInfo.xml b/xml/System.CodeDom.Compiler/CompilerInfo.xml index f28bec805e5..7e0e33d3ac4 100644 --- a/xml/System.CodeDom.Compiler/CompilerInfo.xml +++ b/xml/System.CodeDom.Compiler/CompilerInfo.xml @@ -32,31 +32,30 @@ Represents the configuration settings of a language provider. This class cannot be inherited. - class to determine whether a implementation is configured on the computer, or to examine the configuration and compiler settings for a specific language provider. - - The [<system.codedom> Element](/dotnet/framework/configure-apps/file-schema/compiler/system-codedom-element) in the machine configuration file contains the language provider and compiler configuration settings. Each configured language provider has a corresponding compiler configuration element. Each element defines the implementation type, supported language names, supported file name extensions, and compiler parameters. - - The .NET Framework defines the initial compiler settings in the machine configuration file. Developers and compiler vendors can add configuration settings for a new implementation. - - The class provides read-only access to these settings in the machine configuration file. Use the , , and members to examine the corresponding configuration attributes for a language provider. Use the method to obtain the compiler options and warning level attribute values for a language provider. - - For more details on language provider settings in the configuration file, see [Compiler and Language Provider Settings Schema](/dotnet/framework/configure-apps/file-schema/compiler/). - + class to determine whether a implementation is configured on the computer, or to examine the configuration and compiler settings for a specific language provider. + + The [<system.codedom> Element](/dotnet/framework/configure-apps/file-schema/compiler/system-codedom-element) in the machine configuration file contains the language provider and compiler configuration settings. Each configured language provider has a corresponding compiler configuration element. Each element defines the implementation type, supported language names, supported file name extensions, and compiler parameters. + + The .NET Framework defines the initial compiler settings in the machine configuration file. Developers and compiler vendors can add configuration settings for a new implementation. + + The class provides read-only access to these settings in the machine configuration file. Use the , , and members to examine the corresponding configuration attributes for a language provider. Use the method to obtain the compiler options and warning level attribute values for a language provider. + + For more details on language provider settings in the configuration file, see [Compiler and Language Provider Settings Schema](/dotnet/framework/configure-apps/file-schema/compiler/). + > [!NOTE] -> This class contains 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 code example displays language provider configuration settings. Command-line arguments are used to specify a language, file name extension, or provider type. For the given input, the example determines the corresponding language provider and displays the configured language compiler settings. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDom_CompilerInfo/CPP/source.cpp" id="Snippet1"::: +> This class contains 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 code example displays language provider configuration settings. Command-line arguments are used to specify a language, file name extension, or provider type. For the given input, the example determines the corresponding language provider and displays the configured language compiler settings. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CodeDomProvider/CreateProvider/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDom_CompilerInfo/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDom_CompilerInfo/VB/source.vb" id="Snippet1"::: + ]]> @@ -95,27 +94,26 @@ Gets the type of the configured implementation. A read-only instance that represents the configured language provider type. - implementation on the computer. The property value is a instance that represents a configured language provider implementation. - - - -## Examples - The following code example determines whether the input language has a configured implementation on the computer. If there is a provider configured for the specified language, the example displays the language provider configuration settings. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDom_CompilerInfo/CPP/source.cpp" id="Snippet7"::: + implementation on the computer. The property value is a instance that represents a configured language provider implementation. + + + +## Examples + The following code example determines whether the input language has a configured implementation on the computer. If there is a provider configured for the specified language, the example displays the language provider configuration settings. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CodeDomProvider/CreateProvider/source.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDom_CompilerInfo/VB/source.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDom_CompilerInfo/VB/source.vb" id="Snippet7"::: + ]]> The language provider is not configured on this computer. - Cannot locate the type because it is a or empty string. - - -or- - + Cannot locate the type because it is a or empty string. + + -or- + Cannot locate the type because the name for the cannot be found in the configuration file. @@ -159,24 +157,23 @@ Gets the configured compiler settings for the language provider implementation. A read-only instance that contains the compiler options and settings configured for the language provider. - method to examine the compiler settings of the instances returned by the and methods. - - The [<system.codedom> Element](/dotnet/framework/configure-apps/file-schema/compiler/system-codedom-element) in the machine configuration file contains the language provider and compiler configuration settings for each implementation on the computer. Each language provider configuration element can contain optional `compilerOptions` and `warningLevel` attributes. These attributes define the default values for the and properties. - - If the language provider configuration element does not define the `compilerOptions` attribute, the property value is an empty string (""). If the language provider configuration element does not define the `warningLevel` attribute, the property value is -1. - - - -## Examples - The following code example determines whether the input language has a configured implementation on the computer. If there is a provider configured for the specified language, the example displays the language provider configuration settings. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDom_CompilerInfo/CPP/source.cpp" id="Snippet7"::: + method to examine the compiler settings of the instances returned by the and methods. + + The [<system.codedom> Element](/dotnet/framework/configure-apps/file-schema/compiler/system-codedom-element) in the machine configuration file contains the language provider and compiler configuration settings for each implementation on the computer. Each language provider configuration element can contain optional `compilerOptions` and `warningLevel` attributes. These attributes define the default values for the and properties. + + If the language provider configuration element does not define the `compilerOptions` attribute, the property value is an empty string (""). If the language provider configuration element does not define the `warningLevel` attribute, the property value is -1. + + + +## Examples + The following code example determines whether the input language has a configured implementation on the computer. If there is a provider configured for the specified language, the example displays the language provider configuration settings. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CodeDomProvider/CreateProvider/source.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDom_CompilerInfo/VB/source.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDom_CompilerInfo/VB/source.vb" id="Snippet7"::: + ]]> @@ -224,22 +221,21 @@ Returns a instance for the current language provider settings. A CodeDOM provider associated with the language provider configuration. - method returns a instance for the current language provider settings. - - Use the method to get a implementation for a instance returned by the or method. - - - -## Examples - The following code example enumerates the language providers on the computer and displays the configuration and compiler settings for each language provider. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDom_CompilerInfo/CPP/source.cpp" id="Snippet8"::: + method returns a instance for the current language provider settings. + + Use the method to get a implementation for a instance returned by the or method. + + + +## Examples + The following code example enumerates the language providers on the computer and displays the configuration and compiler settings for each language provider. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CodeDomProvider/CreateProvider/source.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDom_CompilerInfo/VB/source.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDom_CompilerInfo/VB/source.vb" id="Snippet8"::: + ]]> @@ -280,13 +276,13 @@ Returns a instance for the current language provider settings and specified options. A CodeDOM provider associated with the language provider configuration and specified options. - method returns a instance for the current language provider settings and the specified provider options. For information about supported provider options, see the specific CodeDOM provider documentation. - - Use the method to get a implementation for a instance returned by the or method. - + method returns a instance for the current language provider settings and the specified provider options. For information about supported provider options, see the specific CodeDOM provider documentation. + + Use the method to get a implementation for a instance returned by the or method. + ]]> @@ -330,17 +326,17 @@ if is a object and its value is the same as this instance; otherwise, . - method. - - The two instances are considered equal if the values of the following properties are equal: - -- The property. - -- The , , and properties of the instance returned by the method. - + method. + + The two instances are considered equal if the values of the following properties are equal: + +- The property. + +- The , , and properties of the instance returned by the method. + ]]> @@ -386,20 +382,19 @@ Returns the file name extensions supported by the language provider. An array of file name extensions supported by the language provider. - implementation on the computer. Each configured language provider supports one or more file name extensions. For example, a might support the file name extensions ".cs" and ".c#". - - - -## Examples - The following code example enumerates the language providers on the computer and displays the configuration and compiler settings for each language provider. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDom_CompilerInfo/CPP/source.cpp" id="Snippet8"::: + implementation on the computer. Each configured language provider supports one or more file name extensions. For example, a might support the file name extensions ".cs" and ".c#". + + + +## Examples + The following code example enumerates the language providers on the computer and displays the configuration and compiler settings for each language provider. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CodeDomProvider/CreateProvider/source.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDom_CompilerInfo/VB/source.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDom_CompilerInfo/VB/source.vb" id="Snippet8"::: + ]]> @@ -438,22 +433,21 @@ Returns the hash code for the current instance. A 32-bit signed integer hash code for the current instance, suitable for use in hashing algorithms and data structures such as a hash table. - method. - - This method generates the same hash code for two objects that are equal according to the method. - - - -## Examples - The following code example creates an instance of the class. The example displays the provider name, hash code, and default file name extension for the new provider instance. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDom_CompilerInfo/CPP/source.cpp" id="Snippet3"::: + method. + + This method generates the same hash code for two objects that are equal according to the method. + + + +## Examples + The following code example creates an instance of the class. The example displays the provider name, hash code, and default file name extension for the new provider instance. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CodeDomProvider/CreateProvider/source.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDom_CompilerInfo/VB/source.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDom_CompilerInfo/VB/source.vb" id="Snippet3"::: + ]]> @@ -499,20 +493,19 @@ Gets the language names supported by the language provider. An array of language names supported by the language provider. - implementation on the computer. Each configured language provider supports one or more language names. For example, the object for a might return an array with the language names "c#", "cs", and "csharp". - - - -## Examples - The following code example enumerates the language providers on the computer and displays the configuration and compiler settings for each language provider. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDom_CompilerInfo/CPP/source.cpp" id="Snippet8"::: + implementation on the computer. Each configured language provider supports one or more language names. For example, the object for a might return an array with the language names "c#", "cs", and "csharp". + + + +## Examples + The following code example enumerates the language providers on the computer and displays the configuration and compiler settings for each language provider. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CodeDomProvider/CreateProvider/source.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDom_CompilerInfo/VB/source.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDom_CompilerInfo/VB/source.vb" id="Snippet8"::: + ]]> @@ -551,20 +544,19 @@ if the language provider implementation type is configured on the computer; otherwise, . - property to check the implementation before accessing the provider properties or methods. For example, after you get the language provider settings from the method, use the property to verify the provider type implementation before calling the method or using the property. - - - -## Examples - The following code example determines whether the input language has a configured implementation on the computer. If there is a provider configured for the specified language, the example displays the language provider configuration settings. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDom_CompilerInfo/CPP/source.cpp" id="Snippet7"::: + property to check the implementation before accessing the provider properties or methods. For example, after you get the language provider settings from the method, use the property to verify the provider type implementation before calling the method or using the property. + + + +## Examples + The following code example determines whether the input language has a configured implementation on the computer. If there is a provider configured for the specified language, the example displays the language provider configuration settings. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CodeDomProvider/CreateProvider/source.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDom_CompilerInfo/VB/source.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDom_CompilerInfo/VB/source.vb" id="Snippet7"::: + ]]> diff --git a/xml/System.CodeDom.Compiler/CompilerParameters.xml b/xml/System.CodeDom.Compiler/CompilerParameters.xml index b6cc8a9588f..1ceb20b2240 100644 --- a/xml/System.CodeDom.Compiler/CompilerParameters.xml +++ b/xml/System.CodeDom.Compiler/CompilerParameters.xml @@ -44,31 +44,30 @@ Represents the parameters used to invoke a compiler. - object represents the settings and options for an interface. - - If you are compiling an executable program, you must set the property to `true`. When the is set to `false`, the compiler will generate a class library. By default, a new is initialized with its property set to `false`. If you are compiling an executable from a CodeDOM graph, a must be defined in the graph. If there are multiple code entry points, you can indicate the class that defines the entry point to use by setting the name of the class to the property. - - You can specify a file name for the output assembly in the property. Otherwise, a default output file name will be used. To include debug information in a generated assembly, set the property to `true`. If your project references any assemblies, you must specify the assembly names as items in a set to the property of the used when invoking compilation. - - You can compile an assembly that is written to memory rather than disk by setting the property to `true`. When an assembly is generated in memory, your code can obtain a reference to the generated assembly from the property of a . If an assembly is written to disk, you can obtain the path to the generated assembly from the property of a . - - To specify a warning level at which to halt compilation, set the property to an integer that represents the warning level at which to halt compilation. You can also configure the compiler to halt compilation if warnings are encountered by setting the property to `true`. - - To specify a custom command-line arguments string to use when invoking the compilation process, set the string in the property. If a Win32 security token is required to invoke the compiler process, specify the token in the property. To include .NET Framework resource files in the compiled assembly, add the names of the resource files to the property. To reference .NET Framework resources in another assembly, add the names of the resource files to the property. To include a Win32 resource file in the compiled assembly, specify the name of the Win32 resource file in the property. - + object represents the settings and options for an interface. + + If you are compiling an executable program, you must set the property to `true`. When the is set to `false`, the compiler will generate a class library. By default, a new is initialized with its property set to `false`. If you are compiling an executable from a CodeDOM graph, a must be defined in the graph. If there are multiple code entry points, you can indicate the class that defines the entry point to use by setting the name of the class to the property. + + You can specify a file name for the output assembly in the property. Otherwise, a default output file name will be used. To include debug information in a generated assembly, set the property to `true`. If your project references any assemblies, you must specify the assembly names as items in a set to the property of the used when invoking compilation. + + You can compile an assembly that is written to memory rather than disk by setting the property to `true`. When an assembly is generated in memory, your code can obtain a reference to the generated assembly from the property of a . If an assembly is written to disk, you can obtain the path to the generated assembly from the property of a . + + To specify a warning level at which to halt compilation, set the property to an integer that represents the warning level at which to halt compilation. You can also configure the compiler to halt compilation if warnings are encountered by setting the property to `true`. + + To specify a custom command-line arguments string to use when invoking the compilation process, set the string in the property. If a Win32 security token is required to invoke the compiler process, specify the token in the property. To include .NET Framework resource files in the compiled assembly, add the names of the resource files to the property. To reference .NET Framework resources in another assembly, add the names of the resource files to the property. To include a Win32 resource file in the compiled assembly, specify the name of the Win32 resource file in the property. + > [!NOTE] > This class contains a link demand and an inheritance demand at the class level that applies to all members. A is thrown when either the immediate caller or the derived class does not have full-trust permission. For details about security demands, see [Link Demands](/dotnet/framework/misc/link-demands) and [Inheritance Demands](https://learn.microsoft.com/previous-versions/dotnet/netframework-4.0/x4yx82e6(v=vs.100)). - -## Examples - The following example builds a CodeDOM source graph for a simple Hello World program. The source is then saved to a file, compiled into an executable, and run. The `CompileCode` method illustrates how to use the class to specify various compiler settings and options. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompilerParametersExample/CPP/source.cpp" id="Snippet1"::: + +## Examples + The following example builds a CodeDOM source graph for a simple Hello World program. The source is then saved to a file, compiled into an executable, and run. The `CompileCode` method illustrates how to use the class to specify various compiler settings and options. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerParameters/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet1"::: + ]]> @@ -116,15 +115,14 @@ Initializes a new instance of the class. - to specify various compiler settings and options. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompilerParametersExample/CPP/source.cpp" id="Snippet2"::: + to specify various compiler settings and options. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerParameters/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: + ]]> @@ -292,19 +290,18 @@ Gets or sets optional command-line arguments to use when invoking the compiler. Any additional command-line arguments for the compiler. - typically includes this string on the command line when invoking a command-line compiler. By default, this property contains an empty string. -## Examples - The following example illustrates using to specify various compiler settings and options. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompilerParametersExample/CPP/source.cpp" id="Snippet2"::: +## Examples + The following example illustrates using to specify various compiler settings and options. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerParameters/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: + ]]> C# compiler options @@ -342,14 +339,14 @@ An typically includes this string o Gets or sets the name of the core or standard assembly that contains basic types such as , , or . The name of the core assembly that contains basic types. - property. - + property. + > [!NOTE] -> An or implementation may choose to ignore this property. - +> An or implementation may choose to ignore this property. + ]]> @@ -395,24 +392,23 @@ An typically includes this string o Gets the .NET resource files to include when compiling the assembly output. A collection that contains the file paths of .NET resources to include in the generated assembly. - method with the flag . - - Add one or more .NET resource file paths to the returned to embed the file resources in the compiled assembly. Adding a duplicate or invalid file path results in compilation errors; ensure that each string specifies a unique path to a valid .NET resource file. - + method with the flag . + + Add one or more .NET resource file paths to the returned to embed the file resources in the compiled assembly. Adding a duplicate or invalid file path results in compilation errors; ensure that each string specifies a unique path to a valid .NET resource file. + Use to include default or neutral culture .NET resources for an assembly; use the property to reference .NET resources in satellite assemblies. - -## Examples - The following example illustrates using to specify various compiler settings and options. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompilerParametersExample/CPP/source.cpp" id="Snippet2"::: + +## Examples + The following example illustrates using to specify various compiler settings and options. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerParameters/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: + ]]> @@ -496,20 +492,19 @@ An typically includes this string o if an executable should be generated; otherwise, . - to specify various compiler settings and options. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompilerParametersExample/CPP/source.cpp" id="Snippet2"::: + to specify various compiler settings and options. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerParameters/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: + ]]> @@ -557,15 +552,14 @@ An typically includes this string o if the compiler should generate the output in memory; otherwise, . - to specify various compiler settings and options. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompilerParametersExample/CPP/source.cpp" id="Snippet2"::: + to specify various compiler settings and options. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerParameters/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: + ]]> @@ -656,24 +650,23 @@ An typically includes this string o Gets the .NET resource files that are referenced in the current source. A collection that contains the file paths of .NET resources that are referenced by the source. - method with the flag . - - Add one or more .NET resource file paths to the returned to create links for the resources in the compiled assembly. Adding a duplicate or invalid file path results in compilation errors; ensure that each string specifies a unique path to a valid .NET resource file. - + method with the flag . + + Add one or more .NET resource file paths to the returned to create links for the resources in the compiled assembly. Adding a duplicate or invalid file path results in compilation errors; ensure that each string specifies a unique path to a valid .NET resource file. + Use to reference .NET resources in satellite assemblies, localized for a particular culture; use the property to embed the resources into the compiled assembly. - -## Examples - The following example illustrates using to specify various compiler settings and options. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompilerParametersExample/CPP/source.cpp" id="Snippet2"::: + +## Examples + The following example illustrates using to specify various compiler settings and options. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerParameters/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: + ]]> @@ -723,20 +716,19 @@ An typically includes this string o Gets or sets the name of the main class. The name of the main class. - to specify various compiler settings and options. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompilerParametersExample/CPP/source.cpp" id="Snippet2"::: + to specify various compiler settings and options. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerParameters/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: + ]]> @@ -783,15 +775,14 @@ An typically includes this string o Gets or sets the name of the output assembly. The name of the output assembly. - to specify various compiler settings and options. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompilerParametersExample/CPP/source.cpp" id="Snippet2"::: + to specify various compiler settings and options. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerParameters/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: + ]]> @@ -834,20 +825,19 @@ An typically includes this string o Gets the assemblies referenced by the current project. A collection that contains the assembly names that are referenced by the source to compile. - to import the assembly manifest and reference the assembly type information in the current project. - - - -## Examples - The following example illustrates using to specify various compiler settings and options. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompilerParametersExample/CPP/source.cpp" id="Snippet2"::: + to import the assembly manifest and reference the assembly type information in the current project. + + + +## Examples + The following example illustrates using to specify various compiler settings and options. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerParameters/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: + ]]> @@ -891,23 +881,22 @@ An typically includes this string o Gets or sets the collection that contains the temporary files. A collection that contains the temporary files. - property in the collection. The property is set if the collection is created using the constructor with the `keepFiles` parameter set to `true`. - + property in the collection. The property is set if the collection is created using the constructor with the `keepFiles` parameter set to `true`. + > [!NOTE] -> This class contains a link demand and an inheritance demand at the class level that applies to all members. A is thrown when either the immediate caller or the derived class does not have full-trust permission. For details about security demands, see [Link Demands](/dotnet/framework/misc/link-demands) and [Inheritance Demands](https://learn.microsoft.com/previous-versions/dotnet/netframework-4.0/x4yx82e6(v=vs.100)). - - - -## Examples - The following example illustrates using to specify various compiler settings and options. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompilerParametersExample/CPP/source.cpp" id="Snippet2"::: +> This class contains a link demand and an inheritance demand at the class level that applies to all members. A is thrown when either the immediate caller or the derived class does not have full-trust permission. For details about security demands, see [Link Demands](/dotnet/framework/misc/link-demands) and [Inheritance Demands](https://learn.microsoft.com/previous-versions/dotnet/netframework-4.0/x4yx82e6(v=vs.100)). + + + +## Examples + The following example illustrates using to specify various compiler settings and options. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerParameters/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: + ]]> @@ -955,15 +944,14 @@ An typically includes this string o if warnings should be treated as errors; otherwise, . - to specify various compiler settings and options. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompilerParametersExample/CPP/source.cpp" id="Snippet2"::: + to specify various compiler settings and options. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerParameters/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: + ]]> @@ -1044,15 +1032,14 @@ An typically includes this string o Gets or sets the warning level at which the compiler aborts compilation. The warning level at which the compiler aborts compilation. - to specify various compiler settings and options. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompilerParametersExample/CPP/source.cpp" id="Snippet2"::: + to specify various compiler settings and options. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerParameters/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: + ]]> @@ -1099,15 +1086,15 @@ An typically includes this string o Gets or sets the file name of a Win32 resource file to link into the compiled assembly. A Win32 resource file that will be linked into the compiled assembly. - to compile a Win32 resource file into the assembly. Use or to compile with .NET Framework resource files. - - Not all compilers support Win32 resource files, so you should test a code generator for this support before linking a resource file by calling the method with the flag . - + to compile a Win32 resource file into the assembly. Use or to compile with .NET Framework resource files. + + Not all compilers support Win32 resource files, so you should test a code generator for this support before linking a resource file by calling the method with the flag . + ]]> diff --git a/xml/System.CodeDom.Compiler/CompilerResults.xml b/xml/System.CodeDom.Compiler/CompilerResults.xml index 54d9ef8d0fa..51fce4c6f9b 100644 --- a/xml/System.CodeDom.Compiler/CompilerResults.xml +++ b/xml/System.CodeDom.Compiler/CompilerResults.xml @@ -40,35 +40,34 @@ Represents the results of compilation that are returned from a compiler. - interface implementation: - -- The property indicates the compiled assembly. - -- The property indicates the security evidence for the assembly. - -- The property indicates the path to the compiled assembly, if it was not generated only in memory. - -- The property indicates any compiler errors and warnings. - -- The property contains the compiler output messages. - -- The property indicates result code value returned by the compiler. - -- The property indicates the temporary files generated during compilation and linking. - + interface implementation: + +- The property indicates the compiled assembly. + +- The property indicates the security evidence for the assembly. + +- The property indicates the path to the compiled assembly, if it was not generated only in memory. + +- The property indicates any compiler errors and warnings. + +- The property contains the compiler output messages. + +- The property indicates result code value returned by the compiler. + +- The property indicates the temporary files generated during compilation and linking. + > [!NOTE] -> This class contains an inheritance demand at the class level that applies to all members. A is thrown when the derived class does not have full-trust permission. For details about inheritance demands, see [Inheritance Demands](https://learn.microsoft.com/previous-versions/dotnet/netframework-4.0/x4yx82e6(v=vs.100)). - - - -## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompilerResultsExample/CPP/class1.cpp" id="Snippet1"::: +> This class contains an inheritance demand at the class level that applies to all members. A is thrown when the derived class does not have full-trust permission. For details about inheritance demands, see [Inheritance Demands](https://learn.microsoft.com/previous-versions/dotnet/netframework-4.0/x4yx82e6(v=vs.100)). + + + +## Examples :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerResults/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerResultsExample/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerResultsExample/VB/class1.vb" id="Snippet1"::: + ]]> @@ -147,13 +146,13 @@ Gets or sets the compiled assembly. An that indicates the compiled assembly. - [!NOTE] -> The `get` accessor for the property calls the method to load the compiled assembly into the current application domain. After calling the `get` accessor, the compiled assembly cannot be deleted until the current is unloaded. - +> The `get` accessor for the property calls the method to load the compiled assembly into the current application domain. After calling the `get` accessor, the compiled assembly cannot be deleted until the current is unloaded. + ]]> @@ -197,11 +196,11 @@ Gets the collection of compiler errors and warnings. A that indicates the errors and warnings resulting from compilation, if any. - , so that user code to locate and display the code that generated an error or warning, where possible, can be implemented. - + , so that user code to locate and display the code that generated an error or warning, where possible, can be implemented. + ]]> @@ -282,11 +281,11 @@ Gets or sets the compiler's return value. The compiler's return value. - @@ -329,11 +328,11 @@ Gets the compiler output messages. A that contains the output messages. - diff --git a/xml/System.CodeDom.Compiler/GeneratedCodeAttribute.xml b/xml/System.CodeDom.Compiler/GeneratedCodeAttribute.xml index 9707254ac89..f343cff1dc2 100644 --- a/xml/System.CodeDom.Compiler/GeneratedCodeAttribute.xml +++ b/xml/System.CodeDom.Compiler/GeneratedCodeAttribute.xml @@ -64,20 +64,19 @@ Identifies code generated by a tool. This class cannot be inherited. - class can be used by code analysis tools to identify computer-generated code, and to provide an analysis based on the tool and the version of the tool that generated the code. - - - -## Examples - The following code example shows the use of the class to identify computer-generated code. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.codedom.compiler.generatedcodeattribute/cpp/source.cpp" id="Snippet1"::: + class can be used by code analysis tools to identify computer-generated code, and to provide an analysis based on the tool and the version of the tool that generated the code. + + + +## Examples + The following code example shows the use of the class to identify computer-generated code. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/GeneratedCodeAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.codedom.compiler.generatedcodeattribute/vb/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.codedom.compiler.generatedcodeattribute/vb/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.CodeDom.Compiler/GeneratorSupport.xml b/xml/System.CodeDom.Compiler/GeneratorSupport.xml index 8a69ffb148e..a3ca344c7c3 100644 --- a/xml/System.CodeDom.Compiler/GeneratorSupport.xml +++ b/xml/System.CodeDom.Compiler/GeneratorSupport.xml @@ -43,20 +43,19 @@ Defines identifiers used to determine whether a code generator supports certain types of code elements. - method of a code generator to determine whether the code generator supports generating certain types of code. - - - -## Examples - The following example illustrates using to specify various compiler settings and options. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CompilerParametersExample/CPP/source.cpp" id="Snippet2"::: + method of a code generator to determine whether the code generator supports generating certain types of code. + + + +## Examples + The following example illustrates using to specify various compiler settings and options. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/CompilerParameters/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CompilerParametersExample/VB/source.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.CodeDom.Compiler/IndentedTextWriter.xml b/xml/System.CodeDom.Compiler/IndentedTextWriter.xml index 11f61a19f4f..ce0e9982cd9 100644 --- a/xml/System.CodeDom.Compiler/IndentedTextWriter.xml +++ b/xml/System.CodeDom.Compiler/IndentedTextWriter.xml @@ -86,7 +86,6 @@ ## Examples The following code example demonstrates using an to write text at different levels of indentation. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IndentedTextWriterExample/CPP/form1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/IndentedTextWriter/Overview/form1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IndentedTextWriterExample/VB/form1.vb" id="Snippet1"::: @@ -210,7 +209,6 @@ ## Examples The following code example demonstrates creating an using a specified tab string. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IndentedTextWriterExample/CPP/form1.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/IndentedTextWriter/Overview/form1.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IndentedTextWriterExample/VB/form1.vb" id="Snippet3"::: @@ -583,7 +581,6 @@ ## Examples The following code example demonstrates setting the indentation level of an . The indentation level is the number of tab strings to prefix each line with. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IndentedTextWriterExample/CPP/form1.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/IndentedTextWriter/Overview/form1.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IndentedTextWriterExample/VB/form1.vb" id="Snippet3"::: @@ -2959,7 +2956,6 @@ ## Examples The following code example demonstrates writing a line without tab string indentations. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IndentedTextWriterExample/CPP/form1.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom.Compiler/IndentedTextWriter/Overview/form1.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IndentedTextWriterExample/VB/form1.vb" id="Snippet6"::: diff --git a/xml/System.CodeDom/CodeArgumentReferenceExpression.xml b/xml/System.CodeDom/CodeArgumentReferenceExpression.xml index e626e9f7acb..15500fe28c6 100644 --- a/xml/System.CodeDom/CodeArgumentReferenceExpression.xml +++ b/xml/System.CodeDom/CodeArgumentReferenceExpression.xml @@ -48,22 +48,21 @@ Represents a reference to the value of an argument passed to a method. - can be used in a method to reference the value of a parameter that has been passed to the method. + + The property specifies the name of the parameter to reference. + + + +## Examples + The following example code defines a method that invokes `Console.WriteLine` to output the string parameter passed to the method. A references the argument passed to the method by method parameter name. -## Remarks - can be used in a method to reference the value of a parameter that has been passed to the method. - - The property specifies the name of the parameter to reference. - - - -## Examples - The following example code defines a method that invokes `Console.WriteLine` to output the string parameter passed to the method. A references the argument passed to the method by method parameter name. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeArgumentReferenceExpressionExample/CPP/codeargumentreferenceexpressionexample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeArgumentReferenceExpression/Overview/codeargumentreferenceexpressionexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeArgumentReferenceExpressionExample/VB/codeargumentreferenceexpressionexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeArgumentReferenceExpressionExample/VB/codeargumentreferenceexpressionexample.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.CodeDom/CodeArrayCreateExpression.xml b/xml/System.CodeDom/CodeArrayCreateExpression.xml index 7b4e654286d..0a52d56a6f8 100644 --- a/xml/System.CodeDom/CodeArrayCreateExpression.xml +++ b/xml/System.CodeDom/CodeArrayCreateExpression.xml @@ -48,24 +48,23 @@ Represents an expression that creates an array. - can be used to represent a code expression that creates an array. Expressions that create an array should specify either a number of elements, or a list of expressions to use to initialize the array. + + Most arrays can be initialized immediately following declaration. The property can be set to the expression to use to initialize the array. + + A only directly supports creating single-dimension arrays. If a language allows arrays of arrays, it is possible to create them by nesting a within a . Not all languages support arrays of arrays. You can check whether an for a language declares support for nested arrays by calling with the flag. + + + +## Examples + The following code uses a to create an array of integers with 10 indexes. -## Remarks - can be used to represent a code expression that creates an array. Expressions that create an array should specify either a number of elements, or a list of expressions to use to initialize the array. - - Most arrays can be initialized immediately following declaration. The property can be set to the expression to use to initialize the array. - - A only directly supports creating single-dimension arrays. If a language allows arrays of arrays, it is possible to create them by nesting a within a . Not all languages support arrays of arrays. You can check whether an for a language declares support for nested arrays by calling with the flag. - - - -## Examples - The following code uses a to create an array of integers with 10 indexes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeArrayCreateExpressionSnippet/CPP/codearraycreateexpressionsnippet.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeArrayCreateExpression/Overview/codearraycreateexpressionsnippet.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeArrayCreateExpressionSnippet/VB/codearraycreateexpressionsnippet.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeArrayCreateExpressionSnippet/VB/codearraycreateexpressionsnippet.vb" id="Snippet1"::: + ]]> @@ -621,11 +620,11 @@ Gets or sets the expression that indicates the size of the array. A that indicates the size of the array. - . - + . + ]]> diff --git a/xml/System.CodeDom/CodeArrayIndexerExpression.xml b/xml/System.CodeDom/CodeArrayIndexerExpression.xml index b45e8d7716e..61f2989f303 100644 --- a/xml/System.CodeDom/CodeArrayIndexerExpression.xml +++ b/xml/System.CodeDom/CodeArrayIndexerExpression.xml @@ -48,20 +48,19 @@ Represents a reference to an index of an array. - can be used to represent a reference to an index of an array of one or more dimensions. Use for representing a reference to an index of a code (non-array) indexer. The property indicates the indexer object. The property indicates either a single index within the target array, or a set of indexes that together specify a specific intersection of indexes across the dimensions of the array. + + + +## Examples + The following code creates a that references index 5 of an array of integers named `x` : -## Remarks - can be used to represent a reference to an index of an array of one or more dimensions. Use for representing a reference to an index of a code (non-array) indexer. The property indicates the indexer object. The property indicates either a single index within the target array, or a set of indexes that together specify a specific intersection of indexes across the dimensions of the array. - - - -## Examples - The following code creates a that references index 5 of an array of integers named `x` : - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeArrayIndexerExpressionSnippet/CPP/codearrayindexerexpressionsnippet.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeArrayIndexerExpression/Overview/codearrayindexerexpressionsnippet.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeArrayIndexerExpressionSnippet/VB/codearrayindexerexpressionsnippet.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeArrayIndexerExpressionSnippet/VB/codearrayindexerexpressionsnippet.vb" id="Snippet1"::: + ]]> @@ -186,11 +185,11 @@ Gets or sets the index or indexes of the indexer expression. A that indicates the index or indexes of the indexer expression. - can contain a that specifies a single index within the target array, or multiple objects that together specify a specific intersection of indexes across the dimensions of the array. - + can contain a that specifies a single index within the target array, or multiple objects that together specify a specific intersection of indexes across the dimensions of the array. + ]]> @@ -237,11 +236,11 @@ Gets or sets the target object of the array indexer. A that represents the array being indexed. - , a , or a . - + , a , or a . + ]]> diff --git a/xml/System.CodeDom/CodeAssignStatement.xml b/xml/System.CodeDom/CodeAssignStatement.xml index 5f3778c87ec..2492271e274 100644 --- a/xml/System.CodeDom/CodeAssignStatement.xml +++ b/xml/System.CodeDom/CodeAssignStatement.xml @@ -48,20 +48,19 @@ Represents a simple assignment statement. - can be used to represent a statement that assigns the value of an object to another object, or a reference to another reference. Simple assignment statements are usually of the form " `value1` = `value2` ", where `value1` is the object being assigned to, and `value2` is being assigned. The property indicates the object to assign to. The property indicates the object to assign. - - - -## Examples - The following code creates a that assigns the value 10 to an integer variable named `i` : - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeAssignStatement/CPP/codeassignstatementsnippet.cpp" id="Snippet1"::: + can be used to represent a statement that assigns the value of an object to another object, or a reference to another reference. Simple assignment statements are usually of the form " `value1` = `value2` ", where `value1` is the object being assigned to, and `value2` is being assigned. The property indicates the object to assign to. The property indicates the object to assign. + + + +## Examples + The following code creates a that assigns the value 10 to an integer variable named `i`: + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeAssignStatement/Overview/codeassignstatementsnippet.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAssignStatement/VB/codeassignstatementsnippet.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAssignStatement/VB/codeassignstatementsnippet.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.CodeDom/CodeAttachEventStatement.xml b/xml/System.CodeDom/CodeAttachEventStatement.xml index 60f8b43b556..7b383e1dd96 100644 --- a/xml/System.CodeDom/CodeAttachEventStatement.xml +++ b/xml/System.CodeDom/CodeAttachEventStatement.xml @@ -48,20 +48,19 @@ Represents a statement that attaches an event-handler delegate to an event. - can be used to represent a statement that adds an event-handler delegate for an event. The property indicates the event to attach the event handler to. The property indicates the event handler to attach. + + + +## Examples + The following example code demonstrates use of a to attach an event handler with an event. -## Remarks - can be used to represent a statement that adds an event-handler delegate for an event. The property indicates the event to attach the event handler to. The property indicates the event handler to attach. - - - -## Examples - The following example code demonstrates use of a to attach an event handler with an event. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeAttachEventStatementExample/CPP/codeattacheventstatementexample.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeAttachEventStatement/Overview/codeattacheventstatementexample.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttachEventStatementExample/VB/codeattacheventstatementexample.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttachEventStatementExample/VB/codeattacheventstatementexample.vb" id="Snippet3"::: + ]]> diff --git a/xml/System.CodeDom/CodeAttributeArgument.xml b/xml/System.CodeDom/CodeAttributeArgument.xml index 80c49221838..9d92196d3fb 100644 --- a/xml/System.CodeDom/CodeAttributeArgument.xml +++ b/xml/System.CodeDom/CodeAttributeArgument.xml @@ -48,26 +48,25 @@ Represents an argument used in a metadata attribute declaration. - can be used to represent either the value for a single argument of an attribute constructor, or a value with which to initialize a property of the attribute. + + The property indicates the value of the argument. The property, when used, indicates the name of a property of the attribute to which to assign the value. + + Attribute declarations are frequently initialized with a number of arguments that are passed into the constructor of the attribute at run time. To provide arguments to the constructor for an attribute, add a for each argument to the collection of a . Only the property of each needs to be initialized. The order of arguments within the collection must correspond to the order of arguments in the method signature of the constructor for the attribute. + + You can also set properties of the attribute that are not available through the constructor by providing a that indicates the name of the property to set, along with the value to set. + + + +## Examples + The following code creates a class, and adds code attributes to declare that the class is serializable and obsolete. -## Remarks - can be used to represent either the value for a single argument of an attribute constructor, or a value with which to initialize a property of the attribute. - - The property indicates the value of the argument. The property, when used, indicates the name of a property of the attribute to which to assign the value. - - Attribute declarations are frequently initialized with a number of arguments that are passed into the constructor of the attribute at run time. To provide arguments to the constructor for an attribute, add a for each argument to the collection of a . Only the property of each needs to be initialized. The order of arguments within the collection must correspond to the order of arguments in the method signature of the constructor for the attribute. - - You can also set properties of the attribute that are not available through the constructor by providing a that indicates the name of the property to set, along with the value to set. - - - -## Examples - The following code creates a class, and adds code attributes to declare that the class is serializable and obsolete. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codeattributeargument/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeAttributeArgument/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.codedom.codeattributeargument/vb/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.codedom.codeattributeargument/vb/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.CodeDom/CodeAttributeArgumentCollection.xml b/xml/System.CodeDom/CodeAttributeArgumentCollection.xml index a7c14c70ef8..62d2a06ba15 100644 --- a/xml/System.CodeDom/CodeAttributeArgumentCollection.xml +++ b/xml/System.CodeDom/CodeAttributeArgumentCollection.xml @@ -48,20 +48,19 @@ Represents a collection of objects. - class provides a simple collection object that can be used to store a set of objects. - - - -## Examples - The following example demonstrates the use of the class methods. The example creates a new instance of the class and uses the 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/CodeAttributeArgumentCollectionExample/CPP/class1.cpp" id="Snippet1"::: + class provides a simple collection object that can be used to store a set of objects. + + + +## Examples + The following example demonstrates the use of the class methods. The example creates a new instance of the class and uses the methods to add statements to the collection, return their index, and add or remove attributes at a specific index point. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeAttributeArgumentCollection/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/VB/class1.vb" id="Snippet1"::: + ]]> @@ -219,15 +218,14 @@ Adds the specified object to the collection. The index at which the new element was inserted. - object to a instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/CPP/class1.cpp" id="Snippet3"::: + object to a instance. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeAttributeArgumentCollection/Overview/class1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/VB/class1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/VB/class1.vb" id="Snippet3"::: + ]]> @@ -277,15 +275,14 @@ An array of type that contains the objects to add to the collection. Copies the elements of the specified array to the end of the collection. - method overload to add the members of a array to a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/CPP/class1.cpp" id="Snippet4"::: + method overload to add the members of a array to a . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeAttributeArgumentCollection/Overview/class1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/VB/class1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/VB/class1.vb" id="Snippet4"::: + ]]> @@ -328,15 +325,14 @@ A that contains the objects to add to the collection. Copies the contents of another object to the end of the collection. - method overload to add the members of one object to another . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/CPP/class1.cpp" id="Snippet4"::: + method overload to add the members of one object to another . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeAttributeArgumentCollection/Overview/class1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/VB/class1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/VB/class1.vb" id="Snippet4"::: + ]]> @@ -381,15 +377,14 @@ if the collection contains the specified object; otherwise, . - method to search for the presence of a specific object in a and gets the index value at which it was found. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/CPP/class1.cpp" id="Snippet5"::: + method to search for the presence of a specific object in a and gets the index value at which it was found. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeAttributeArgumentCollection/Overview/class1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/VB/class1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/VB/class1.vb" id="Snippet5"::: + ]]> @@ -431,21 +426,20 @@ The index of the array at which to begin inserting. Copies the collection objects to a one-dimensional instance beginning at the specified index. - object to a array beginning at a specified index value. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/CPP/class1.cpp" id="Snippet6"::: + object to a array beginning at a specified index value. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeAttributeArgumentCollection/Overview/class1.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/VB/class1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/VB/class1.vb" id="Snippet6"::: + ]]> - The destination array is multidimensional. - - -or- - + The destination array is multidimensional. + + -or- + The number of elements in the is greater than the available space between the index of the target array specified by the parameter and the end of the target array. The parameter is . The parameter is less than the target array's minimum index. @@ -487,15 +481,14 @@ Gets the index of the specified object in the collection, if it exists in the collection. The index of the specified object, if found, in the collection; otherwise, -1. - object and uses the method to get the index value at which it was found. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/CPP/class1.cpp" id="Snippet5"::: + object and uses the method to get the index value at which it was found. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeAttributeArgumentCollection/Overview/class1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/VB/class1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/VB/class1.vb" id="Snippet5"::: + ]]> @@ -538,15 +531,14 @@ The object to insert. Inserts the specified object into the collection at the specified index. - method to add a object to a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/CPP/class1.cpp" id="Snippet8"::: + method to add a object to a . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeAttributeArgumentCollection/Overview/class1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/VB/class1.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/VB/class1.vb" id="Snippet8"::: + ]]> @@ -587,11 +579,11 @@ Gets or sets the object at the specified index in the collection. A at each valid index. - The parameter is outside the valid range of indexes for the collection. @@ -632,15 +624,14 @@ The object to remove from the collection. Removes the specified object from the collection. - method to delete a object from a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/CPP/class1.cpp" id="Snippet9"::: + method to delete a object from a . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeAttributeArgumentCollection/Overview/class1.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/VB/class1.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeArgumentCollectionExample/VB/class1.vb" id="Snippet9"::: + ]]> The specified object is not found in the collection. diff --git a/xml/System.CodeDom/CodeAttributeDeclaration.xml b/xml/System.CodeDom/CodeAttributeDeclaration.xml index ccc34ca63bd..fdd00a51158 100644 --- a/xml/System.CodeDom/CodeAttributeDeclaration.xml +++ b/xml/System.CodeDom/CodeAttributeDeclaration.xml @@ -48,20 +48,19 @@ Represents an attribute declaration. - can be used to represent an expression that declares an attribute. The attribute name and the arguments for the attribute are stored as properties of the object. A can be used to represent each argument for the attribute. + + + +## Examples + The following code example creates a that declares a with an argument of `false`: -## Remarks - A can be used to represent an expression that declares an attribute. The attribute name and the arguments for the attribute are stored as properties of the object. A can be used to represent each argument for the attribute. - - - -## Examples - The following code example creates a that declares a with an argument of `false`: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codeattributedeclaration/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeAttributeDeclaration/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.codedom.codeattributedeclaration/vb/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.codedom.codeattributedeclaration/vb/source.vb" id="Snippet1"::: + ]]> @@ -144,11 +143,11 @@ The that identifies the attribute. Initializes a new instance of the class using the specified code type reference. - and properties. - + and properties. + ]]> @@ -228,11 +227,11 @@ An array of type that contains the arguments for the attribute. Initializes a new instance of the class using the specified code type reference and arguments. - and properties, and the `arguments` parameter is used to set the property for the . - + and properties, and the `arguments` parameter is used to set the property for the . + ]]> diff --git a/xml/System.CodeDom/CodeAttributeDeclarationCollection.xml b/xml/System.CodeDom/CodeAttributeDeclarationCollection.xml index fbc92db378c..9c20a0e4c0e 100644 --- a/xml/System.CodeDom/CodeAttributeDeclarationCollection.xml +++ b/xml/System.CodeDom/CodeAttributeDeclarationCollection.xml @@ -48,20 +48,19 @@ Represents a collection of objects. - class provides a simple collection object that can be used to store a set of objects. + + + +## Examples + The following example demonstrates the use of the class methods. -## Remarks - The class provides a simple collection object that can be used to store a set of objects. - - - -## Examples - The following example demonstrates the use of the class methods. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeAttributeDeclarationCollection/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/VB/class1.vb" id="Snippet1"::: + ]]> @@ -219,15 +218,14 @@ Adds a object with the specified value to the collection. The index at which the new element was inserted. - object to a instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/CPP/class1.cpp" id="Snippet3"::: + object to a instance. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeAttributeDeclarationCollection/Overview/class1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/VB/class1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/VB/class1.vb" id="Snippet3"::: + ]]> @@ -277,15 +275,14 @@ An array of type that contains the objects to add to the collection. Copies the elements of the specified array to the end of the collection. - method overload to add an array of objects to a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/CPP/class1.cpp" id="Snippet4"::: + method overload to add an array of objects to a . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeAttributeDeclarationCollection/Overview/class1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/VB/class1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/VB/class1.vb" id="Snippet4"::: + ]]> @@ -328,15 +325,14 @@ A that contains the objects to add to the collection. Copies the contents of another object to the end of the collection. - method overload to add the members of one to another. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/CPP/class1.cpp" id="Snippet4"::: + method overload to add the members of one to another. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeAttributeDeclarationCollection/Overview/class1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/VB/class1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/VB/class1.vb" id="Snippet4"::: + ]]> @@ -381,15 +377,14 @@ if the collection contains the specified object; otherwise, . - method to search for the presence of a specific instance and gets the index value at which it was found. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/CPP/class1.cpp" id="Snippet5"::: + method to search for the presence of a specific instance and gets the index value at which it was found. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeAttributeDeclarationCollection/Overview/class1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/VB/class1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/VB/class1.vb" id="Snippet5"::: + ]]> @@ -432,21 +427,20 @@ The index of the array at which to begin inserting. Copies the collection objects to a one-dimensional instance beginning at the specified index. - to an array beginning at index 0. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/CPP/class1.cpp" id="Snippet6"::: + to an array beginning at index 0. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeAttributeDeclarationCollection/Overview/class1.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/VB/class1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/VB/class1.vb" id="Snippet6"::: + ]]> - The destination array is multidimensional. - - -or- - + The destination array is multidimensional. + + -or- + The number of elements in the is greater than the available space between the index of the target array specified by the parameter and the end of the target array. The parameter is . The parameter is less than the target array's minimum index. @@ -489,15 +483,14 @@ Gets the index of the specified object in the collection, if it exists in the collection. The index in the collection of the specified object, if found; otherwise, -1. - instance and uses the method to get the index value at which it was found. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/CPP/class1.cpp" id="Snippet5"::: + instance and uses the method to get the index value at which it was found. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeAttributeDeclarationCollection/Overview/class1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/VB/class1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/VB/class1.vb" id="Snippet5"::: + ]]> @@ -540,15 +533,14 @@ The object to insert. Inserts the specified object into the collection at the specified index. - method to add a object to the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/CPP/class1.cpp" id="Snippet8"::: + method to add a object to the . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeAttributeDeclarationCollection/Overview/class1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/VB/class1.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/VB/class1.vb" id="Snippet8"::: + ]]> @@ -590,11 +582,11 @@ Gets or sets the object at the specified index. A at each valid index. - The parameter is outside the valid range of indexes for the collection. @@ -636,15 +628,14 @@ The object to remove from the collection. Removes the specified object from the collection. - method to delete a object from the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/CPP/class1.cpp" id="Snippet9"::: + method to delete a object from the . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeAttributeDeclarationCollection/Overview/class1.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/VB/class1.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttributeDeclarationCollectionExample/VB/class1.vb" id="Snippet9"::: + ]]> The specified object is not found in the collection. diff --git a/xml/System.CodeDom/CodeBaseReferenceExpression.xml b/xml/System.CodeDom/CodeBaseReferenceExpression.xml index e53b84e772d..1ce713d078e 100644 --- a/xml/System.CodeDom/CodeBaseReferenceExpression.xml +++ b/xml/System.CodeDom/CodeBaseReferenceExpression.xml @@ -48,20 +48,19 @@ Represents a reference to the base class. - represents a reference to the base class of the current class. The base class is sometimes also known as the parent class or super class. References to the base class are commonly used when overriding a method or property in order to call the base class's implementation of that method or property. For example, an override of a ToString method that appends a string to the end of the base class's `ToString` method would call base.ToString() in C#. + + + +## Examples + This example demonstrates using a to reference a base class method. -## Remarks - represents a reference to the base class of the current class. The base class is sometimes also known as the parent class or super class. References to the base class are commonly used when overriding a method or property in order to call the base class's implementation of that method or property. For example, an override of a ToString method that appends a string to the end of the base class's `ToString` method would call base.ToString() in C#. - - - -## Examples - This example demonstrates using a to reference a base class method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeBaseReferenceExpressionExample/CPP/codebasereferenceexpressionexample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeBaseReferenceExpression/Overview/codebasereferenceexpressionexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeBaseReferenceExpressionExample/VB/codebasereferenceexpressionexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeBaseReferenceExpressionExample/VB/codebasereferenceexpressionexample.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.CodeDom/CodeBinaryOperatorExpression.xml b/xml/System.CodeDom/CodeBinaryOperatorExpression.xml index e3d8d6e593b..62829f920af 100644 --- a/xml/System.CodeDom/CodeBinaryOperatorExpression.xml +++ b/xml/System.CodeDom/CodeBinaryOperatorExpression.xml @@ -48,20 +48,19 @@ Represents an expression that consists of a binary operation between two expressions. - can be used to represent code expressions that include a binary operator. Some examples of binary operators are equality (`==`), addition (`+`), and bitwise (`|`) operators. The enumeration represents a set of basic, commonly used binary operators that are supported in many languages. + + + +## Examples + This example demonstrates use of a to add two numbers together. -## Remarks - can be used to represent code expressions that include a binary operator. Some examples of binary operators are equality (`==`), addition (`+`), and bitwise (`|`) operators. The enumeration represents a set of basic, commonly used binary operators that are supported in many languages. - - - -## Examples - This example demonstrates use of a to add two numbers together. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeBinaryOperatorExpression/CPP/codebinaryoperatorexpressionexample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeBinaryOperatorExpression/Overview/codebinaryoperatorexpressionexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeBinaryOperatorExpression/VB/codebinaryoperatorexpressionexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeBinaryOperatorExpression/VB/codebinaryoperatorexpressionexample.vb" id="Snippet2"::: + ]]> @@ -241,11 +240,11 @@ Gets or sets the operator in the binary operator expression. A that indicates the type of operator in the expression. - enumeration. - + enumeration. + ]]> diff --git a/xml/System.CodeDom/CodeCastExpression.xml b/xml/System.CodeDom/CodeCastExpression.xml index 053666ff78e..6d791e22f2a 100644 --- a/xml/System.CodeDom/CodeCastExpression.xml +++ b/xml/System.CodeDom/CodeCastExpression.xml @@ -48,22 +48,21 @@ Represents an expression cast to a data type or interface. - can be used to represent an expression cast to a different data type or interface. + + The property indicates the to cast. The property indicates the type to cast to. + + + +## Examples + This example demonstrates using a to cast a `System.Int32` value to a `System.Int64` data type. -## Remarks - can be used to represent an expression cast to a different data type or interface. - - The property indicates the to cast. The property indicates the type to cast to. - - - -## Examples - This example demonstrates using a to cast a `System.Int32` value to a `System.Int64` data type. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeCastExpressionExample/CPP/codecastexpressionexample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCastExpression/Overview/codecastexpressionexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCastExpressionExample/VB/codecastexpressionexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCastExpressionExample/VB/codecastexpressionexample.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.CodeDom/CodeCatchClause.xml b/xml/System.CodeDom/CodeCatchClause.xml index 610a0108bfc..db6cd56439f 100644 --- a/xml/System.CodeDom/CodeCatchClause.xml +++ b/xml/System.CodeDom/CodeCatchClause.xml @@ -48,22 +48,21 @@ Represents a exception block of a statement. - can be used to represent a `catch` exception block of a `try/catch` statement. + + The property specifies the type of exception to catch. The property specifies a name for the variable representing the exception that has been caught. The collection property contains the statements for the `catch` block. + + + +## Examples + The following example code demonstrates using objects to define exception handling clauses of a try...catch block. -## Remarks - can be used to represent a `catch` exception block of a `try/catch` statement. - - The property specifies the type of exception to catch. The property specifies a name for the variable representing the exception that has been caught. The collection property contains the statements for the `catch` block. - - - -## Examples - The following example code demonstrates using objects to define exception handling clauses of a try...catch block. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTryCatchFinallyExample/CPP/codetrycatchfinallyexample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCatchClause/Overview/codetrycatchfinallyexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTryCatchFinallyExample/VB/codetrycatchfinallyexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTryCatchFinallyExample/VB/codetrycatchfinallyexample.vb" id="Snippet2"::: + ]]> @@ -282,11 +281,11 @@ Gets or sets the type of the exception to handle with the catch block. A that indicates the type of the exception to handle. - . - + . + ]]> @@ -330,11 +329,11 @@ Gets or sets the variable name of the exception that the clause handles. The name for the exception variable that the clause handles. - diff --git a/xml/System.CodeDom/CodeCatchClauseCollection.xml b/xml/System.CodeDom/CodeCatchClauseCollection.xml index 6007880c596..515dcfdbcfd 100644 --- a/xml/System.CodeDom/CodeCatchClauseCollection.xml +++ b/xml/System.CodeDom/CodeCatchClauseCollection.xml @@ -48,20 +48,19 @@ Represents a collection of objects. - class provides a simple collection object that can be used to store a set of objects. + + + +## Examples + The following example demonstrates the use of the class methods. The example creates a new instance of the class and uses the methods to add statements to the collection, return their index, and add or remove attributes at a specific index point. -## Remarks - The class provides a simple collection object that can be used to store a set of objects. - - - -## Examples - The following example demonstrates the use of the class methods. The example creates a new instance of the class and uses the 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/CodeCatchClauseCollectionExample/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCatchClauseCollection/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCatchClauseCollectionExample/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCatchClauseCollectionExample/VB/class1.vb" id="Snippet1"::: + ]]> @@ -219,15 +218,14 @@ Adds the specified object to the collection. The index at which the new element was inserted. - object to the instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeCatchClauseCollectionExample/CPP/class1.cpp" id="Snippet3"::: + object to the instance. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCatchClauseCollection/Overview/class1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCatchClauseCollectionExample/VB/class1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCatchClauseCollectionExample/VB/class1.vb" id="Snippet3"::: + ]]> @@ -277,15 +275,14 @@ An array of type that contains the objects to add to the collection. Copies the elements of the specified array to the end of the collection. - method overload to add the members of an array of objects to the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeCatchClauseCollectionExample/CPP/class1.cpp" id="Snippet4"::: + method overload to add the members of an array of objects to the . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCatchClauseCollection/Overview/class1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCatchClauseCollectionExample/VB/class1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCatchClauseCollectionExample/VB/class1.vb" id="Snippet4"::: + ]]> @@ -328,15 +325,14 @@ A that contains the objects to add to the collection. Copies the contents of another object to the end of the collection. - method overload to add the members of one object to another . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeCatchClauseCollectionExample/CPP/class1.cpp" id="Snippet4"::: + method overload to add the members of one object to another . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCatchClauseCollection/Overview/class1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCatchClauseCollectionExample/VB/class1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCatchClauseCollectionExample/VB/class1.vb" id="Snippet4"::: + ]]> @@ -381,15 +377,14 @@ if the collection contains the specified object; otherwise, . - method to search for the presence of a specific instance and gets the index value at which it was found. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeCatchClauseCollectionExample/CPP/class1.cpp" id="Snippet5"::: + method to search for the presence of a specific instance and gets the index value at which it was found. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCatchClauseCollection/Overview/class1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCatchClauseCollectionExample/VB/class1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCatchClauseCollectionExample/VB/class1.vb" id="Snippet5"::: + ]]> @@ -432,21 +427,20 @@ The index of the array at which to begin inserting. Copies the collection objects to a one-dimensional instance beginning at the specified index. - to a array beginning at index value 0. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeCatchClauseCollectionExample/CPP/class1.cpp" id="Snippet6"::: + to a array beginning at index value 0. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCatchClauseCollection/Overview/class1.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCatchClauseCollectionExample/VB/class1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCatchClauseCollectionExample/VB/class1.vb" id="Snippet6"::: + ]]> - The destination array is multidimensional. - - -or- - + The destination array is multidimensional. + + -or- + The number of elements in the is greater than the available space between the index of the target array specified by the parameter and the end of the target array. The parameter is . The parameter is less than the target array's minimum index. @@ -489,15 +483,14 @@ Gets the index of the specified object in the collection, if it exists in the collection. The index of the specified object, if found, in the collection; otherwise, -1. - object and uses the method to get the index value at which it was found. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeCatchClauseCollectionExample/CPP/class1.cpp" id="Snippet5"::: + object and uses the method to get the index value at which it was found. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCatchClauseCollection/Overview/class1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCatchClauseCollectionExample/VB/class1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCatchClauseCollectionExample/VB/class1.vb" id="Snippet5"::: + ]]> @@ -540,15 +533,14 @@ The object to insert. Inserts the specified object into the collection at the specified index. - method to add a object to a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeCatchClauseCollectionExample/CPP/class1.cpp" id="Snippet8"::: + method to add a object to a . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCatchClauseCollection/Overview/class1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCatchClauseCollectionExample/VB/class1.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCatchClauseCollectionExample/VB/class1.vb" id="Snippet8"::: + ]]> @@ -590,11 +582,11 @@ Gets or sets the object at the specified index in the collection. A object at each valid index. - The parameter is outside the valid range of indexes for the collection. @@ -636,15 +628,14 @@ The object to remove from the collection. Removes the specified object from the collection. - method to delete a object from a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeCatchClauseCollectionExample/CPP/class1.cpp" id="Snippet9"::: + method to delete a object from a . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCatchClauseCollection/Overview/class1.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCatchClauseCollectionExample/VB/class1.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCatchClauseCollectionExample/VB/class1.vb" id="Snippet9"::: + ]]> The specified object is not found in the collection. diff --git a/xml/System.CodeDom/CodeComment.xml b/xml/System.CodeDom/CodeComment.xml index 9dff369c555..04cbc8f23c2 100644 --- a/xml/System.CodeDom/CodeComment.xml +++ b/xml/System.CodeDom/CodeComment.xml @@ -48,24 +48,23 @@ Represents a comment. - can be used to represent a single line comment. + + A can contain a and allows it to be treated as a statement and generated as code within a collection of statements. Multi-line comments can be represented with multiple objects. + + To include a comment in a CodeDOM graph that can be generated to source code, add a to a , and add this to the statements collection of a or to the comments collection of a or any object that derives from . + + + +## Examples + This example demonstrates using a to represent a comment in source code. -## Remarks - can be used to represent a single line comment. - - A can contain a and allows it to be treated as a statement and generated as code within a collection of statements. Multi-line comments can be represented with multiple objects. - - To include a comment in a CodeDOM graph that can be generated to source code, add a to a , and add this to the statements collection of a or to the comments collection of a or any object that derives from . - - - -## Examples - This example demonstrates using a to represent a comment in source code. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeCommentExample/CPP/codecommentexample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeComment/Overview/codecommentexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCommentExample/VB/codecommentexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCommentExample/VB/codecommentexample.vb" id="Snippet2"::: + ]]> @@ -231,11 +230,11 @@ if the comment is a documentation comment; otherwise, . - @@ -278,11 +277,11 @@ Gets or sets the text of the comment. A string containing the comment text. - objects should be defined. - + objects should be defined. + ]]> diff --git a/xml/System.CodeDom/CodeCommentStatement.xml b/xml/System.CodeDom/CodeCommentStatement.xml index 4001f55b053..29d32ef78e8 100644 --- a/xml/System.CodeDom/CodeCommentStatement.xml +++ b/xml/System.CodeDom/CodeCommentStatement.xml @@ -48,20 +48,19 @@ Represents a statement consisting of a single comment. - can be used to represent a single-line comment statement. is a statement, so it can be inserted into a statements collection and will appear on its own line. can also be added to the comments collection of or any object that derives from . + + + +## Examples + This example demonstrates using a to represent a comment in source code. -## Remarks - can be used to represent a single-line comment statement. is a statement, so it can be inserted into a statements collection and will appear on its own line. can also be added to the comments collection of or any object that derives from . - - - -## Examples - This example demonstrates using a to represent a comment in source code. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeCommentExample/CPP/codecommentexample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeComment/Overview/codecommentexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCommentExample/VB/codecommentexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCommentExample/VB/codecommentexample.vb" id="Snippet2"::: + ]]> @@ -221,24 +220,24 @@ if the comment is a documentation comment; otherwise, . Initializes a new instance of the class using the specified text and documentation comment flag. - is a documentation comment and the comment is structured using triple delimiter characters. For example, in C# the comment is "`///`", in Visual Basic "`'''`". Documentation comments are used to identify an XML comment field, such as a type or member summary identified by the `` element. - - - -## Examples - The following code example demonstrates the use of the constructor to create a comment statement to be used as an XML comment field. This example is part of a larger example that follows. - + is a documentation comment and the comment is structured using triple delimiter characters. For example, in C# the comment is "`///`", in Visual Basic "`'''`". Documentation comments are used to identify an XML comment field, such as a type or member summary identified by the `` element. + + + +## Examples + The following code example demonstrates the use of the constructor to create a comment statement to be used as an XML comment field. This example is part of a larger example that follows. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCommentStatement/.ctor/program.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomHelloWorldSample/vb/program.vb" id="Snippet3"::: - - The following code example demonstrates the creation of a simple "Hello World" console application and the generation of an XML documentation file for the compiled application. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomHelloWorldSample/vb/program.vb" id="Snippet3"::: + + The following code example demonstrates the creation of a simple "Hello World" console application and the generation of an XML documentation file for the compiled application. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCommentStatement/.ctor/program.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomHelloWorldSample/vb/program.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomHelloWorldSample/vb/program.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.CodeDom/CodeCommentStatementCollection.xml b/xml/System.CodeDom/CodeCommentStatementCollection.xml index 299d7af17b3..6364625a789 100644 --- a/xml/System.CodeDom/CodeCommentStatementCollection.xml +++ b/xml/System.CodeDom/CodeCommentStatementCollection.xml @@ -48,20 +48,19 @@ Represents a collection of objects. - class provides a simple collection object that can be used to store a set of objects. + + + +## Examples + The following example demonstrates the use of the class methods. The example creates a new instance of the class and uses the methods to add statements to the collection, return their index, and add or remove attributes at a specific index point. -## Remarks - The class provides a simple collection object that can be used to store a set of objects. - - - -## Examples - The following example demonstrates the use of the class methods. The example creates a new instance of the class and uses the 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/CodeCommentStatementCollectionExample/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCommentStatementCollection/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCommentStatementCollectionExample/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCommentStatementCollectionExample/VB/class1.vb" id="Snippet1"::: + ]]> @@ -219,15 +218,14 @@ Adds the specified object to the collection. The index at which the new element was inserted. - object to a instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeCommentStatementCollectionExample/CPP/class1.cpp" id="Snippet3"::: + object to a instance. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCommentStatementCollection/Overview/class1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCommentStatementCollectionExample/VB/class1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCommentStatementCollectionExample/VB/class1.vb" id="Snippet3"::: + ]]> @@ -277,15 +275,14 @@ An array of type that contains the objects to add to the collection. Copies the elements of the specified array to the end of the collection. - method overload to add the members of a array to the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeCommentStatementCollectionExample/CPP/class1.cpp" id="Snippet4"::: + method overload to add the members of a array to the . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCommentStatementCollection/Overview/class1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCommentStatementCollectionExample/VB/class1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCommentStatementCollectionExample/VB/class1.vb" id="Snippet4"::: + ]]> @@ -328,15 +325,14 @@ A that contains the objects to add to the collection. Copies the contents of another object to the end of the collection. - method overload to add the members of one to another. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeCommentStatementCollectionExample/CPP/class1.cpp" id="Snippet4"::: + method overload to add the members of one to another. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCommentStatementCollection/Overview/class1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCommentStatementCollectionExample/VB/class1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCommentStatementCollectionExample/VB/class1.vb" id="Snippet4"::: + ]]> @@ -381,15 +377,14 @@ if the collection contains the specified object; otherwise, . - method to search for the presence of a specific object and gets the index value at which it was found. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeCommentStatementCollectionExample/CPP/class1.cpp" id="Snippet5"::: + method to search for the presence of a specific object and gets the index value at which it was found. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCommentStatementCollection/Overview/class1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCommentStatementCollectionExample/VB/class1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCommentStatementCollectionExample/VB/class1.vb" id="Snippet5"::: + ]]> @@ -432,21 +427,20 @@ The index of the array at which to begin inserting. Copies the collection objects to the specified one-dimensional beginning at the specified index. - to an array beginning at the index value 0. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeCommentStatementCollectionExample/CPP/class1.cpp" id="Snippet6"::: + to an array beginning at the index value 0. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCommentStatementCollection/Overview/class1.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCommentStatementCollectionExample/VB/class1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCommentStatementCollectionExample/VB/class1.vb" id="Snippet6"::: + ]]> - The destination array is multidimensional. - - -or- - + The destination array is multidimensional. + + -or- + The number of elements in the is greater than the available space between the index of the target array specified by the parameter and the end of the target array. The parameter is . The parameter is less than the target array's minimum index. @@ -489,15 +483,14 @@ Gets the index of the specified object in the collection, if it exists in the collection. The index of the specified object, if found, in the collection; otherwise, -1. - object and uses the method to get the index value at which it was found. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeCommentStatementCollectionExample/CPP/class1.cpp" id="Snippet5"::: + object and uses the method to get the index value at which it was found. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCommentStatementCollection/Overview/class1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCommentStatementCollectionExample/VB/class1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCommentStatementCollectionExample/VB/class1.vb" id="Snippet5"::: + ]]> @@ -540,15 +533,14 @@ The object to insert. Inserts a object into the collection at the specified index. - method to add a object to the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeCommentStatementCollectionExample/CPP/class1.cpp" id="Snippet8"::: + method to add a object to the . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCommentStatementCollection/Overview/class1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCommentStatementCollectionExample/VB/class1.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCommentStatementCollectionExample/VB/class1.vb" id="Snippet8"::: + ]]> @@ -590,11 +582,11 @@ Gets or sets the object at the specified index in the collection. A object at each valid index. - The parameter is outside the valid range of indexes for the collection. @@ -635,15 +627,14 @@ The object to remove from the collection. Removes the specified object from the collection. - method to delete a object from the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeCommentStatementCollectionExample/CPP/class1.cpp" id="Snippet9"::: + method to delete a object from the . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCommentStatementCollection/Overview/class1.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCommentStatementCollectionExample/VB/class1.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeCommentStatementCollectionExample/VB/class1.vb" id="Snippet9"::: + ]]> The specified object is not found in the collection. diff --git a/xml/System.CodeDom/CodeCompileUnit.xml b/xml/System.CodeDom/CodeCompileUnit.xml index ceba8e7b24e..f80d0b3d8ba 100644 --- a/xml/System.CodeDom/CodeCompileUnit.xml +++ b/xml/System.CodeDom/CodeCompileUnit.xml @@ -48,27 +48,26 @@ Provides a container for a CodeDOM program graph. - provides a container for a CodeDOM program graph. - - contains a collection that can store objects containing CodeDOM source code graphs, along with a collection of assemblies referenced by the project, and a collection of attributes for the project assembly. - - A can be passed to the method of an implementation along with other parameters to generate code based on the program graph contained by the compile unit. - + provides a container for a CodeDOM program graph. + + contains a collection that can store objects containing CodeDOM source code graphs, along with a collection of assemblies referenced by the project, and a collection of attributes for the project assembly. + + A can be passed to the method of an implementation along with other parameters to generate code based on the program graph contained by the compile unit. + > [!NOTE] -> Some languages support only a single namespace that contains a single class in a compile unit. - - - -## Examples - The following code example constructs a that models the program structure of a simple "Hello World" program. This code example is part of a larger example that also produces code from this model, and is provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDomExample/CPP/source.cpp" id="Snippet2"::: +> Some languages support only a single namespace that contains a single class in a compile unit. + + + +## Examples + The following code example constructs a that models the program structure of a simple "Hello World" program. This code example is part of a larger example that also produces code from this model, and is provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCompileUnit/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomExample/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomExample/VB/source.vb" id="Snippet2"::: + ]]> @@ -135,11 +134,11 @@ Gets a collection of custom attributes for the generated assembly. A that indicates the custom attributes for the generated assembly. - objects representing attributes for the generated assembly from this collection. - + objects representing attributes for the generated assembly from this collection. + ]]> @@ -175,14 +174,14 @@ Gets a object containing end directives. A object containing end directives. - property. This example is part of a larger example provided for the class. - + property. This example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeChecksumPragma/Overview/codedirective.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.CodeDom.CodeDirectives/VB/codedirective.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.CodeDom.CodeDirectives/VB/codedirective.vb" id="Snippet3"::: + ]]> @@ -225,23 +224,22 @@ Gets the collection of namespaces. A that indicates the namespaces that the compile unit uses. - objects from this collection. Each object represents a namespace. - + objects from this collection. Each object represents a namespace. + > [!NOTE] -> Some languages support only a single namespace that contains a single class in a compile unit. - - - -## Examples - The following code example constructs a that models the program structure of a simple "Hello World" program. This example is part of a larger example that also produces code from this model, and is provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDomExample/CPP/source.cpp" id="Snippet2"::: +> Some languages support only a single namespace that contains a single class in a compile unit. + + + +## Examples + The following code example constructs a that models the program structure of a simple "Hello World" program. This example is part of a larger example that also produces code from this model, and is provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCompileUnit/Overview/source.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomExample/VB/source.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomExample/VB/source.vb" id="Snippet2"::: + ]]> @@ -279,11 +277,11 @@ Gets the referenced assemblies. A that contains the file names of the referenced assemblies. - @@ -319,14 +317,14 @@ Gets a object containing start directives. A object containing start directives. - property. This example is part of a larger example provided for the class. - + property. This example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeChecksumPragma/Overview/codedirective.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.CodeDom.CodeDirectives/VB/codedirective.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.CodeDom.CodeDirectives/VB/codedirective.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.CodeDom/CodeConditionStatement.xml b/xml/System.CodeDom/CodeConditionStatement.xml index 71eeb74d61f..eaf5584ca69 100644 --- a/xml/System.CodeDom/CodeConditionStatement.xml +++ b/xml/System.CodeDom/CodeConditionStatement.xml @@ -48,22 +48,21 @@ Represents a conditional branch statement, typically represented as an statement. - can be used to represent code that consists of a conditional expression, a collection of statements to execute if the conditional expression evaluates to `true`, and an optional collection of statements to execute if the conditional expression evaluates to `false`. A is generated in many languages as an `if` statement. + + The property indicates the expression to test. The property contains the statements to execute if the expression to test evaluates to `true`. The property contains the statements to execute if the expression to test evaluates to `false`. + + + +## Examples + This example demonstrates using a to represent an `if` statement with an `else` block. -## Remarks - can be used to represent code that consists of a conditional expression, a collection of statements to execute if the conditional expression evaluates to `true`, and an optional collection of statements to execute if the conditional expression evaluates to `false`. A is generated in many languages as an `if` statement. - - The property indicates the expression to test. The property contains the statements to execute if the expression to test evaluates to `true`. The property contains the statements to execute if the expression to test evaluates to `false`. - - - -## Examples - This example demonstrates using a to represent an `if` statement with an `else` block. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeConditionStatementExample/CPP/codeconditionstatementexample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeConditionStatement/Overview/codeconditionstatementexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeConditionStatementExample/VB/codeconditionstatementexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeConditionStatementExample/VB/codeconditionstatementexample.vb" id="Snippet2"::: + ]]> @@ -234,11 +233,11 @@ Gets or sets the expression to evaluate or . A to evaluate or . - collection will be executed. If this conditional expression evaluates to `false` and the collection is not empty, the code contained in the collection will be executed. - + collection will be executed. If this conditional expression evaluates to `false` and the collection is not empty, the code contained in the collection will be executed. + ]]> diff --git a/xml/System.CodeDom/CodeConstructor.xml b/xml/System.CodeDom/CodeConstructor.xml index 9122c3161a1..f7586ebf914 100644 --- a/xml/System.CodeDom/CodeConstructor.xml +++ b/xml/System.CodeDom/CodeConstructor.xml @@ -48,22 +48,21 @@ Represents a declaration for an instance constructor of a type. - can be used to represent a declaration of an instance constructor for a type. Use to declare a static constructor for a type. + + If the constructor calls a base class constructor, set the constructor arguments for the base class constructor in the property. If the constructor overloads another constructor for the type, set the constructor arguments to pass to the overloaded type constructor in the property. + + + +## Examples + This example demonstrates using a to declare several types of constructors. -## Remarks - can be used to represent a declaration of an instance constructor for a type. Use to declare a static constructor for a type. - - If the constructor calls a base class constructor, set the constructor arguments for the base class constructor in the property. If the constructor overloads another constructor for the type, set the constructor arguments to pass to the overloaded type constructor in the property. - - - -## Examples - This example demonstrates using a to declare several types of constructors. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeConstructorExample/CPP/codeconstructorexample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeConstructor/Overview/codeconstructorexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeConstructorExample/VB/codeconstructorexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeConstructorExample/VB/codeconstructorexample.vb" id="Snippet2"::: + ]]> @@ -136,11 +135,11 @@ Gets the collection of base constructor arguments. A that contains the base constructor arguments. - overloads a base class constructor, this collection contains any arguments to pass to a base class constructor. To call a base class constructor with no arguments, set a containing an empty string ("") to this collection. - + overloads a base class constructor, this collection contains any arguments to pass to a base class constructor. To call a base class constructor with no arguments, set a containing an empty string ("") to this collection. + ]]> @@ -184,11 +183,11 @@ Gets the collection of chained constructor arguments. A that contains the chained constructor arguments. - overloads another constructor of the same type, this collection contains any arguments to pass to the overloaded type constructor. To call a constructor for the current type with no arguments, set a containing an empty string ("") to this collection. - + overloads another constructor of the same type, this collection contains any arguments to pass to the overloaded type constructor. To call a constructor for the current type with no arguments, set a containing an empty string ("") to this collection. + ]]> diff --git a/xml/System.CodeDom/CodeDelegateCreateExpression.xml b/xml/System.CodeDom/CodeDelegateCreateExpression.xml index 46b90d27af8..a6ad6ba8b43 100644 --- a/xml/System.CodeDom/CodeDelegateCreateExpression.xml +++ b/xml/System.CodeDom/CodeDelegateCreateExpression.xml @@ -48,24 +48,23 @@ Represents an expression that creates a delegate. - represents code that creates a delegate. is often used with or to represent an event handler to attach or remove from an event. + + The property specifies the type of delegate to create. The property indicates the object that contains the event-handler method. The property indicates the name of the event-handler method whose method signature matches the method signature of the delegate. + + In C#, a delegate creation expression is typically of the following form: `new EventHandler(this.HandleEventMethod)`. In Visual Basic, a delegate creation expression is typically of the following form: `AddressOf Me.HandleEventMethod`. + + + +## Examples + The following example code uses a to create a delegate. -## Remarks - represents code that creates a delegate. is often used with or to represent an event handler to attach or remove from an event. - - The property specifies the type of delegate to create. The property indicates the object that contains the event-handler method. The property indicates the name of the event-handler method whose method signature matches the method signature of the delegate. - - In C#, a delegate creation expression is typically of the following form: `new EventHandler(this.HandleEventMethod)`. In Visual Basic, a delegate creation expression is typically of the following form: `AddressOf Me.HandleEventMethod`. - - - -## Examples - The following example code uses a to create a delegate. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeAttachEventStatementExample/CPP/codeattacheventstatementexample.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeAttachEventStatement/Overview/codeattacheventstatementexample.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttachEventStatementExample/VB/codeattacheventstatementexample.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeAttachEventStatementExample/VB/codeattacheventstatementexample.vb" id="Snippet3"::: + ]]> diff --git a/xml/System.CodeDom/CodeDelegateInvokeExpression.xml b/xml/System.CodeDom/CodeDelegateInvokeExpression.xml index 635a1fc5848..6762845106f 100644 --- a/xml/System.CodeDom/CodeDelegateInvokeExpression.xml +++ b/xml/System.CodeDom/CodeDelegateInvokeExpression.xml @@ -48,22 +48,21 @@ Represents an expression that raises an event. - can be used to represent code that invokes an event. Invoking an event invokes all delegates that are registered with the event using the specified parameters. + + The property specifies the event to invoke. The property specifies the parameters to pass to the delegates for the event. + + + +## Examples + The following example demonstrates use of a to invoke an event named `TestEvent`. -## Remarks - can be used to represent code that invokes an event. Invoking an event invokes all delegates that are registered with the event using the specified parameters. - - The property specifies the event to invoke. The property specifies the parameters to pass to the delegates for the event. - - - -## Examples - The following example demonstrates use of a to invoke an event named `TestEvent`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDelegateInvokeExpressionExample/CPP/codedelegateinvokeexpressionexample.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeDelegateInvokeExpression/Overview/codedelegateinvokeexpressionexample.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDelegateInvokeExpressionExample/VB/codedelegateinvokeexpressionexample.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDelegateInvokeExpressionExample/VB/codedelegateinvokeexpressionexample.vb" id="Snippet3"::: + ]]> diff --git a/xml/System.CodeDom/CodeDirectionExpression.xml b/xml/System.CodeDom/CodeDirectionExpression.xml index 941b5b1e785..ad8b9c138e5 100644 --- a/xml/System.CodeDom/CodeDirectionExpression.xml +++ b/xml/System.CodeDom/CodeDirectionExpression.xml @@ -48,25 +48,24 @@ Represents an expression used as a method invoke parameter along with a reference direction indicator. - can represent a parameter passed to a method and the reference direction of the parameter. - - The property indicates the expression to qualify with a direction. The property indicates the direction of the parameter using one of the enumeration values. - + can represent a parameter passed to a method and the reference direction of the parameter. + + The property indicates the expression to qualify with a direction. The property indicates the direction of the parameter using one of the enumeration values. + > [!NOTE] -> is intended to be used as a method invoke parameter, and should not be used when declaring methods. +> is intended to be used as a method invoke parameter, and should not be used when declaring methods. + + + +## Examples + The following example demonstrates use of a to specify a field direction modifier for an expression to pass as a method parameter. - - -## Examples - The following example demonstrates use of a to specify a field direction modifier for an expression to pass as a method parameter. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeMultiExample/CPP/codemultiexample.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeDirectionExpression/Overview/codemultiexample.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMultiExample/VB/codemultiexample.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMultiExample/VB/codemultiexample.vb" id="Snippet4"::: + ]]> diff --git a/xml/System.CodeDom/CodeEntryPointMethod.xml b/xml/System.CodeDom/CodeEntryPointMethod.xml index 49437ae0d79..89c981e54cb 100644 --- a/xml/System.CodeDom/CodeEntryPointMethod.xml +++ b/xml/System.CodeDom/CodeEntryPointMethod.xml @@ -48,20 +48,19 @@ Represents the entry point method of an executable. - is a that represents the entry point method of an executable. + + + +## Examples + This example demonstrates using a to indicate the method to start program execution at. -## Remarks - A is a that represents the entry point method of an executable. - - - -## Examples - This example demonstrates using a to indicate the method to start program execution at. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeEntryPointMethod/CPP/codeentrypointmethodexample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeEntryPointMethod/Overview/codeentrypointmethodexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeEntryPointMethod/VB/codeentrypointmethodexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeEntryPointMethod/VB/codeentrypointmethodexample.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.CodeDom/CodeEventReferenceExpression.xml b/xml/System.CodeDom/CodeEventReferenceExpression.xml index b49d7381024..e88df944bc4 100644 --- a/xml/System.CodeDom/CodeEventReferenceExpression.xml +++ b/xml/System.CodeDom/CodeEventReferenceExpression.xml @@ -48,22 +48,21 @@ Represents a reference to an event. - can be used to represent a reference to an event. + + The property specifies the object that contains the event. The property specifies the name of the event. + + + +## Examples + The following example demonstrates use of to reference an event named TestEvent. -## Remarks - can be used to represent a reference to an event. - - The property specifies the object that contains the event. The property specifies the name of the event. - - - -## Examples - The following example demonstrates use of to reference an event named TestEvent. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeMultiExample/CPP/codemultiexample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeDirectionExpression/Overview/codemultiexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMultiExample/VB/codemultiexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMultiExample/VB/codemultiexample.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.CodeDom/CodeExpressionCollection.xml b/xml/System.CodeDom/CodeExpressionCollection.xml index 388d695a570..389ec96eee0 100644 --- a/xml/System.CodeDom/CodeExpressionCollection.xml +++ b/xml/System.CodeDom/CodeExpressionCollection.xml @@ -48,22 +48,21 @@ Represents a collection of objects. - class provides a simple collection object that can be used to store a set of objects. + + + +## Examples + The following example demonstrates the use of the class methods. The example creates a new instance of the class and uses the methods to add statements to the collection, return their index, and add or remove attributes at a specific index point. -## Remarks - Provides a simple collection object that can represent a set of Code Document Object Model (CodeDOM) expression objects. - - The class provides a simple collection object that can be used to store a set of objects. - - - -## Examples - The following example demonstrates the use of the class methods. The example creates a new instance of the class and uses the 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/CodeExpressionCollectionExample/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeExpressionCollection/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeExpressionCollectionExample/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeExpressionCollectionExample/VB/class1.vb" id="Snippet1"::: + ]]> @@ -221,15 +220,14 @@ Adds the specified object to the collection. The index at which the new element was inserted. - object to a instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeExpressionCollectionExample/CPP/class1.cpp" id="Snippet3"::: + object to a instance. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeExpressionCollection/Overview/class1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeExpressionCollectionExample/VB/class1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeExpressionCollectionExample/VB/class1.vb" id="Snippet3"::: + ]]> @@ -279,15 +277,14 @@ An array of type that contains the objects to add to the collection. Copies the elements of the specified array to the end of the collection. - method overload to add the members of a array to a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeExpressionCollectionExample/CPP/class1.cpp" id="Snippet4"::: + method overload to add the members of a array to a . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeExpressionCollection/Overview/class1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeExpressionCollectionExample/VB/class1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeExpressionCollectionExample/VB/class1.vb" id="Snippet4"::: + ]]> @@ -330,15 +327,14 @@ A that contains the objects to add to the collection. Copies the contents of another object to the end of the collection. - method overload to add the members of one object to another . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeExpressionCollectionExample/CPP/class1.cpp" id="Snippet4"::: + method overload to add the members of one object to another . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeExpressionCollection/Overview/class1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeExpressionCollectionExample/VB/class1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeExpressionCollectionExample/VB/class1.vb" id="Snippet4"::: + ]]> @@ -383,15 +379,14 @@ if the collection contains the specified object; otherwise, . - method to search for the presence of a specific object and gets the index value at which it was found. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeExpressionCollectionExample/CPP/class1.cpp" id="Snippet5"::: + method to search for the presence of a specific object and gets the index value at which it was found. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeExpressionCollection/Overview/class1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeExpressionCollectionExample/VB/class1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeExpressionCollectionExample/VB/class1.vb" id="Snippet5"::: + ]]> @@ -434,21 +429,20 @@ The index of the array at which to begin inserting. Copies the collection objects to a one-dimensional instance beginning at the specified index. - to a array beginning at the index value 0. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeExpressionCollectionExample/CPP/class1.cpp" id="Snippet6"::: + to a array beginning at the index value 0. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeExpressionCollection/Overview/class1.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeExpressionCollectionExample/VB/class1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeExpressionCollectionExample/VB/class1.vb" id="Snippet6"::: + ]]> - The destination array is multidimensional. - - -or- - + The destination array is multidimensional. + + -or- + The number of elements in the is greater than the available space between the index of the target array specified by the parameter and the end of the target array. The parameter is . The parameter is less than the target array's minimum index. @@ -491,15 +485,14 @@ Gets the index of the specified object in the collection, if it exists in the collection. The index of the specified object, if found, in the collection; otherwise, -1. - object and uses the method to get the index value at which it was found. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeExpressionCollectionExample/CPP/class1.cpp" id="Snippet5"::: + object and uses the method to get the index value at which it was found. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeExpressionCollection/Overview/class1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeExpressionCollectionExample/VB/class1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeExpressionCollectionExample/VB/class1.vb" id="Snippet5"::: + ]]> @@ -542,15 +535,14 @@ The object to insert. Inserts the specified object into the collection at the specified index. - method to add a object to a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeExpressionCollectionExample/CPP/class1.cpp" id="Snippet8"::: + method to add a object to a . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeExpressionCollection/Overview/class1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeExpressionCollectionExample/VB/class1.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeExpressionCollectionExample/VB/class1.vb" id="Snippet8"::: + ]]> @@ -592,11 +584,11 @@ Gets or sets the object at the specified index in the collection. A object at each valid index. - The parameter is outside the valid range of indexes for the collection. @@ -637,15 +629,14 @@ The object to remove from the collection. Removes the specified object from the collection. - method to delete a object from a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeExpressionCollectionExample/CPP/class1.cpp" id="Snippet9"::: + method to delete a object from a . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeExpressionCollection/Overview/class1.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeExpressionCollectionExample/VB/class1.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeExpressionCollectionExample/VB/class1.vb" id="Snippet9"::: + ]]> The specified object is not found in the collection. diff --git a/xml/System.CodeDom/CodeExpressionStatement.xml b/xml/System.CodeDom/CodeExpressionStatement.xml index 4df4eb77f33..a5a8abc0ee2 100644 --- a/xml/System.CodeDom/CodeExpressionStatement.xml +++ b/xml/System.CodeDom/CodeExpressionStatement.xml @@ -48,20 +48,19 @@ Represents a statement that consists of a single expression. - contains a object, and it can be added to a object, allowing some expressions to stand alone. For example, a contained by a can represent a method call without a return value. - - - -## Examples - The following example demonstrates how to create an instance of the class by using a object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDomSampleBatch/CPP/class1.cpp" id="Snippet1"::: + contains a object, and it can be added to a object, allowing some expressions to stand alone. For example, a contained by a can represent a method call without a return value. + + + +## Examples + The following example demonstrates how to create an instance of the class by using a object. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeExpressionStatement/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomSampleBatch/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomSampleBatch/VB/class1.vb" id="Snippet1"::: + ]]> @@ -149,15 +148,14 @@ A for the statement. Initializes a new instance of the class by using the specified expression. - object and uses it as a parameter to initialize an instance of the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDomSampleBatch/CPP/class1.cpp" id="Snippet1"::: + object and uses it as a parameter to initialize an instance of the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeExpressionStatement/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomSampleBatch/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomSampleBatch/VB/class1.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.CodeDom/CodeFieldReferenceExpression.xml b/xml/System.CodeDom/CodeFieldReferenceExpression.xml index ef708278ae2..05acd132819 100644 --- a/xml/System.CodeDom/CodeFieldReferenceExpression.xml +++ b/xml/System.CodeDom/CodeFieldReferenceExpression.xml @@ -48,22 +48,21 @@ Represents a reference to a field. - can be used to represent a reference to a field. - - The property specifies the object that contains the field. The property specifies the name of the field to reference. - - - -## Examples - The following example demonstrates use of a to reference a field. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeReferenceExample/CPP/codereferenceexample.cpp" id="Snippet2"::: + can be used to represent a reference to a field. + + The property specifies the object that contains the field. The property specifies the name of the field to reference. + + + +## Examples + The following example demonstrates use of a to reference a field. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeFieldReferenceExpression/Overview/codereferenceexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeReferenceExample/VB/codereferenceexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeReferenceExample/VB/codereferenceexample.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.CodeDom/CodeGotoStatement.xml b/xml/System.CodeDom/CodeGotoStatement.xml index 5cb11e66e1a..81a20e3088b 100644 --- a/xml/System.CodeDom/CodeGotoStatement.xml +++ b/xml/System.CodeDom/CodeGotoStatement.xml @@ -63,7 +63,6 @@ ## Examples The following example code demonstrates use of a and a to redirect program flow. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeGotoStatementExample/CPP/codegotostatementexample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeGotoStatement/Overview/codegotostatementexample.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeGotoStatementExample/VB/codegotostatementexample.vb" id="Snippet2"::: diff --git a/xml/System.CodeDom/CodeIndexerExpression.xml b/xml/System.CodeDom/CodeIndexerExpression.xml index f7e457f2600..9a5fbbab255 100644 --- a/xml/System.CodeDom/CodeIndexerExpression.xml +++ b/xml/System.CodeDom/CodeIndexerExpression.xml @@ -48,20 +48,19 @@ Represents a reference to an indexer property of an object. - can be used to represent a reference to a code indexer, or non-array indexer. Use to represent a reference to array indexers. - - - -## Examples - The following example demonstrates use of a to reference a type indexer for the current object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeMultiExample/CPP/codemultiexample.cpp" id="Snippet3"::: + can be used to represent a reference to a code indexer, or non-array indexer. Use to represent a reference to array indexers. + + + +## Examples + The following example demonstrates use of a to reference a type indexer for the current object. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeDirectionExpression/Overview/codemultiexample.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMultiExample/VB/codemultiexample.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMultiExample/VB/codemultiexample.vb" id="Snippet3"::: + ]]> @@ -187,11 +186,11 @@ Gets the collection of indexes of the indexer expression. A that indicates the index or indexes of the indexer expression. - can contain a that specifies a single index within the target indexer, or multiple objects that together specify a specific intersection of indexes across the dimensions of the indexer. - + can contain a that specifies a single index within the target indexer, or multiple objects that together specify a specific intersection of indexes across the dimensions of the indexer. + ]]> @@ -238,11 +237,11 @@ Gets or sets the target object that can be indexed. A that indicates the indexer object. - diff --git a/xml/System.CodeDom/CodeIterationStatement.xml b/xml/System.CodeDom/CodeIterationStatement.xml index c298f81fba9..02e1853e284 100644 --- a/xml/System.CodeDom/CodeIterationStatement.xml +++ b/xml/System.CodeDom/CodeIterationStatement.xml @@ -48,22 +48,21 @@ Represents a statement, or a loop through a block of statements, using a test expression as a condition for continuing to loop. - can represent a `for` loop or `while` loop. - - The property specifies the statement to execute before the first loop iteration. The property specifies the loop continuation expression, which must evaluate to `true` at the end of each loop iteration for another iteration to begin. The property specifies the statement to execute at the end of each loop iteration. The property specifies the collection of statements to execute within the loop. - - - -## Examples - This example demonstrates using a to represent a `for` loop. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeIterationStatementExample/CPP/codeiterationstatementexample.cpp" id="Snippet2"::: + can represent a `for` loop or `while` loop. + + The property specifies the statement to execute before the first loop iteration. The property specifies the loop continuation expression, which must evaluate to `true` at the end of each loop iteration for another iteration to begin. The property specifies the statement to execute at the end of each loop iteration. The property specifies the collection of statements to execute within the loop. + + + +## Examples + This example demonstrates using a to represent a `for` loop. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeIterationStatement/Overview/codeiterationstatementexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeIterationStatementExample/VB/codeiterationstatementexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeIterationStatementExample/VB/codeiterationstatementexample.vb" id="Snippet2"::: + ]]> @@ -198,11 +197,11 @@ Gets or sets the statement that is called after each loop cycle. A that indicates the per cycle increment statement. - @@ -250,11 +249,11 @@ Gets or sets the loop initialization statement. A that indicates the loop initialization statement. - that contains a that contains an empty string. - + that contains a that contains an empty string. + ]]> @@ -342,11 +341,11 @@ Gets or sets the expression to test as the condition that continues the loop. A that indicates the expression to test. - diff --git a/xml/System.CodeDom/CodeLabeledStatement.xml b/xml/System.CodeDom/CodeLabeledStatement.xml index f87ae21057e..21a6c5c7406 100644 --- a/xml/System.CodeDom/CodeLabeledStatement.xml +++ b/xml/System.CodeDom/CodeLabeledStatement.xml @@ -48,25 +48,24 @@ Represents a labeled statement or a stand-alone label. - represents a label and optionally, an associated statement. A label can be used to indicate the target of a . - - The property is optional. To create only a label, leave the property uninitialized. - + represents a label and optionally, an associated statement. A label can be used to indicate the target of a . + + The property is optional. To create only a label, leave the property uninitialized. + > [!NOTE] -> Not all languages support `goto` statements and labels, so you should test whether a code generator supports `goto` statements and labels by calling the method with the flag. - - - -## Examples - The following example code demonstrates use of a and a to redirect program flow. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeGotoStatementExample/CPP/codegotostatementexample.cpp" id="Snippet2"::: +> Not all languages support `goto` statements and labels, so you should test whether a code generator supports `goto` statements and labels by calling the method with the flag. + + + +## Examples + The following example code demonstrates use of a and a to redirect program flow. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeGotoStatement/Overview/codegotostatementexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeGotoStatementExample/VB/codegotostatementexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeGotoStatementExample/VB/codegotostatementexample.vb" id="Snippet2"::: + ]]> @@ -281,11 +280,11 @@ Gets or sets the optional associated statement. A that indicates the statement associated with the label. - represents only a label, rather than a labeled statement. - + represents only a label, rather than a labeled statement. + ]]> diff --git a/xml/System.CodeDom/CodeLinePragma.xml b/xml/System.CodeDom/CodeLinePragma.xml index b526f9f8d13..38d9551a3b6 100644 --- a/xml/System.CodeDom/CodeLinePragma.xml +++ b/xml/System.CodeDom/CodeLinePragma.xml @@ -48,20 +48,19 @@ Represents a specific location within a specific file. - can be used to represent a specific location within a file. This type of object is often used after compilation by debugging tools to store locations of associated code elements, such as position references associated with compiler warnings and errors. - - - -## Examples - The following code example demonstrates the use of the class to reference a specific line of a source file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDomSampleBatch/CPP/class1.cpp" id="Snippet2"::: + can be used to represent a specific location within a file. This type of object is often used after compilation by debugging tools to store locations of associated code elements, such as position references associated with compiler warnings and errors. + + + +## Examples + The following code example demonstrates the use of the class to reference a specific line of a source file. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeExpressionStatement/Overview/class1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomSampleBatch/VB/class1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomSampleBatch/VB/class1.vb" id="Snippet2"::: + ]]> @@ -108,11 +107,11 @@ Initializes a new instance of the class. - and properties. - + and properties. + ]]> @@ -151,15 +150,14 @@ The line number to store a reference to. Initializes a new instance of the class. - class to reference a specific line of a source file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDomSampleBatch/CPP/class1.cpp" id="Snippet2"::: + class to reference a specific line of a source file. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeExpressionStatement/Overview/class1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomSampleBatch/VB/class1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomSampleBatch/VB/class1.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.CodeDom/CodeMemberEvent.xml b/xml/System.CodeDom/CodeMemberEvent.xml index c6f5ebab84a..72b5c00c38a 100644 --- a/xml/System.CodeDom/CodeMemberEvent.xml +++ b/xml/System.CodeDom/CodeMemberEvent.xml @@ -48,20 +48,19 @@ Represents a declaration for an event of a type. - can be used to represent event members of a type. has properties to indicate the data type of the event, whether it privately implements a data type, and what interface types, if any, the member event implements. - - - -## Examples - This example demonstrates use of a to declare an event that takes a `System.EventHandler` delegate: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeMemberEventSample/CPP/codemembereventexample.cpp" id="Snippet3"::: + can be used to represent event members of a type. has properties to indicate the data type of the event, whether it privately implements a data type, and what interface types, if any, the member event implements. + + + +## Examples + This example demonstrates use of a to declare an event that takes a `System.EventHandler` delegate: + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeMemberEvent/Overview/codemembereventexample.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMemberEventSample/VB/codemembereventexample.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMemberEventSample/VB/codemembereventexample.vb" id="Snippet3"::: + ]]> @@ -134,11 +133,11 @@ Gets or sets the data type that the member event implements. A that indicates the data type or types that the member event implements. - @@ -185,11 +184,11 @@ Gets or sets the privately implemented data type, if any. A that indicates the data type that the event privately implements. - diff --git a/xml/System.CodeDom/CodeMemberField.xml b/xml/System.CodeDom/CodeMemberField.xml index 54b34bae91f..0ffa83f588b 100644 --- a/xml/System.CodeDom/CodeMemberField.xml +++ b/xml/System.CodeDom/CodeMemberField.xml @@ -48,24 +48,22 @@ Represents a declaration for a field of a type. - can be used to represent the declaration for a field of a type. - - - -## Examples - The following example demonstrates use of a to declare a field of type `string` named `testStringField`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeMemberFieldExample/CPP/codememberfieldexample.cpp" id="Snippet2"::: + can be used to represent the declaration for a field of a type. + + + +## Examples + The following example demonstrates use of a to declare a field of type `string` named `testStringField`. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeMemberField/Overview/codememberfieldexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMemberFieldExample/VB/codememberfieldexample.vb" id="Snippet2"::: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeMemberFieldPublicConstExample/CPP/class1.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMemberFieldExample/VB/codememberfieldexample.vb" id="Snippet2"::: + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeMemberField/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMemberFieldPublicConstExample/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMemberFieldPublicConstExample/VB/class1.vb" id="Snippet1"::: + ]]> @@ -185,16 +183,16 @@ The name of the field. Initializes a new instance of the class using the specified field type and field name. - [!NOTE] -> You must use square brackets ([]) and not the C# angle brackets (<>) to delimit generic parameters. - - To avoid the possibility of making a syntactic mistake, consider using the constructor that takes a type instead of a string as a parameter. - +> You must use square brackets ([]) and not the C# angle brackets (<>) to delimit generic parameters. + + To avoid the possibility of making a syntactic mistake, consider using the constructor that takes a type instead of a string as a parameter. + ]]> @@ -277,14 +275,14 @@ Gets or sets the initialization expression for the field. The initialization expression for the field. - property. - + property. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeMemberField/InitExpression/program.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMemberFieldInit/VB/program.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMemberFieldInit/VB/program.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.CodeDom/CodeMemberMethod.xml b/xml/System.CodeDom/CodeMemberMethod.xml index 7c81f0fca66..25292bab9dd 100644 --- a/xml/System.CodeDom/CodeMemberMethod.xml +++ b/xml/System.CodeDom/CodeMemberMethod.xml @@ -48,22 +48,21 @@ Represents a declaration for a method of a type. - can be used to represent the declaration for a method. - - The property specifies the data type of the method's return value. The property contains the method's parameters. The property contains the statements of the method. - - - -## Examples - The following example demonstrates use of a to declare a method that accepts a parameter and returns a value. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeMemberMethodExample/CPP/codemembermethodexample.cpp" id="Snippet2"::: + can be used to represent the declaration for a method. + + The property specifies the data type of the method's return value. The property contains the method's parameters. The property contains the statements of the method. + + + +## Examples + The following example demonstrates use of a to declare a method that accepts a parameter and returns a value. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeMemberMethod/Overview/codemembermethodexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMemberMethodExample/VB/codemembermethodexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMemberMethodExample/VB/codemembermethodexample.vb" id="Snippet2"::: + ]]> @@ -96,19 +95,19 @@ Initializes a new instance of the class. - object. - - - -## Examples - The following code example shows the use of the constructor to create a instance. This example is part of a larger example provided for the method. - + object. + + + +## Examples + The following code example shows the use of the constructor to create a instance. This example is part of a larger example provided for the method. + :::code language="csharp" source="~/snippets/csharp/Microsoft.CSharp/CSharpCodeProvider/GenerateCodeFromMember/program.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDom_GenerateCodeFromMember/vb/module1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDom_GenerateCodeFromMember/vb/module1.vb" id="Snippet3"::: + ]]> @@ -145,15 +144,15 @@ Gets the data types of the interfaces implemented by this method, unless it is a private method implementation, which is indicated by the property. A that indicates the interfaces implemented by this method. - represents a declaration for a public method, and this method implements a method on an interface, the interface or interfaces this method implements a method of should be referenced in this collection. - - The method should still have the same name as the method of the interface that is implemented by this method. For some languages, like C#, this has no effect on the syntax. For others, like Visual Basic, there is a special syntax for implementing interfaces. If the method is privately implementing a single interface, the property should be used instead. - + represents a declaration for a public method, and this method implements a method on an interface, the interface or interfaces this method implements a method of should be referenced in this collection. + + The method should still have the same name as the method of the interface that is implemented by this method. For some languages, like C#, this has no effect on the syntax. For others, like Visual Basic, there is a special syntax for implementing interfaces. If the method is privately implementing a single interface, the property should be used instead. + ]]> @@ -337,13 +336,13 @@ Gets or sets the data type of the interface this method, if private, implements a method of, if any. A that indicates the data type of the interface with the method that the private method whose declaration is represented by this implements. - represents the declaration of a private method and the method implements a method of an interface, this property should indicate the interface type that the method is implementing a method of. - - The type referenced by this property must be an interface. - + represents the declaration of a private method and the method implements a method of an interface, this property should indicate the interface type that the method is implementing a method of. + + The type referenced by this property must be an interface. + ]]> @@ -494,19 +493,19 @@ Gets the type parameters for the current generic method. A that contains the type parameters for the generic method. - property to add two type parameters to the `printMethod`. This example is part of a larger example provided for the class. - + property to add two type parameters to the `printMethod`. This example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeDefaultValueExpression/Overview/codedomgenerics.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.CodeDOM.Generics.1/VB/codedomgenerics.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.CodeDOM.Generics.1/VB/codedomgenerics.vb" id="Snippet6"::: + ]]> diff --git a/xml/System.CodeDom/CodeMemberProperty.xml b/xml/System.CodeDom/CodeMemberProperty.xml index b55067a81fb..97c7d491914 100644 --- a/xml/System.CodeDom/CodeMemberProperty.xml +++ b/xml/System.CodeDom/CodeMemberProperty.xml @@ -48,22 +48,21 @@ Represents a declaration for a property of a type. - can be used to represent the declaration for a property of a type. - - The property specifies the data type of the property. The property contains any get statement methods for the property. The property contains any set statement methods for the property. The property specifies any parameters for the property, such as are required for an indexer property. - - - -## Examples - The following example code demonstrates use of a to define a `string` property with `get` and `set` accessors. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeMemberPropertyExample/CPP/codememberpropertyexample.cpp" id="Snippet3"::: + can be used to represent the declaration for a property of a type. + + The property specifies the data type of the property. The property contains any get statement methods for the property. The property contains any set statement methods for the property. The property specifies any parameters for the property, such as are required for an indexer property. + + + +## Examples + The following example code demonstrates use of a to define a `string` property with `get` and `set` accessors. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeMemberProperty/Overview/codememberpropertyexample.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMemberPropertyExample/VB/codememberpropertyexample.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMemberPropertyExample/VB/codememberpropertyexample.vb" id="Snippet3"::: + ]]> @@ -136,11 +135,11 @@ Gets the collection of statements for the property. A that contains the statements for the member property. - should return the value for the member property. Use a to return a value of the data type of the property. - + should return the value for the member property. Use a to return a value of the data type of the property. + ]]> @@ -180,13 +179,13 @@ if the property of the collection is non-zero, or if the value of this property has been set to ; otherwise, . - [!NOTE] -> Setting this property to `false` clears the collection. - +> Setting this property to `false` clears the collection. + ]]> @@ -225,14 +224,14 @@ if the property of the collection is non-zero; otherwise, . - will return `false` if the property is read-only. - + will return `false` if the property is read-only. + > [!NOTE] -> Setting this property to `false` will clear the collection. - +> Setting this property to `false` will clear the collection. + ]]> @@ -270,11 +269,11 @@ Gets the data types of any interfaces that the property implements. A that indicates the data types the property implements. - @@ -317,13 +316,13 @@ Gets the collection of declaration expressions for the property. A that indicates the declaration expressions for the property. - [!NOTE] -> In general, properties do not have parameters. CodeDom supports an exception to this. For any property that has the special name "Item" and one or more parameters, it will declare an indexer property for the class. However, not all languages support the declaration of indexers. - +> In general, properties do not have parameters. CodeDom supports an exception to this. For any property that has the special name "Item" and one or more parameters, it will declare an indexer property for the class. However, not all languages support the declaration of indexers. + ]]> @@ -371,11 +370,11 @@ Gets or sets the data type of the interface, if any, this property, if private, implements. A that indicates the data type of the interface, if any, the property, if private, implements. - @@ -418,11 +417,11 @@ Gets the collection of statements for the property. A that contains the statements for the member property. - represents a reference to the object passed to the set method. - + represents a reference to the object passed to the set method. + ]]> diff --git a/xml/System.CodeDom/CodeMethodInvokeExpression.xml b/xml/System.CodeDom/CodeMethodInvokeExpression.xml index 82d78bbe0bc..d758ea47ea4 100644 --- a/xml/System.CodeDom/CodeMethodInvokeExpression.xml +++ b/xml/System.CodeDom/CodeMethodInvokeExpression.xml @@ -48,22 +48,21 @@ Represents an expression that invokes a method. - can be used to represent an expression that invokes a method. - - The property specifies the method to invoke. The property indicates the parameters to pass to the method. Use a to specify the field direction of a parameter. - - - -## Examples - This example demonstrates using a to invoke a method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeMethodInvokeExpression/CPP/codemethodinvokeexpressionexample.cpp" id="Snippet2"::: + can be used to represent an expression that invokes a method. + + The property specifies the method to invoke. The property indicates the parameters to pass to the method. Use a to specify the field direction of a parameter. + + + +## Examples + This example demonstrates using a to invoke a method. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeMethodInvokeExpression/Overview/codemethodinvokeexpressionexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMethodInvokeExpression/VB/codemethodinvokeexpressionexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMethodInvokeExpression/VB/codemethodinvokeexpressionexample.vb" id="Snippet2"::: + ]]> @@ -275,11 +274,11 @@ Gets the parameters to invoke the method with. A that indicates the parameters to invoke the method with. - to specify a field direction for the parameter. - + to specify a field direction for the parameter. + ]]> diff --git a/xml/System.CodeDom/CodeMethodReferenceExpression.xml b/xml/System.CodeDom/CodeMethodReferenceExpression.xml index 58b520524ab..c06ba7c32ce 100644 --- a/xml/System.CodeDom/CodeMethodReferenceExpression.xml +++ b/xml/System.CodeDom/CodeMethodReferenceExpression.xml @@ -48,24 +48,23 @@ Represents a reference to a method. - can be used to represent an expression of the form Object.Method. - - The property indicates the object that contains the method. The property indicates the name of the method. - - A is used with a to indicate the method to invoke, and with a to indicate the method to handle the event. - - - -## Examples - The following code example uses a to refer to a method: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeMethodReferenceExample/CPP/codemethodreferenceexample.cpp" id="Snippet3"::: + can be used to represent an expression of the form Object.Method. + + The property indicates the object that contains the method. The property indicates the name of the method. + + A is used with a to indicate the method to invoke, and with a to indicate the method to handle the event. + + + +## Examples + The following code example uses a to refer to a method: + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeMethodReferenceExpression/Overview/codemethodreferenceexample.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMethodReferenceExample/VB/codemethodreferenceexample.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMethodReferenceExample/VB/codemethodreferenceexample.vb" id="Snippet3"::: + ]]> @@ -194,20 +193,19 @@ An array of values that specify the for this . Initializes a new instance of the class using the specified target object, method name, and generic type arguments. - @@ -334,11 +332,11 @@ Gets the type arguments for the current generic method reference expression. A containing the type arguments for the current code . - property represents a collection of type references to be substituted for the type parameter references of the current generic method. - + property represents a collection of type references to be substituted for the type parameter references of the current generic method. + ]]> diff --git a/xml/System.CodeDom/CodeMethodReturnStatement.xml b/xml/System.CodeDom/CodeMethodReturnStatement.xml index f3ae8a35392..80cdbf3bd7f 100644 --- a/xml/System.CodeDom/CodeMethodReturnStatement.xml +++ b/xml/System.CodeDom/CodeMethodReturnStatement.xml @@ -48,20 +48,19 @@ Represents a return value statement. - can be used to represent a return value statement. The property specifies the value to return. - - - -## Examples - The following example demonstrates use of a to return a value from a method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeMemberMethodExample/CPP/codemembermethodexample.cpp" id="Snippet2"::: + can be used to represent a return value statement. The property specifies the value to return. + + + +## Examples + The following example demonstrates use of a to return a value from a method. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeMemberMethod/Overview/codemembermethodexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMemberMethodExample/VB/codemembermethodexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMemberMethodExample/VB/codemembermethodexample.vb" id="Snippet2"::: + ]]> @@ -188,11 +187,11 @@ Gets or sets the return value. A that indicates the value to return for the return statement, or if the statement is part of a subroutine. - diff --git a/xml/System.CodeDom/CodeNamespace.xml b/xml/System.CodeDom/CodeNamespace.xml index f916305f173..fc0c4401f56 100644 --- a/xml/System.CodeDom/CodeNamespace.xml +++ b/xml/System.CodeDom/CodeNamespace.xml @@ -48,27 +48,26 @@ Represents a namespace declaration. - can be used to represent a namespace declaration. - - The property specifies the name of the namespace. The property contains the namespace import directives for the namespace. The property contains the type declarations for the namespace. The property contains the comments that apply at the namespace level. - - In some languages, a namespace can function as a container for type declarations; all types in the same namespace are accessible without using fully-qualified type references, if there is no conflict between type names. - + can be used to represent a namespace declaration. + + The property specifies the name of the namespace. The property contains the namespace import directives for the namespace. The property contains the type declarations for the namespace. The property contains the comments that apply at the namespace level. + + In some languages, a namespace can function as a container for type declarations; all types in the same namespace are accessible without using fully-qualified type references, if there is no conflict between type names. + > [!NOTE] -> Use fully qualified type references to avoid potential ambiguity. - - - -## Examples - The following example code demonstrates use of a to declare a namespace. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeNamespaceExample/CPP/codenamespaceexample.cpp" id="Snippet2"::: +> Use fully qualified type references to avoid potential ambiguity. + + + +## Examples + The following example code demonstrates use of a to declare a namespace. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeNamespace/Overview/codenamespaceexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeNamespaceExample/VB/codenamespaceexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeNamespaceExample/VB/codenamespaceexample.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.CodeDom/CodeNamespaceCollection.xml b/xml/System.CodeDom/CodeNamespaceCollection.xml index 4c6ce2e6727..cc93818c5cc 100644 --- a/xml/System.CodeDom/CodeNamespaceCollection.xml +++ b/xml/System.CodeDom/CodeNamespaceCollection.xml @@ -48,20 +48,19 @@ Represents a collection of objects. - class provides a simple collection object that can be used to store a set of objects. - - - -## Examples - The following example demonstrates how to use the 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/CodeNamespaceCollectionExample/CPP/class1.cpp" id="Snippet1"::: + class provides a simple collection object that can be used to store a set of objects. + + + +## Examples + The following example demonstrates how to use the 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="csharp" source="~/snippets/csharp/System.CodeDom/CodeNamespaceCollection/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeNamespaceCollectionExample/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeNamespaceCollectionExample/VB/class1.vb" id="Snippet1"::: + ]]> @@ -110,15 +109,14 @@ Initializes a new instance of the class. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeNamespaceCollectionExample/CPP/class1.cpp" id="Snippet2"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeNamespaceCollection/Overview/class1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeNamespaceCollectionExample/VB/class1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeNamespaceCollectionExample/VB/class1.vb" id="Snippet2"::: + ]]> @@ -230,15 +228,14 @@ Adds the specified object to the collection. The index at which the new element was inserted. - method to add a object to a instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeNamespaceCollectionExample/CPP/class1.cpp" id="Snippet3"::: + method to add a object to a instance. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeNamespaceCollection/Overview/class1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeNamespaceCollectionExample/VB/class1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeNamespaceCollectionExample/VB/class1.vb" id="Snippet3"::: + ]]> @@ -288,15 +285,14 @@ An array of type that contains the objects to add to the collection. Copies the elements of the specified array to the end of the collection. - method overload to add members of a array to the . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeNamespaceCollectionExample/CPP/class1.cpp" id="Snippet4"::: + method overload to add members of a array to the . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeNamespaceCollection/Overview/class1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeNamespaceCollectionExample/VB/class1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeNamespaceCollectionExample/VB/class1.vb" id="Snippet4"::: + ]]> @@ -339,15 +335,14 @@ A that contains the objects to add to the collection. Adds the contents of the specified object to the end of the collection. - method overload to add objects from one to another . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeNamespaceCollectionExample/CPP/class1.cpp" id="Snippet4"::: + method overload to add objects from one to another . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeNamespaceCollection/Overview/class1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeNamespaceCollectionExample/VB/class1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeNamespaceCollectionExample/VB/class1.vb" id="Snippet4"::: + ]]> @@ -392,15 +387,14 @@ if the is contained in the collection; otherwise, . - method to find a object in a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeNamespaceCollectionExample/CPP/class1.cpp" id="Snippet5"::: + method to find a object in a . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeNamespaceCollection/Overview/class1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeNamespaceCollectionExample/VB/class1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeNamespaceCollectionExample/VB/class1.vb" id="Snippet5"::: + ]]> @@ -443,21 +437,20 @@ The index of the array at which to begin inserting. Copies the collection objects to a one-dimensional instance, starting at the specified index. - method to copy the contents of a object to an array, starting at the specified index value. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeNamespaceCollectionExample/CPP/class1.cpp" id="Snippet6"::: + method to copy the contents of a object to an array, starting at the specified index value. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeNamespaceCollection/Overview/class1.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeNamespaceCollectionExample/VB/class1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeNamespaceCollectionExample/VB/class1.vb" id="Snippet6"::: + ]]> - The destination array is multidimensional. - - -or- - + The destination array is multidimensional. + + -or- + The number of elements in the is greater than the available space between the index of the target array specified by the parameter and the end of the target array. The parameter is . The parameter is less than the target array's minimum index. @@ -500,15 +493,14 @@ Gets the index of the specified object in the , if it exists in the collection. The index of the specified , if it is found, in the collection; otherwise, -1. - and uses the method to retrieve the index value at which it was found. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeNamespaceCollectionExample/CPP/class1.cpp" id="Snippet5"::: + and uses the method to retrieve the index value at which it was found. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeNamespaceCollection/Overview/class1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeNamespaceCollectionExample/VB/class1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeNamespaceCollectionExample/VB/class1.vb" id="Snippet5"::: + ]]> @@ -551,15 +543,14 @@ The to insert. Inserts the specified object into the collection at the specified index. - method to insert a object into a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeNamespaceCollectionExample/CPP/class1.cpp" id="Snippet8"::: + method to insert a object into a . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeNamespaceCollection/Overview/class1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeNamespaceCollectionExample/VB/class1.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeNamespaceCollectionExample/VB/class1.vb" id="Snippet8"::: + ]]> @@ -601,11 +592,11 @@ Gets or sets the object at the specified index in the collection. A at each valid index. - The parameter is outside the valid range of indexes for the collection. @@ -647,15 +638,14 @@ The to remove from the collection. Removes the specified object from the collection. - method to delete a object from a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeNamespaceCollectionExample/CPP/class1.cpp" id="Snippet9"::: + method to delete a object from a . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeNamespaceCollection/Overview/class1.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeNamespaceCollectionExample/VB/class1.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeNamespaceCollectionExample/VB/class1.vb" id="Snippet9"::: + ]]> The specified object is not found in the collection. diff --git a/xml/System.CodeDom/CodeNamespaceImport.xml b/xml/System.CodeDom/CodeNamespaceImport.xml index ba45be25a2a..7f22e9fe7db 100644 --- a/xml/System.CodeDom/CodeNamespaceImport.xml +++ b/xml/System.CodeDom/CodeNamespaceImport.xml @@ -48,25 +48,24 @@ Represents a namespace import directive that indicates a namespace to use. - can be used to represent a namespace import directive. - - In most languages, a namespace import directive causes visibility of the types within the imported namespaces to code that references types in the imported namespaces. - + can be used to represent a namespace import directive. + + In most languages, a namespace import directive causes visibility of the types within the imported namespaces to code that references types in the imported namespaces. + > [!NOTE] -> Use fully qualified type references to avoid potential ambiguity. - - - -## Examples - The following example code demonstrates use of a to import the namespace: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeNamespaceImportExample/CPP/codenamespaceimportexample.cpp" id="Snippet2"::: +> Use fully qualified type references to avoid potential ambiguity. + + + +## Examples + The following example code demonstrates use of a to import the namespace: + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeNamespaceImport/Overview/codenamespaceimportexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeNamespaceImportExample/VB/codenamespaceimportexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeNamespaceImportExample/VB/codenamespaceimportexample.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.CodeDom/CodeNamespaceImportCollection.xml b/xml/System.CodeDom/CodeNamespaceImportCollection.xml index 71b3a353917..b08f819c70f 100644 --- a/xml/System.CodeDom/CodeNamespaceImportCollection.xml +++ b/xml/System.CodeDom/CodeNamespaceImportCollection.xml @@ -59,20 +59,19 @@ Represents a collection of objects. - class provides a simple collection object that can be used to store a set of objects. - - - -## Examples - The following example demonstrates some of the members of the class. The example initializes a new instance of the class, adds objects to it, and gets the total number of objects in the collection. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDomSampleBatch/CPP/class1.cpp" id="Snippet3"::: + class provides a simple collection object that can be used to store a set of objects. + + + +## Examples + The following example demonstrates some of the members of the class. The example initializes a new instance of the class, adds objects to it, and gets the total number of objects in the collection. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeExpressionStatement/Overview/class1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomSampleBatch/VB/class1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomSampleBatch/VB/class1.vb" id="Snippet3"::: + ]]> @@ -143,15 +142,14 @@ The object to add to the collection. Adds a object to the collection. - object to a instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDomSampleBatch/CPP/class1.cpp" id="Snippet5"::: + object to a instance. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeExpressionStatement/Overview/class1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomSampleBatch/VB/class1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomSampleBatch/VB/class1.vb" id="Snippet5"::: + ]]> @@ -192,15 +190,14 @@ An array of type that contains the objects to add to the collection. Adds a set of objects to the collection. - method to add the members of a array to a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDomSampleBatch/CPP/class1.cpp" id="Snippet6"::: + method to add the members of a array to a . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeExpressionStatement/Overview/class1.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomSampleBatch/VB/class1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomSampleBatch/VB/class1.vb" id="Snippet6"::: + ]]> @@ -277,15 +274,14 @@ Gets the number of namespaces in the collection. The number of namespaces in the collection. - object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDomSampleBatch/CPP/class1.cpp" id="Snippet7"::: + object. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeExpressionStatement/Overview/class1.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomSampleBatch/VB/class1.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomSampleBatch/VB/class1.vb" id="Snippet7"::: + ]]> @@ -405,11 +401,11 @@ The zero-based index in at which copying begins. Copies the elements of the to an , starting at a particular index. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -636,11 +632,11 @@ This member is an explicit interface member implementation. It can be used only Adds an object to the . The position at which the new element was inserted. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -686,11 +682,11 @@ This member is an explicit interface member implementation. It can be used only Removes all items from the . - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -735,11 +731,11 @@ This member is an explicit interface member implementation. It can be used only if the value is in the list; otherwise, . - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -783,11 +779,11 @@ This member is an explicit interface member implementation. It can be used only Determines the index of a specific item in the . The index of if it is found in the list; otherwise, -1. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -832,11 +828,11 @@ This member is an explicit interface member implementation. It can be used only The to insert into the . Inserts an item in the at the specified position. - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -1015,11 +1011,11 @@ This member is an explicit interface member implementation. It can be used only The to remove from the . Removes the first occurrence of a specific object from the . - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -1062,11 +1058,11 @@ This member is an explicit interface member implementation. It can be used only The zero-based index of the element to remove. Removes the element at the specified index of the . - instance is cast to an interface. - + instance is cast to an interface. + ]]> diff --git a/xml/System.CodeDom/CodeObjectCreateExpression.xml b/xml/System.CodeDom/CodeObjectCreateExpression.xml index 011998f7498..563fc838343 100644 --- a/xml/System.CodeDom/CodeObjectCreateExpression.xml +++ b/xml/System.CodeDom/CodeObjectCreateExpression.xml @@ -48,22 +48,21 @@ Represents an expression that creates a new instance of a type. - can be used to represent an expression that creates an instance of a type. - - The property specifies the data type to create a new instance of. The property specifies the parameters to pass to the constructor of the type to create a new instance of. - - - -## Examples - The following example demonstrates use of to create a new instance of the System.DateTime class using the parameterless constructor. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeMultiExample/CPP/codemultiexample.cpp" id="Snippet5"::: + can be used to represent an expression that creates an instance of a type. + + The property specifies the data type to create a new instance of. The property specifies the parameters to pass to the constructor of the type to create a new instance of. + + + +## Examples + The following example demonstrates use of to create a new instance of the System.DateTime class using the parameterless constructor. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeDirectionExpression/Overview/codemultiexample.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMultiExample/VB/codemultiexample.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMultiExample/VB/codemultiexample.vb" id="Snippet5"::: + ]]> diff --git a/xml/System.CodeDom/CodeParameterDeclarationExpression.xml b/xml/System.CodeDom/CodeParameterDeclarationExpression.xml index 2df5d3aa196..68e0a41b3bf 100644 --- a/xml/System.CodeDom/CodeParameterDeclarationExpression.xml +++ b/xml/System.CodeDom/CodeParameterDeclarationExpression.xml @@ -48,22 +48,21 @@ Represents a parameter declaration for a method, property, or constructor. - can be used to represent code that declares a parameter for a method, property, or constructor. - - The property specifies the name of the parameter. The property specifies the data type of the parameter. The property specifies the direction modifier of the parameter. The property specifies the attributes associated with the parameter. - - - -## Examples - The following example demonstrates use of to declare parameters of a method using different field reference type specifiers. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeParameterDeclarationExample/CPP/codeparameterdeclarationexample.cpp" id="Snippet3"::: + can be used to represent code that declares a parameter for a method, property, or constructor. + + The property specifies the name of the parameter. The property specifies the data type of the parameter. The property specifies the direction modifier of the parameter. The property specifies the attributes associated with the parameter. + + + +## Examples + The following example demonstrates use of to declare parameters of a method using different field reference type specifiers. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeParameterDeclarationExpression/Overview/codeparameterdeclarationexample.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeParameterDeclarationExample/VB/codeparameterdeclarationexample.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeParameterDeclarationExample/VB/codeparameterdeclarationexample.vb" id="Snippet3"::: + ]]> @@ -184,16 +183,16 @@ The name of the parameter to declare. Initializes a new instance of the class using the specified parameter type and name. - [!NOTE] -> You must use square brackets ([]) and not the C# angle brackets (<>) to delimit generic parameters. - - To avoid the possibility of making a syntactic mistake, consider using the constructor that takes a type instead of a string as a parameter. - +> You must use square brackets ([]) and not the C# angle brackets (<>) to delimit generic parameters. + + To avoid the possibility of making a syntactic mistake, consider using the constructor that takes a type instead of a string as a parameter. + ]]> diff --git a/xml/System.CodeDom/CodeParameterDeclarationExpressionCollection.xml b/xml/System.CodeDom/CodeParameterDeclarationExpressionCollection.xml index f6913f814a3..148b0bd9c40 100644 --- a/xml/System.CodeDom/CodeParameterDeclarationExpressionCollection.xml +++ b/xml/System.CodeDom/CodeParameterDeclarationExpressionCollection.xml @@ -48,20 +48,19 @@ Represents a collection of objects. - class provides a simple collection object that can be used to store a set of objects. - - - -## Examples - The following example demonstrates how to use the class methods. The example creates a new instance of the class and uses the 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/CodeParameterDeclarationExpressionCollectionExample/CPP/class1.cpp" id="Snippet1"::: + class provides a simple collection object that can be used to store a set of objects. + + + +## Examples + The following example demonstrates how to use the class methods. The example creates a new instance of the class and uses the methods to add statements to the collection, return their index, and add or remove attributes at a specific index point. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeParameterDeclarationExpressionCollection/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/VB/class1.vb" id="Snippet1"::: + ]]> @@ -219,15 +218,14 @@ Adds the specified to the collection. The index at which the new element was inserted. - object to a instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/CPP/class1.cpp" id="Snippet3"::: + object to a instance. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeParameterDeclarationExpressionCollection/Overview/class1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/VB/class1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/VB/class1.vb" id="Snippet3"::: + ]]> @@ -277,15 +275,14 @@ An array of type containing the objects to add to the collection. Copies the elements of the specified array to the end of the collection. - method overload to add the members of a array to a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/CPP/class1.cpp" id="Snippet4"::: + method overload to add the members of a array to a . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeParameterDeclarationExpressionCollection/Overview/class1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/VB/class1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/VB/class1.vb" id="Snippet4"::: + ]]> @@ -328,15 +325,14 @@ A containing the objects to add to the collection. Adds the contents of another to the end of the collection. - method overload to add the members of one object to another . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/CPP/class1.cpp" id="Snippet4"::: + method overload to add the members of one object to another . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeParameterDeclarationExpressionCollection/Overview/class1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/VB/class1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/VB/class1.vb" id="Snippet4"::: + ]]> @@ -381,15 +377,14 @@ if the collection contains the specified object; otherwise, . - method to search for the presence of a specific object and get the index value at which it was found. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/CPP/class1.cpp" id="Snippet5"::: + method to search for the presence of a specific object and get the index value at which it was found. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeParameterDeclarationExpressionCollection/Overview/class1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/VB/class1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/VB/class1.vb" id="Snippet5"::: + ]]> @@ -432,21 +427,20 @@ The index of the array at which to begin inserting. Copies the collection objects to a one-dimensional instance beginning at the specified index. - to an beginning at the specified index value. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/CPP/class1.cpp" id="Snippet6"::: + to an beginning at the specified index value. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeParameterDeclarationExpressionCollection/Overview/class1.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/VB/class1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/VB/class1.vb" id="Snippet6"::: + ]]> - The destination array is multidimensional. - - -or- - + The destination array is multidimensional. + + -or- + The number of elements in the is greater than the available space between the index of the target array specified by the parameter and the end of the target array. The parameter is . The parameter is less than the target array's minimum index. @@ -489,15 +483,14 @@ Gets the index in the collection of the specified , if it exists in the collection. The index in the collection of the specified object, if found; otherwise, -1. - instance and uses the method to get the index value at which it was found. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/CPP/class1.cpp" id="Snippet5"::: + instance and uses the method to get the index value at which it was found. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeParameterDeclarationExpressionCollection/Overview/class1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/VB/class1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/VB/class1.vb" id="Snippet5"::: + ]]> @@ -540,15 +533,14 @@ The to insert. Inserts the specified into the collection at the specified index. - method to add a object to a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/CPP/class1.cpp" id="Snippet8"::: + method to add a object to a . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeParameterDeclarationExpressionCollection/Overview/class1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/VB/class1.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/VB/class1.vb" id="Snippet8"::: + ]]> @@ -590,11 +582,11 @@ Gets or sets the at the specified index in the collection. A at each valid index. - The parameter is outside the valid range of indexes for the collection. @@ -635,15 +627,14 @@ The to remove from the collection. Removes the specified from the collection. - method to delete a object from a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/CPP/class1.cpp" id="Snippet9"::: + method to delete a object from a . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeParameterDeclarationExpressionCollection/Overview/class1.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/VB/class1.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeParameterDeclarationExpressionCollectionExample/VB/class1.vb" id="Snippet9"::: + ]]> The specified object is not found in the collection. diff --git a/xml/System.CodeDom/CodePrimitiveExpression.xml b/xml/System.CodeDom/CodePrimitiveExpression.xml index 15cb96138be..6ae05003846 100644 --- a/xml/System.CodeDom/CodePrimitiveExpression.xml +++ b/xml/System.CodeDom/CodePrimitiveExpression.xml @@ -48,24 +48,23 @@ Represents a primitive data type value. - can be used to represent an expression that indicates a primitive data type value. - - The property specifies the primitive data type value to represent. - - Primitive data types that can be represented using include `null`; string; 16-, 32-, and 64-bit signed integers; and single-precision and double-precision floating-point numbers. - - - -## Examples - The following example demonstrates use of to represent values of several primitive types. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodePrimitiveExpressionExample/CPP/codeprimitiveexpressionexample.cpp" id="Snippet2"::: + can be used to represent an expression that indicates a primitive data type value. + + The property specifies the primitive data type value to represent. + + Primitive data types that can be represented using include `null`; string; 16-, 32-, and 64-bit signed integers; and single-precision and double-precision floating-point numbers. + + + +## Examples + The following example demonstrates use of to represent values of several primitive types. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodePrimitiveExpression/Overview/codeprimitiveexpressionexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodePrimitiveExpressionExample/VB/codeprimitiveexpressionexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodePrimitiveExpressionExample/VB/codeprimitiveexpressionexample.vb" id="Snippet2"::: + ]]> @@ -191,11 +190,11 @@ Gets or sets the primitive data type to represent. The primitive data type instance to represent the value of. - diff --git a/xml/System.CodeDom/CodePropertyReferenceExpression.xml b/xml/System.CodeDom/CodePropertyReferenceExpression.xml index b7ea798d9dc..94813c34e9c 100644 --- a/xml/System.CodeDom/CodePropertyReferenceExpression.xml +++ b/xml/System.CodeDom/CodePropertyReferenceExpression.xml @@ -48,24 +48,23 @@ Represents a reference to the value of a property. - can be used to represent a reference to the value of a property. - - The property specifies the object that contains the property to reference. The property specifies the name of the property to reference. - - This object does not have a property to indicate whether the reference is used in a `get` or `set`. If the property reference occurs on the left, assigned to, side of an assignment statement, then it is a `set`. - - - -## Examples - The following example code demonstrates use of a to refer to a property. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeReferenceExample/CPP/codereferenceexample.cpp" id="Snippet3"::: + can be used to represent a reference to the value of a property. + + The property specifies the object that contains the property to reference. The property specifies the name of the property to reference. + + This object does not have a property to indicate whether the reference is used in a `get` or `set`. If the property reference occurs on the left, assigned to, side of an assignment statement, then it is a `set`. + + + +## Examples + The following example code demonstrates use of a to refer to a property. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeFieldReferenceExpression/Overview/codereferenceexample.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeReferenceExample/VB/codereferenceexample.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeReferenceExample/VB/codereferenceexample.vb" id="Snippet3"::: + ]]> diff --git a/xml/System.CodeDom/CodePropertySetValueReferenceExpression.xml b/xml/System.CodeDom/CodePropertySetValueReferenceExpression.xml index 3eb46195a34..23e0909a747 100644 --- a/xml/System.CodeDom/CodePropertySetValueReferenceExpression.xml +++ b/xml/System.CodeDom/CodePropertySetValueReferenceExpression.xml @@ -48,22 +48,21 @@ Represents the value argument of a property set method call within a property set method. - represents the value argument of a property set method call within a property set method declaration. - - A property set method typically assigns or uses the value assigned to the property. Within the property set method, this value is represented by an implicit variable represented in CodeDOM by a . - - - -## Examples - This example demonstrates use of a to represent the value argument passed to a property set value statement block. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodePropertySetValueExample/CPP/codepropertysetvalueexample.cpp" id="Snippet2"::: + represents the value argument of a property set method call within a property set method declaration. + + A property set method typically assigns or uses the value assigned to the property. Within the property set method, this value is represented by an implicit variable represented in CodeDOM by a . + + + +## Examples + This example demonstrates use of a to represent the value argument passed to a property set value statement block. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodePropertySetValueReferenceExpression/Overview/codepropertysetvalueexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodePropertySetValueExample/VB/codepropertysetvalueexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodePropertySetValueExample/VB/codepropertysetvalueexample.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.CodeDom/CodeRemoveEventStatement.xml b/xml/System.CodeDom/CodeRemoveEventStatement.xml index 9741b7bb1d0..ece71a0b18e 100644 --- a/xml/System.CodeDom/CodeRemoveEventStatement.xml +++ b/xml/System.CodeDom/CodeRemoveEventStatement.xml @@ -48,22 +48,21 @@ Represents a statement that removes an event handler. - can be used to represent a statement that removes an event handler for an event. - - The property specifies the event to remove the event handler from. The property specifies the event handler to remove. - - - -## Examples - The following example demonstrates use of a to remove a delegate from an event. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeRemoveEventExample/CPP/coderemoveeventexample.cpp" id="Snippet2"::: + can be used to represent a statement that removes an event handler for an event. + + The property specifies the event to remove the event handler from. The property specifies the event handler to remove. + + + +## Examples + The following example demonstrates use of a to remove a delegate from an event. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeRemoveEventStatement/Overview/coderemoveeventexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeRemoveEventExample/VB/coderemoveeventexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeRemoveEventExample/VB/coderemoveeventexample.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.CodeDom/CodeSnippetCompileUnit.xml b/xml/System.CodeDom/CodeSnippetCompileUnit.xml index 58f01ef4122..91b69c79e44 100644 --- a/xml/System.CodeDom/CodeSnippetCompileUnit.xml +++ b/xml/System.CodeDom/CodeSnippetCompileUnit.xml @@ -48,24 +48,23 @@ Represents a literal code fragment that can be compiled. - can represent a literal block of code that is included directly in the source without modification. - - A stores a section of code, exactly in its original format, as a string. The CodeDOM does not translate literal code fragments. Literal code fragments are stored and output in their original format. CodeDOM objects that contain literal code are provided so developers can encapsulate code that is already in the target language. - - The property contains the literal code fragment as a string. The property is optional and specifies the position of the code within a source code document. - - - -## Examples - The following code example demonstrates how to create a new instance of the class by using a string that represents literal code. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDomSampleBatch/CPP/class1.cpp" id="Snippet8"::: + can represent a literal block of code that is included directly in the source without modification. + + A stores a section of code, exactly in its original format, as a string. The CodeDOM does not translate literal code fragments. Literal code fragments are stored and output in their original format. CodeDOM objects that contain literal code are provided so developers can encapsulate code that is already in the target language. + + The property contains the literal code fragment as a string. The property is optional and specifies the position of the code within a source code document. + + + +## Examples + The following code example demonstrates how to create a new instance of the class by using a string that represents literal code. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeExpressionStatement/Overview/class1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomSampleBatch/VB/class1.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomSampleBatch/VB/class1.vb" id="Snippet8"::: + ]]> @@ -112,11 +111,11 @@ Initializes a new instance of the class. - property. - + property. + ]]> @@ -153,15 +152,14 @@ The literal code fragment to represent. Initializes a new instance of the class. - class by using a string that represents literal code. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDomSampleBatch/CPP/class1.cpp" id="Snippet8"::: + class by using a string that represents literal code. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeExpressionStatement/Overview/class1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomSampleBatch/VB/class1.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomSampleBatch/VB/class1.vb" id="Snippet8"::: + ]]> diff --git a/xml/System.CodeDom/CodeSnippetExpression.xml b/xml/System.CodeDom/CodeSnippetExpression.xml index a3e94a608e0..df1532bc2ce 100644 --- a/xml/System.CodeDom/CodeSnippetExpression.xml +++ b/xml/System.CodeDom/CodeSnippetExpression.xml @@ -48,22 +48,21 @@ Represents a literal expression. - property contains the literal code for this snippet expression. - - - -## Examples - The following code example demonstrates how to create an instance of the class using a literal code fragment. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDomSampleBatch/CPP/class1.cpp" id="Snippet9"::: + property contains the literal code for this snippet expression. + + + +## Examples + The following code example demonstrates how to create an instance of the class using a literal code fragment. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeExpressionStatement/Overview/class1.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomSampleBatch/VB/class1.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomSampleBatch/VB/class1.vb" id="Snippet9"::: + ]]> @@ -145,15 +144,14 @@ The literal expression to represent. Initializes a new instance of the class using the specified literal expression. - constructor to create an instance of the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDomSampleBatch/CPP/class1.cpp" id="Snippet9"::: + constructor to create an instance of the class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeExpressionStatement/Overview/class1.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomSampleBatch/VB/class1.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomSampleBatch/VB/class1.vb" id="Snippet9"::: + ]]> @@ -196,11 +194,11 @@ Gets or sets the literal string of code. The literal string. - diff --git a/xml/System.CodeDom/CodeStatementCollection.xml b/xml/System.CodeDom/CodeStatementCollection.xml index 056a61366df..9396772626d 100644 --- a/xml/System.CodeDom/CodeStatementCollection.xml +++ b/xml/System.CodeDom/CodeStatementCollection.xml @@ -48,20 +48,19 @@ Represents a collection of objects. - class provides a simple collection object that can be used to store a set of objects. - - - -## Examples - The following example demonstrates how to use the 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 statements at a specific index point. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeStatementCollectionExample/CPP/class1.cpp" id="Snippet1"::: + class provides a simple collection object that can be used to store a set of objects. + + + +## Examples + The following example demonstrates how to use the 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 statements at a specific index point. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeStatementCollection/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeStatementCollectionExample/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeStatementCollectionExample/VB/class1.vb" id="Snippet1"::: + ]]> @@ -110,15 +109,14 @@ Initializes a new instance of the class. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeStatementCollectionExample/CPP/class1.cpp" id="Snippet2"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeStatementCollection/Overview/class1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeStatementCollectionExample/VB/class1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeStatementCollectionExample/VB/class1.vb" id="Snippet2"::: + ]]> @@ -279,15 +277,14 @@ Adds the specified object to the collection. The index at which the new element was inserted. - object to a instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeStatementCollectionExample/CPP/class1.cpp" id="Snippet3"::: + object to a instance. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeStatementCollection/Overview/class1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeStatementCollectionExample/VB/class1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeStatementCollectionExample/VB/class1.vb" id="Snippet3"::: + ]]> @@ -337,15 +334,14 @@ An array of objects to add to the collection. Adds a set of objects to the collection. - method overload to add the members of an array to a instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeStatementCollectionExample/CPP/class1.cpp" id="Snippet4"::: + method overload to add the members of an array to a instance. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeStatementCollection/Overview/class1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeStatementCollectionExample/VB/class1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeStatementCollectionExample/VB/class1.vb" id="Snippet4"::: + ]]> @@ -388,15 +384,14 @@ A object that contains the objects to add to the collection. Adds the contents of another object to the end of the collection. - method overload to add the members of one to another. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeStatementCollectionExample/CPP/class1.cpp" id="Snippet4"::: + method overload to add the members of one to another. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeStatementCollection/Overview/class1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeStatementCollectionExample/VB/class1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeStatementCollectionExample/VB/class1.vb" id="Snippet4"::: + ]]> @@ -441,15 +436,14 @@ if the collection contains the specified object; otherwise, . - method to search for the presence of a specific and retrieve the index value at which it was found. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeStatementCollectionExample/CPP/class1.cpp" id="Snippet5"::: + method to search for the presence of a specific and retrieve the index value at which it was found. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeStatementCollection/Overview/class1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeStatementCollectionExample/VB/class1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeStatementCollectionExample/VB/class1.vb" id="Snippet5"::: + ]]> @@ -492,21 +486,20 @@ The index of the array at which to begin inserting. Copies the elements of the object to a one-dimensional instance, starting at the specified index. - object to an array, starting at the specified index value. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeStatementCollectionExample/CPP/class1.cpp" id="Snippet6"::: + object to an array, starting at the specified index value. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeStatementCollection/Overview/class1.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeStatementCollectionExample/VB/class1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeStatementCollectionExample/VB/class1.vb" id="Snippet6"::: + ]]> - The destination array is multidimensional. - - -or- - + The destination array is multidimensional. + + -or- + The number of elements in the is greater than the available space between the index of the target array specified by the parameter and the end of the target array. The parameter is . The parameter is less than the target array's minimum index. @@ -549,15 +542,14 @@ Gets the index of the specified object in the , if it exists in the collection. The index of the specified object, if it is found, in the collection; otherwise, -1. - and uses the method to retrieve the index value at which it was found. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeStatementCollectionExample/CPP/class1.cpp" id="Snippet5"::: + and uses the method to retrieve the index value at which it was found. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeStatementCollection/Overview/class1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeStatementCollectionExample/VB/class1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeStatementCollectionExample/VB/class1.vb" id="Snippet5"::: + ]]> @@ -600,15 +592,14 @@ The object to insert. Inserts the specified object into the collection at the specified index. - method to add a object to a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeStatementCollectionExample/CPP/class1.cpp" id="Snippet8"::: + method to add a object to a . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeStatementCollection/Overview/class1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeStatementCollectionExample/VB/class1.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeStatementCollectionExample/VB/class1.vb" id="Snippet8"::: + ]]> @@ -650,11 +641,11 @@ Gets or sets the object at the specified index in the collection. A at each valid index. - The parameter is outside the valid range of indexes for the collection. @@ -695,15 +686,14 @@ The to remove from the collection. Removes the specified object from the collection. - method to delete a object from a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeStatementCollectionExample/CPP/class1.cpp" id="Snippet9"::: + method to delete a object from a . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeStatementCollection/Overview/class1.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeStatementCollectionExample/VB/class1.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeStatementCollectionExample/VB/class1.vb" id="Snippet9"::: + ]]> The specified object is not found in the collection. diff --git a/xml/System.CodeDom/CodeThisReferenceExpression.xml b/xml/System.CodeDom/CodeThisReferenceExpression.xml index 6e93516bf54..f8a23e0783c 100644 --- a/xml/System.CodeDom/CodeThisReferenceExpression.xml +++ b/xml/System.CodeDom/CodeThisReferenceExpression.xml @@ -48,20 +48,19 @@ Represents a reference to the current local class instance. - to refer to the current object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeMethodReferenceExample/CPP/codemethodreferenceexample.cpp" id="Snippet3"::: + to refer to the current object. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeMethodReferenceExpression/Overview/codemethodreferenceexample.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMethodReferenceExample/VB/codemethodreferenceexample.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMethodReferenceExample/VB/codemethodreferenceexample.vb" id="Snippet3"::: + ]]> diff --git a/xml/System.CodeDom/CodeThrowExceptionStatement.xml b/xml/System.CodeDom/CodeThrowExceptionStatement.xml index 7940bca53c6..17ad4e08d90 100644 --- a/xml/System.CodeDom/CodeThrowExceptionStatement.xml +++ b/xml/System.CodeDom/CodeThrowExceptionStatement.xml @@ -48,22 +48,21 @@ Represents a statement that throws an exception. - can represent a statement that throws an exception. The expression should be, or evaluate to, a reference to an instance of a type that derives from the class. - - The property specifies the exception to throw. - - - -## Examples - This example demonstrates using a to throw a new `System.Exception`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeThrowExceptionStatement/CPP/codethrowexceptionstatementexample.cpp" id="Snippet2"::: + can represent a statement that throws an exception. The expression should be, or evaluate to, a reference to an instance of a type that derives from the class. + + The property specifies the exception to throw. + + + +## Examples + This example demonstrates using a to throw a new `System.Exception`. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeThrowExceptionStatement/Overview/codethrowexceptionstatementexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeThrowExceptionStatement/VB/codethrowexceptionstatementexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeThrowExceptionStatement/VB/codethrowexceptionstatementexample.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.CodeDom/CodeTryCatchFinallyStatement.xml b/xml/System.CodeDom/CodeTryCatchFinallyStatement.xml index 345bff3d053..c5492fe0b81 100644 --- a/xml/System.CodeDom/CodeTryCatchFinallyStatement.xml +++ b/xml/System.CodeDom/CodeTryCatchFinallyStatement.xml @@ -48,25 +48,24 @@ Represents a block with any number of clauses and, optionally, a block. - can be used to represent a `try`/`catch` block of code. - - The property contains the statements to execute within a `try` block. The property contains the `catch` clauses to handle caught exceptions. The property contains the statements to execute within a `finally` block. - + can be used to represent a `try`/`catch` block of code. + + The property contains the statements to execute within a `try` block. The property contains the `catch` clauses to handle caught exceptions. The property contains the statements to execute within a `finally` block. + > [!NOTE] -> Not all languages support `try`/`catch` blocks. Call the method with the flag to determine whether a code generator supports `try`/`catch` blocks. - - - -## Examples - The following example code demonstrates use of a to define a `try...catch...finally` statement for exception handling. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTryCatchFinallyExample/CPP/codetrycatchfinallyexample.cpp" id="Snippet2"::: +> Not all languages support `try`/`catch` blocks. Call the method with the flag to determine whether a code generator supports `try`/`catch` blocks. + + + +## Examples + The following example code demonstrates use of a to define a `try...catch...finally` statement for exception handling. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeCatchClause/Overview/codetrycatchfinallyexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTryCatchFinallyExample/VB/codetrycatchfinallyexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTryCatchFinallyExample/VB/codetrycatchfinallyexample.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.CodeDom/CodeTypeConstructor.xml b/xml/System.CodeDom/CodeTypeConstructor.xml index bec7213aa65..8ccc2d0794e 100644 --- a/xml/System.CodeDom/CodeTypeConstructor.xml +++ b/xml/System.CodeDom/CodeTypeConstructor.xml @@ -48,23 +48,22 @@ Represents a static constructor for a class. - can be used to represent the static constructor for a class. A static constructor is called once when the type is loaded. - + can be used to represent the static constructor for a class. A static constructor is called once when the type is loaded. + > [!NOTE] -> Not all languages support static constructors. Support for static constructors can be checked by calling with the flag to determine if static constructors are supported by the code generator for a particular language. - - - -## Examples - The following example demonstrates use of a to declare a static constructor for a type. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTypeConstructorExample/CPP/codetypeconstructorexample.cpp" id="Snippet2"::: +> Not all languages support static constructors. Support for static constructors can be checked by calling with the flag to determine if static constructors are supported by the code generator for a particular language. + + + +## Examples + The following example demonstrates use of a to declare a static constructor for a type. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeConstructor/Overview/codetypeconstructorexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeConstructorExample/VB/codetypeconstructorexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeConstructorExample/VB/codetypeconstructorexample.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.CodeDom/CodeTypeDeclaration.xml b/xml/System.CodeDom/CodeTypeDeclaration.xml index 14feab085ac..687e1733682 100644 --- a/xml/System.CodeDom/CodeTypeDeclaration.xml +++ b/xml/System.CodeDom/CodeTypeDeclaration.xml @@ -48,27 +48,26 @@ Represents a type declaration for a class, structure, interface, or enumeration. - can be used to represent code that declares a class, structure, interface, or enumeration. can be used to declare a type that is nested within another type. - - The property specifies the base type or base types of the type being declared. The property contains the type members, which can include methods, fields, properties, comments and other types. The property indicates the values for the type declaration, which indicate the type category of the type. The , , , and methods indicate whether the type is a class, structure, enumeration, or interface type, respectively. - + can be used to represent code that declares a class, structure, interface, or enumeration. can be used to declare a type that is nested within another type. + + The property specifies the base type or base types of the type being declared. The property contains the type members, which can include methods, fields, properties, comments and other types. The property indicates the values for the type declaration, which indicate the type category of the type. The , , , and methods indicate whether the type is a class, structure, enumeration, or interface type, respectively. + > [!NOTE] -> Some programming languages only support the declaration of reference types, or classes. To check a language-specific CodeDOM code generator for support for declaring interfaces, enumerations, or value types, call the method to test for the appropriate flags. indicates support for interfaces, indicates support for enumerations, and indicates support for value types such as structures. - - You can build a class or a structure implementation in one complete declaration, or spread the implementation across multiple declarations. The property indicates whether the type declaration is complete or partial. Not all code generators support partial type declarations, so you should test for this support by calling the method with the flag . - - - -## Examples - This example demonstrates using a to declare a type. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTypeDeclarationExample/CPP/codetypedeclarationexample.cpp" id="Snippet2"::: +> Some programming languages only support the declaration of reference types, or classes. To check a language-specific CodeDOM code generator for support for declaring interfaces, enumerations, or value types, call the method to test for the appropriate flags. indicates support for interfaces, indicates support for enumerations, and indicates support for value types such as structures. + + You can build a class or a structure implementation in one complete declaration, or spread the implementation across multiple declarations. The property indicates whether the type declaration is complete or partial. Not all code generators support partial type declarations, so you should test for this support by calling the method with the flag . + + + +## Examples + This example demonstrates using a to declare a type. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeDeclaration/Overview/codetypedeclarationexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeDeclarationExample/VB/codetypedeclarationexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeDeclarationExample/VB/codetypedeclarationexample.vb" id="Snippet2"::: + ]]> @@ -180,45 +179,45 @@ Gets the base types of the type. A object that indicates the base types of the type. - as the first item in the collection. - + as the first item in the collection. + > [!NOTE] -> In the .NET Framework version 2.0 you do not need the for if the interface you are implementing already exists and you are referring to it by type. For example, if you are implementing the interface and add it to the collection with this statement, `ctd.BaseTypes.Add(New CodeTypeReference(typeof(ICollection)))`, you do not need the preceding `ctd.BaseTypes.Add(New CodeTypeReference(GetType(Object)))` statement. - - The following code illustrates the addition of a to the collection that refers to . - -```vb -Dim ctd As New CodeTypeDeclaration("Class1") -ctd.IsClass = True -ctd.BaseTypes.Add(New CodeTypeReference(GetType(Object))) -ctd.BaseTypes.Add(New CodeTypeReference("Interface1")) -``` - -```csharp -CodeTypeDeclaration ctd = new CodeTypeDeclaration("Class1"); -ctd.IsClass = true; -ctd.BaseTypes.Add(new CodeTypeReference(typeof(Object))); -ctd.BaseTypes.Add(new CodeTypeReference("Interface1")); -``` - - The preceding code generates the equivalent of the following Visual Basic code. - -```vb -Public Class Class1 -Implements Interface1 -``` - - However, the Visual Basic code actually generated is the following. - -```vb -Public Class Class1 -Inherits Object -Implements Interface1 -``` - +> In the .NET Framework version 2.0 you do not need the for if the interface you are implementing already exists and you are referring to it by type. For example, if you are implementing the interface and add it to the collection with this statement, `ctd.BaseTypes.Add(New CodeTypeReference(typeof(ICollection)))`, you do not need the preceding `ctd.BaseTypes.Add(New CodeTypeReference(GetType(Object)))` statement. + + The following code illustrates the addition of a to the collection that refers to . + +```vb +Dim ctd As New CodeTypeDeclaration("Class1") +ctd.IsClass = True +ctd.BaseTypes.Add(New CodeTypeReference(GetType(Object))) +ctd.BaseTypes.Add(New CodeTypeReference("Interface1")) +``` + +```csharp +CodeTypeDeclaration ctd = new CodeTypeDeclaration("Class1"); +ctd.IsClass = true; +ctd.BaseTypes.Add(new CodeTypeReference(typeof(Object))); +ctd.BaseTypes.Add(new CodeTypeReference("Interface1")); +``` + + The preceding code generates the equivalent of the following Visual Basic code. + +```vb +Public Class Class1 +Implements Interface1 +``` + + However, the Visual Basic code actually generated is the following. + +```vb +Public Class Class1 +Inherits Object +Implements Interface1 +``` + ]]> @@ -377,37 +376,35 @@ Implements Interface1 if the class or structure declaration is a partial representation of the implementation; if the declaration is a complete implementation of the class or structure. The default is . - property to `false`, which indicates that the type declaration represents all details for the class or structure implementation. - - A partial type declaration makes it easier to build different portions of a class or structure implementation in different modules of your application. The partial type declarations can be stored in one source file, or spread across multiple source files that are eventually compiled together to form the combined type implementation. - - The C# language supports partial type declarations of classes and structures through the `partial` keyword. Visual Basic supports partial type declarations of classes and structures with the `Partial` keyword. Not all code generators support partial type declarations, so you should test for this support by calling the method with the flag . - + property to `false`, which indicates that the type declaration represents all details for the class or structure implementation. + + A partial type declaration makes it easier to build different portions of a class or structure implementation in different modules of your application. The partial type declarations can be stored in one source file, or spread across multiple source files that are eventually compiled together to form the combined type implementation. + + The C# language supports partial type declarations of classes and structures through the `partial` keyword. Visual Basic supports partial type declarations of classes and structures with the `Partial` keyword. Not all code generators support partial type declarations, so you should test for this support by calling the method with the flag . + > [!NOTE] -> Partial type declarations are supported for classes and structures. If you specify a partial type declaration for an enumeration or interface, the generated code produces compiler errors. - - When supplying a class or structure implementation across multiple declarations, set the property to `true` for the initial declaration and all supplemental declarations. The initial declaration must fully specify the type signature, including access modifiers, inherited types, and implemented interfaces. The supplementary declarations do not need to re-specify the type signature. A compiler error typically results if you redefine the type signature in a supplementary declaration. - - Visual Studio 2005 uses partial types to separate user-generated code from designer code. In Visual Basic Windows Application projects, the user code is placed in a partial class that is not qualified by the `Partial` keyword; the designer-provided code appears in the partial class that has the `Partial` keyword. In C#, both the user code and designer code appear in partial classes identified by the `partial` keyword. - - - -## Examples - This example demonstrates using a to supply a class implementation across multiple declarations. The example builds the initial class declaration statement and sets the property to `true`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDomPartialTypeExample/CPP/source.cpp" id="Snippet3"::: +> Partial type declarations are supported for classes and structures. If you specify a partial type declaration for an enumeration or interface, the generated code produces compiler errors. + + When supplying a class or structure implementation across multiple declarations, set the property to `true` for the initial declaration and all supplemental declarations. The initial declaration must fully specify the type signature, including access modifiers, inherited types, and implemented interfaces. The supplementary declarations do not need to re-specify the type signature. A compiler error typically results if you redefine the type signature in a supplementary declaration. + + Visual Studio 2005 uses partial types to separate user-generated code from designer code. In Visual Basic Windows Application projects, the user code is placed in a partial class that is not qualified by the `Partial` keyword; the designer-provided code appears in the partial class that has the `Partial` keyword. In C#, both the user code and designer code appear in partial classes identified by the `partial` keyword. + + + +## Examples + This example demonstrates using a to supply a class implementation across multiple declarations. The example builds the initial class declaration statement and sets the property to `true`. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeDeclaration/IsPartial/source.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomPartialTypeExample/VB/source.vb" id="Snippet3"::: - - A different method in the example extends the class implementation. This method builds a new type declaration statement for the existing class and sets the property to `true`. The compiler combines the two partial type declarations together for the complete class implementation. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeDomPartialTypeExample/CPP/source.cpp" id="Snippet7"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomPartialTypeExample/VB/source.vb" id="Snippet3"::: + + A different method in the example extends the class implementation. This method builds a new type declaration statement for the existing class and sets the property to `true`. The compiler combines the two partial type declarations together for the complete class implementation. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeDeclaration/IsPartial/source.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomPartialTypeExample/VB/source.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeDomPartialTypeExample/VB/source.vb" id="Snippet7"::: + ]]> @@ -599,17 +596,17 @@ Implements Interface1 Gets or sets the attributes of the type. A object that indicates the attributes of the type. - property contains the same type of values used by when investigating a type at run time. Many of these flags do not correspond to the type declaration syntax for some languages. As a result, only the following flags are significant to : , , , , , , , and . - + property contains the same type of values used by when investigating a type at run time. Many of these flags do not correspond to the type declaration syntax for some languages. As a result, only the following flags are significant to : , , , , , , , and . + > [!NOTE] -> Some of the flags such as overlap with the meaning of flags in the property of that is inherited from . The property is a side effect of the class inheriting from so that classes can be nested. The flags in the property should be used instead of the flags in the property. - +> Some of the flags such as overlap with the meaning of flags in the property of that is inherited from . The property is a side effect of the class inheriting from so that classes can be nested. The flags in the property should be used instead of the flags in the property. + > [!NOTE] -> The pattern for setting the visibility flags (flags containing the words `Public` or `Nested`) is to mask out all visibility flags using the and then set the desired visibility flag. For example, the C# code statement to identify the (named `cd`) as an internal class is `cd.TypeAttributes = (cd.TypeAttributes & ~TypeAttributes.VisibilityMask) | TypeAttributes.NotPublic;`. The code to set the same value in Visual Basic is `cd.TypeAttributes = (cd.TypeAttributes And (TypeAttributes.VisibilityMask Xor -1)) Or TypeAttributes.NotPublic`. Setting the property directly to a visibility flag (`cd.TypeAttributes = TypeAttributes.NotPublic;`) erases all other flags that might be set. - +> The pattern for setting the visibility flags (flags containing the words `Public` or `Nested`) is to mask out all visibility flags using the and then set the desired visibility flag. For example, the C# code statement to identify the (named `cd`) as an internal class is `cd.TypeAttributes = (cd.TypeAttributes & ~TypeAttributes.VisibilityMask) | TypeAttributes.NotPublic;`. The code to set the same value in Visual Basic is `cd.TypeAttributes = (cd.TypeAttributes And (TypeAttributes.VisibilityMask Xor -1)) Or TypeAttributes.NotPublic`. Setting the property directly to a visibility flag (`cd.TypeAttributes = TypeAttributes.NotPublic;`) erases all other flags that might be set. + ]]> @@ -652,13 +649,13 @@ Implements Interface1 Gets the type parameters for the type declaration. A that contains the type parameters for the type declaration. - class contains the type parameter `T`. - - For more information on generics, see [Generics in the .NET Framework Class Library](/dotnet/csharp/programming-guide/generics/generics-in-the-net-framework-class-library). - + class contains the type parameter `T`. + + For more information on generics, see [Generics in the .NET Framework Class Library](/dotnet/csharp/programming-guide/generics/generics-in-the-net-framework-class-library). + ]]> diff --git a/xml/System.CodeDom/CodeTypeDeclarationCollection.xml b/xml/System.CodeDom/CodeTypeDeclarationCollection.xml index 32ba56f09d6..5bc11885e96 100644 --- a/xml/System.CodeDom/CodeTypeDeclarationCollection.xml +++ b/xml/System.CodeDom/CodeTypeDeclarationCollection.xml @@ -48,20 +48,19 @@ Represents a collection of objects. - class provides a simple collection object that can be used to store a set of objects. - - - -## Examples - The following example demonstrates how to use the 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/CodeTypeDeclarationCollectionExample/CPP/class1.cpp" id="Snippet1"::: + class provides a simple collection object that can be used to store a set of objects. + + + +## Examples + The following example demonstrates how to use the 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="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeDeclarationCollection/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/VB/class1.vb" id="Snippet1"::: + ]]> @@ -110,15 +109,14 @@ Initializes a new instance of the class. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/CPP/class1.cpp" id="Snippet2"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeDeclarationCollection/Overview/class1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/VB/class1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/VB/class1.vb" id="Snippet2"::: + ]]> @@ -227,15 +225,14 @@ Adds the specified object to the collection. The index at which the new element was inserted. - method to add a object to a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/CPP/class1.cpp" id="Snippet3"::: + method to add a object to a . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeDeclarationCollection/Overview/class1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/VB/class1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/VB/class1.vb" id="Snippet3"::: + ]]> @@ -285,15 +282,14 @@ An array of type that contains the objects to add to the collection. Copies the elements of the specified array to the end of the collection. - method overload to add an array of objects to a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/CPP/class1.cpp" id="Snippet4"::: + method overload to add an array of objects to a . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeDeclarationCollection/Overview/class1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/VB/class1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/VB/class1.vb" id="Snippet4"::: + ]]> @@ -336,15 +332,14 @@ A object that contains the objects to add to the collection. Adds the contents of another object to the end of the collection. - method overload to add objects from one to another . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/CPP/class1.cpp" id="Snippet4"::: + method overload to add objects from one to another . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeDeclarationCollection/Overview/class1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/VB/class1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/VB/class1.vb" id="Snippet4"::: + ]]> @@ -389,15 +384,14 @@ if the collection contains the specified object; otherwise, . - method to find a object in a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/CPP/class1.cpp" id="Snippet5"::: + method to find a object in a . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeDeclarationCollection/Overview/class1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/VB/class1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/VB/class1.vb" id="Snippet5"::: + ]]> @@ -440,21 +434,20 @@ The index of the array at which to begin inserting. Copies the elements in the object to a one-dimensional instance, starting at the specified index. - method to copy the contents of a object to an array, starting at the specified index value. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/CPP/class1.cpp" id="Snippet6"::: + method to copy the contents of a object to an array, starting at the specified index value. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeDeclarationCollection/Overview/class1.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/VB/class1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/VB/class1.vb" id="Snippet6"::: + ]]> - The destination array is multidimensional. - - -or- - + The destination array is multidimensional. + + -or- + The number of elements in the is greater than the available space between the index of the target array specified by the parameter and the end of the target array. The parameter is . The parameter is less than the target array's minimum index. @@ -497,15 +490,14 @@ Gets the index of the specified object in the , if it exists in the collection. The index of the specified object, if it is found, in the collection; otherwise, -1. - entries from a object and displays their names and indexes returned by the method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/CPP/class1.cpp" id="Snippet5"::: + entries from a object and displays their names and indexes returned by the method. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeDeclarationCollection/Overview/class1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/VB/class1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/VB/class1.vb" id="Snippet5"::: + ]]> @@ -548,15 +540,14 @@ The object to insert. Inserts the specified object into the collection at the specified index. - method to insert a object into a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/CPP/class1.cpp" id="Snippet8"::: + method to insert a object into a . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeDeclarationCollection/Overview/class1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/VB/class1.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/VB/class1.vb" id="Snippet8"::: + ]]> @@ -598,11 +589,11 @@ Gets or sets the object at the specified index in the collection. A at each valid index. - The parameter is outside the valid range of indexes for the collection. @@ -643,15 +634,14 @@ The to remove from the collection. Removes the specified object from the collection. - method to delete a object from a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/CPP/class1.cpp" id="Snippet9"::: + method to delete a object from a . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeDeclarationCollection/Overview/class1.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/VB/class1.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeDeclarationCollectionExample/VB/class1.vb" id="Snippet9"::: + ]]> The specified object is not found in the collection. diff --git a/xml/System.CodeDom/CodeTypeDelegate.xml b/xml/System.CodeDom/CodeTypeDelegate.xml index b9b2abc770f..2bc2a99da3f 100644 --- a/xml/System.CodeDom/CodeTypeDelegate.xml +++ b/xml/System.CodeDom/CodeTypeDelegate.xml @@ -48,27 +48,26 @@ Represents a delegate declaration. - can be used to declare a delegate type, or event handler. A delegate defines a method signature that can be used by callback methods or event handlers. Delegates can be declared at the namespace level or nested inside other types. Delegates cannot be nested inside other delegates. - - The property specifies the data type of the event handler returned by the delegate. The property contains the parameters for the delegate type. - - should not be used for enumeration, interface, or type declaration. Instead, use for those. - + can be used to declare a delegate type, or event handler. A delegate defines a method signature that can be used by callback methods or event handlers. Delegates can be declared at the namespace level or nested inside other types. Delegates cannot be nested inside other delegates. + + The property specifies the data type of the event handler returned by the delegate. The property contains the parameters for the delegate type. + + should not be used for enumeration, interface, or type declaration. Instead, use for those. + > [!NOTE] -> Not all languages support the declaration of delegates. Call the method with the flag to determine if it is supported in a particular language. - - - -## Examples - The following example code demonstrates use of a to declare a new delegate type. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTypeDelegateExample/CPP/codetypedelegateexample.cpp" id="Snippet3"::: +> Not all languages support the declaration of delegates. Call the method with the flag to determine if it is supported in a particular language. + + + +## Examples + The following example code demonstrates use of a to declare a new delegate type. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeDelegate/Overview/codetypedelegateexample.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeDelegateExample/VB/codetypedelegateexample.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeDelegateExample/VB/codetypedelegateexample.vb" id="Snippet3"::: + ]]> diff --git a/xml/System.CodeDom/CodeTypeMemberCollection.xml b/xml/System.CodeDom/CodeTypeMemberCollection.xml index be60e75488d..0fdb8f3d0c4 100644 --- a/xml/System.CodeDom/CodeTypeMemberCollection.xml +++ b/xml/System.CodeDom/CodeTypeMemberCollection.xml @@ -48,20 +48,19 @@ Represents a collection of objects. - class provides a simple collection object that can be used to store a set of objects. - - - -## Examples - The following code example demonstrates the use of the 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/CodeTypeMemberCollectionExample/CPP/class1.cpp" id="Snippet1"::: + class provides a simple collection object that can be used to store a set of objects. + + + +## Examples + The following code example demonstrates the use of the 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="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeMemberCollection/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeMemberCollectionExample/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeMemberCollectionExample/VB/class1.vb" id="Snippet1"::: + ]]> @@ -110,15 +109,14 @@ Initializes a new instance of the class. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTypeMemberCollectionExample/CPP/class1.cpp" id="Snippet2"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeMemberCollection/Overview/class1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeMemberCollectionExample/VB/class1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeMemberCollectionExample/VB/class1.vb" id="Snippet2"::: + ]]> @@ -227,15 +225,14 @@ Adds a with the specified value to the collection. The index at which the new element was inserted. - object to a instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTypeMemberCollectionExample/CPP/class1.cpp" id="Snippet3"::: + object to a instance. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeMemberCollection/Overview/class1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeMemberCollectionExample/VB/class1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeMemberCollectionExample/VB/class1.vb" id="Snippet3"::: + ]]> @@ -285,15 +282,14 @@ An array of type containing the objects to add to the collection. Copies the elements of the specified array to the end of the collection. - method overloads to add the members of an array to a object, and to add the members of one to another. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTypeMemberCollectionExample/CPP/class1.cpp" id="Snippet4"::: + method overloads to add the members of an array to a object, and to add the members of one to another. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeMemberCollection/Overview/class1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeMemberCollectionExample/VB/class1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeMemberCollectionExample/VB/class1.vb" id="Snippet4"::: + ]]> @@ -336,15 +332,14 @@ A containing the objects to add to the collection. Adds the contents of another to the end of the collection. - method overloads to add the members of an array to a object, and to add the members of one to another. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTypeMemberCollectionExample/CPP/class1.cpp" id="Snippet4"::: + method overloads to add the members of an array to a object, and to add the members of one to another. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeMemberCollection/Overview/class1.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeMemberCollectionExample/VB/class1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeMemberCollectionExample/VB/class1.vb" id="Snippet4"::: + ]]> @@ -389,15 +384,14 @@ if the collection contains the specified object; otherwise, . - method to search for the presence of a specific object and retrieve the index value at which it was found. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTypeMemberCollectionExample/CPP/class1.cpp" id="Snippet5"::: + method to search for the presence of a specific object and retrieve the index value at which it was found. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeMemberCollection/Overview/class1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeMemberCollectionExample/VB/class1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeMemberCollectionExample/VB/class1.vb" id="Snippet5"::: + ]]> @@ -440,21 +434,20 @@ The index of the array at which to begin inserting. Copies the collection objects to a one-dimensional instance, beginning at the specified index. - to an array, beginning at the specified index value. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTypeMemberCollectionExample/CPP/class1.cpp" id="Snippet6"::: + to an array, beginning at the specified index value. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeMemberCollection/Overview/class1.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeMemberCollectionExample/VB/class1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeMemberCollectionExample/VB/class1.vb" id="Snippet6"::: + ]]> - The destination array is multidimensional. - - -or- - + The destination array is multidimensional. + + -or- + The number of elements in the is greater than the available space between the index of the target array specified by the parameter and the end of the target array. The parameter is . The parameter is less than the target array's minimum index. @@ -497,15 +490,14 @@ Gets the index in the collection of the specified , if it exists in the collection. The index in the collection of the specified object, if found; otherwise, -1. - object and uses the method to retrieve the index value at which it was found. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTypeMemberCollectionExample/CPP/class1.cpp" id="Snippet5"::: + object and uses the method to retrieve the index value at which it was found. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeMemberCollection/Overview/class1.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeMemberCollectionExample/VB/class1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeMemberCollectionExample/VB/class1.vb" id="Snippet5"::: + ]]> @@ -548,15 +540,14 @@ The to insert. Inserts the specified into the collection at the specified index. - method to add a object to a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTypeMemberCollectionExample/CPP/class1.cpp" id="Snippet8"::: + method to add a object to a . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeMemberCollection/Overview/class1.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeMemberCollectionExample/VB/class1.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeMemberCollectionExample/VB/class1.vb" id="Snippet8"::: + ]]> @@ -598,11 +589,11 @@ Gets or sets the at the specified index in the collection. A at each valid index. - The parameter is outside the valid range of indexes for the collection. @@ -643,15 +634,14 @@ The to remove from the collection. Removes a specific from the collection. - method to delete a object from a . - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTypeMemberCollectionExample/CPP/class1.cpp" id="Snippet9"::: + method to delete a object from a . + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeMemberCollection/Overview/class1.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeMemberCollectionExample/VB/class1.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeMemberCollectionExample/VB/class1.vb" id="Snippet9"::: + ]]> The specified object is not found in the collection. diff --git a/xml/System.CodeDom/CodeTypeOfExpression.xml b/xml/System.CodeDom/CodeTypeOfExpression.xml index 0380a1225cf..2dfdedf14d4 100644 --- a/xml/System.CodeDom/CodeTypeOfExpression.xml +++ b/xml/System.CodeDom/CodeTypeOfExpression.xml @@ -48,24 +48,23 @@ Represents a expression, an expression that returns a for a specified type name. - represents a `typeof` expression that returns a at runtime. - - The property specifies the data type to return a object for. - - Use to represent source code that refers to a type by name, such as when creating a to cast an object to a name-specified type. - - - -## Examples - The following example demonstrates use of a to represent a typeof expression. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTypeOfExample/CPP/codetypeofexample.cpp" id="Snippet2"::: + represents a `typeof` expression that returns a at runtime. + + The property specifies the data type to return a object for. + + Use to represent source code that refers to a type by name, such as when creating a to cast an object to a name-specified type. + + + +## Examples + The following example demonstrates use of a to represent a typeof expression. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeOfExpression/Overview/codetypeofexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeOfExample/VB/codetypeofexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeOfExample/VB/codetypeofexample.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.CodeDom/CodeTypeReference.xml b/xml/System.CodeDom/CodeTypeReference.xml index 401743c89b8..0e84e9a4dec 100644 --- a/xml/System.CodeDom/CodeTypeReference.xml +++ b/xml/System.CodeDom/CodeTypeReference.xml @@ -48,24 +48,23 @@ Represents a reference to a type. - object is used to represent a type for CodeDOM objects. When CodeDOM types have a `Type` property, it is of type . For example, the property is a that represents a field's data type. - - A can be initialized with a object or a string. It is generally recommended to use a to do this, although it may not always be possible. If initializing an instance of this class with a string, it is strongly recommended to always use fully qualified types, such as "System.Console" instead of just "Console", because not all languages support importing namespaces. Array types can be specified by either passing in a type object for an array or using one of the constructors that accept rank as a parameter. - - The property specifies the name of the type to reference. For references to array types, the property indicates the type of the elements of the array, and the property indicates the number of dimensions in the array. - - - -## Examples - The following example demonstrates use of a to represent a reference to a type. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTypeOfExample/CPP/codetypeofexample.cpp" id="Snippet2"::: + object is used to represent a type for CodeDOM objects. When CodeDOM types have a `Type` property, it is of type . For example, the property is a that represents a field's data type. + + A can be initialized with a object or a string. It is generally recommended to use a to do this, although it may not always be possible. If initializing an instance of this class with a string, it is strongly recommended to always use fully qualified types, such as "System.Console" instead of just "Console", because not all languages support importing namespaces. Array types can be specified by either passing in a type object for an array or using one of the constructors that accept rank as a parameter. + + The property specifies the name of the type to reference. For references to array types, the property indicates the type of the elements of the array, and the property indicates the number of dimensions in the array. + + + +## Examples + The following example demonstrates use of a to represent a reference to a type. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeOfExpression/Overview/codetypeofexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeOfExample/VB/codetypeofexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeOfExample/VB/codetypeofexample.vb" id="Snippet2"::: + ]]> @@ -106,11 +105,11 @@ Initializes a new instance of the class. - object. If you use this constructor, set properties to establish the type reference. - + object. If you use this constructor, set properties to establish the type reference. + ]]> @@ -181,16 +180,16 @@ The name of the type to reference. Initializes a new instance of the class using the specified type name. - type, where `K` is a string and `V` is a of integers, is represented by reflection as the following (with the assembly information removed): ``System.Collections.Generic.Dictionary`2[[System.String], [System.Collections.Generic.List`1[[System.Int32]]]]``. - + type, where `K` is a string and `V` is a of integers, is represented by reflection as the following (with the assembly information removed): ``System.Collections.Generic.Dictionary`2[[System.String], [System.Collections.Generic.List`1[[System.Int32]]]]``. + > [!NOTE] -> You must use square brackets ([]) and not the C# angle brackets (<>) to delimit generic parameters. - - To avoid the possibility of making a mistake in specifying the syntax, consider using the constructor that takes a type as a parameter instead of a string. - +> You must use square brackets ([]) and not the C# angle brackets (<>) to delimit generic parameters. + + To avoid the possibility of making a mistake in specifying the syntax, consider using the constructor that takes a type as a parameter instead of a string. + ]]> @@ -265,11 +264,11 @@ The number of dimensions in the array. Initializes a new instance of the class using the specified array type and rank. - objects. - + objects. + ]]> @@ -476,11 +475,11 @@ Gets or sets the type of the elements in the array. A that indicates the type of the array elements. - property is greater than or equal to 1. - + property is greater than or equal to 1. + ]]> @@ -561,54 +560,54 @@ Gets or sets the name of the type being referenced. The name of the type being referenced. - [!NOTE] -> The name of the property may be misleading. This property contains just the type name with any array adornments or generic type arguments removed, not the base or parent type as might be expected. For example, the value for ``System.Collections.Generic.Dictionary`2[[System.String], [System.Collections.Generic.List`1[[System.Int32]]]]`` is ``System.Collections.Generic.Dictionary`2``. - -## Representation of Generic Types - The information in this section is intended for CodeDom provider developers and only applies to CLS-compliant languages. The return value can contain generic types. Generic types are formatted with the name of the type followed by a grave accent ("`") followed by a count of the generic type arguments. The generic type arguments can be found in the returned by the property. The values returned by and the associated contain the same content as the value of the type returned by reflection. - - For example, a constructed where `K` is a string and `V` is a constructed of integers is represented by reflection as the following (with the assembly information removed): - -``` -System.Collections.Generic.Dictionary`2[[System.String], [System.Collections.Generic.List`1[[System.Int32]]]] -``` - - Recursively parsing the property from the for yields the same strings as the reflection representation above: - -- The property for the parent returns the following: - - ``` - System.Collections.Generic.Dictionary`2 - ``` - -- The property for the first object in the collection returns the following: - - ``` - System.String - ``` - -- The property for the second object in the collection returns the following: - - ``` - System.Collections.Generic.List`1 - ``` - -- The property in the object for ``System.Collections.Generic.List`1`` returns the following: - - ``` - System.Int32 - ``` - - The type argument count should be used when parsing the associated values. The common practice is to remove the type argument count from the generated code, but the practice is compiler specific. It is important to note that the type argument count can be found within a nested type name, in which case it is followed by a plus sign ("+"). - +> The name of the property may be misleading. This property contains just the type name with any array adornments or generic type arguments removed, not the base or parent type as might be expected. For example, the value for ``System.Collections.Generic.Dictionary`2[[System.String], [System.Collections.Generic.List`1[[System.Int32]]]]`` is ``System.Collections.Generic.Dictionary`2``. + +## Representation of Generic Types + The information in this section is intended for CodeDom provider developers and only applies to CLS-compliant languages. The return value can contain generic types. Generic types are formatted with the name of the type followed by a grave accent ("`") followed by a count of the generic type arguments. The generic type arguments can be found in the returned by the property. The values returned by and the associated contain the same content as the value of the type returned by reflection. + + For example, a constructed where `K` is a string and `V` is a constructed of integers is represented by reflection as the following (with the assembly information removed): + +``` +System.Collections.Generic.Dictionary`2[[System.String], [System.Collections.Generic.List`1[[System.Int32]]]] +``` + + Recursively parsing the property from the for yields the same strings as the reflection representation above: + +- The property for the parent returns the following: + + ``` + System.Collections.Generic.Dictionary`2 + ``` + +- The property for the first object in the collection returns the following: + + ``` + System.String + ``` + +- The property for the second object in the collection returns the following: + + ``` + System.Collections.Generic.List`1 + ``` + +- The property in the object for ``System.Collections.Generic.List`1`` returns the following: + + ``` + System.Int32 + ``` + + The type argument count should be used when parsing the associated values. The common practice is to remove the type argument count from the generated code, but the practice is compiler specific. It is important to note that the type argument count can be found within a nested type name, in which case it is followed by a plus sign ("+"). + > [!NOTE] -> When creating a generic , the recommended practice is to specify the type arguments as objects or use the constructor that takes a . Use of the constructor that creates a from a string can lead to undiscoverable type-argument errors. - +> When creating a generic , the recommended practice is to specify the type arguments as objects or use the constructor that takes a . Use of the constructor that creates a from a string can lead to undiscoverable type-argument errors. + ]]> @@ -697,11 +696,11 @@ System.Collections.Generic.Dictionary`2[[System.String], [System.Collections.Gen Gets the type arguments for the current generic type reference. A containing the type arguments for the current object. - property is a collection of type references to be substituted for the type parameter references of the current generic type. The collection contains all the type arguments for all nested types. For an example, see the property. - + property is a collection of type references to be substituted for the type parameter references of the current generic type. The collection contains all the type arguments for all nested types. For an example, see the property. + ]]> diff --git a/xml/System.CodeDom/CodeTypeReferenceCollection.xml b/xml/System.CodeDom/CodeTypeReferenceCollection.xml index 4c865c89c72..0e00a85a7e8 100644 --- a/xml/System.CodeDom/CodeTypeReferenceCollection.xml +++ b/xml/System.CodeDom/CodeTypeReferenceCollection.xml @@ -48,18 +48,17 @@ Represents a collection of objects. - class provides a simple collection object that can be used to store a set of objects. - - - -## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTypeReferenceCollection/CPP/class1.cpp" id="Snippet1"::: + class provides a simple collection object that can be used to store a set of objects. + + + +## Examples :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeReferenceCollection/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeReferenceCollection/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeReferenceCollection/VB/class1.vb" id="Snippet1"::: + ]]> @@ -108,13 +107,12 @@ Initializes a new instance of the class. - @@ -232,13 +230,12 @@ Adds the specified to the collection. The index at which the new element was inserted. - @@ -362,13 +359,12 @@ An array of type containing the objects to add to the collection. Copies the elements of the specified array to the end of the collection. - @@ -411,13 +407,12 @@ A containing the objects to add to the collection. Adds the contents of the specified to the end of the collection. - @@ -462,13 +457,12 @@ if the is contained in the collection; otherwise, . - @@ -511,19 +505,18 @@ The index of the array at which to begin inserting. Copies the items in the collection to the specified one-dimensional at the specified index. - - The parameter is multidimensional. - - -or- - + The parameter is multidimensional. + + -or- + The number of elements in the is greater than the available space between the index of the target array specified by the parameter and the end of the target array. The parameter is . The parameter is less than the target array's minimum index. @@ -566,13 +559,12 @@ Gets the index in the collection of the specified , if it exists in the collection. The index of the specified in the collection if found; otherwise, -1. - @@ -615,13 +607,12 @@ The to insert. Inserts a into the collection at the specified index. - @@ -663,11 +654,11 @@ Gets or sets the at the specified index in the collection. A at each valid index. - The parameter is outside the valid range of indexes for the collection. @@ -708,13 +699,12 @@ The to remove from the collection. Removes the specified from the collection. - The specified object is not found in the collection. diff --git a/xml/System.CodeDom/CodeTypeReferenceExpression.xml b/xml/System.CodeDom/CodeTypeReferenceExpression.xml index 4ef89c7a3c5..9653d68a9d8 100644 --- a/xml/System.CodeDom/CodeTypeReferenceExpression.xml +++ b/xml/System.CodeDom/CodeTypeReferenceExpression.xml @@ -48,22 +48,21 @@ Represents a reference to a data type. - can be used to reference a particular data type. - - The property specifies the data type to reference. - - - -## Examples - The following example demonstrates use of a to represent a reference to a type. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeTypeOfExample/CPP/codetypeofexample.cpp" id="Snippet3"::: + can be used to reference a particular data type. + + The property specifies the data type to reference. + + + +## Examples + The following example demonstrates use of a to represent a reference to a type. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeTypeOfExpression/Overview/codetypeofexample.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeOfExample/VB/codetypeofexample.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeTypeOfExample/VB/codetypeofexample.vb" id="Snippet3"::: + ]]> diff --git a/xml/System.CodeDom/CodeVariableDeclarationStatement.xml b/xml/System.CodeDom/CodeVariableDeclarationStatement.xml index 2de3a4103eb..fba5c9c81a1 100644 --- a/xml/System.CodeDom/CodeVariableDeclarationStatement.xml +++ b/xml/System.CodeDom/CodeVariableDeclarationStatement.xml @@ -48,25 +48,24 @@ Represents a variable declaration. - can be used to represent code that declares a variable. - - The property specifies the type of the variable to declare. The property specifies the name of the variable to declare. The property is optional, and specifies an initialization expression to assign to the variable after it is created. - + can be used to represent code that declares a variable. + + The property specifies the type of the variable to declare. The property specifies the name of the variable to declare. The property is optional, and specifies an initialization expression to assign to the variable after it is created. + > [!NOTE] -> Some languages can implement the optional variable initialization expression by making a separate assignment statement after the variable declaration. - - - -## Examples - This example demonstrates using a to declare a variable. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeVariableDeclarationStatementExample/CPP/codevariabledeclarationstatementexample.cpp" id="Snippet2"::: +> Some languages can implement the optional variable initialization expression by making a separate assignment statement after the variable declaration. + + + +## Examples + This example demonstrates using a to declare a variable. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeVariableDeclarationStatement/Overview/codevariabledeclarationstatementexample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeVariableDeclarationStatementExample/VB/codevariabledeclarationstatementexample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeVariableDeclarationStatementExample/VB/codevariabledeclarationstatementexample.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.CodeDom/CodeVariableReferenceExpression.xml b/xml/System.CodeDom/CodeVariableReferenceExpression.xml index 989ea486ff2..02417e1bf28 100644 --- a/xml/System.CodeDom/CodeVariableReferenceExpression.xml +++ b/xml/System.CodeDom/CodeVariableReferenceExpression.xml @@ -48,24 +48,23 @@ Represents a reference to a local variable. - can be used to represent a reference to a local variable. - - The property specifies the name of the local variable to reference. - - Use to reference a field. Use to reference a property. Use to reference an event. - - - -## Examples - The following example code demonstrates use of a to refer to a local variable. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeReferenceExample/CPP/codereferenceexample.cpp" id="Snippet4"::: + can be used to represent a reference to a local variable. + + The property specifies the name of the local variable to reference. + + Use to reference a field. Use to reference a property. Use to reference an event. + + + +## Examples + The following example code demonstrates use of a to refer to a local variable. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeFieldReferenceExpression/Overview/codereferenceexample.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeReferenceExample/VB/codereferenceexample.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeReferenceExample/VB/codereferenceexample.vb" id="Snippet4"::: + ]]> diff --git a/xml/System.CodeDom/FieldDirection.xml b/xml/System.CodeDom/FieldDirection.xml index 19dbe853912..2a742b1be04 100644 --- a/xml/System.CodeDom/FieldDirection.xml +++ b/xml/System.CodeDom/FieldDirection.xml @@ -43,20 +43,19 @@ Defines identifiers used to indicate the direction of parameter and argument declarations. - allows for passing arguments to functions by reference, or using incoming or outgoing parameters. - - - -## Examples - The following example demonstrates use of to indicate the field direction types of the parameters of a method in a method declaration. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeParameterDeclarationExample/CPP/codeparameterdeclarationexample.cpp" id="Snippet3"::: + allows for passing arguments to functions by reference, or using incoming or outgoing parameters. + + + +## Examples + The following example demonstrates use of to indicate the field direction types of the parameters of a method in a method declaration. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeParameterDeclarationExpression/Overview/codeparameterdeclarationexample.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeParameterDeclarationExample/VB/codeparameterdeclarationexample.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeParameterDeclarationExample/VB/codeparameterdeclarationexample.vb" id="Snippet3"::: + ]]> diff --git a/xml/System.CodeDom/MemberAttributes.xml b/xml/System.CodeDom/MemberAttributes.xml index 6faa5b8ae13..86fd18495e1 100644 --- a/xml/System.CodeDom/MemberAttributes.xml +++ b/xml/System.CodeDom/MemberAttributes.xml @@ -47,26 +47,25 @@ Defines member attribute identifiers for class members. - enumeration can be used to indicate the scope and access attributes of a class member. - + enumeration can be used to indicate the scope and access attributes of a class member. + > [!NOTE] -> There is no `Virtual` member attribute. A member is declared virtual by setting its member access to Public (`property1.Attributes = MemberAttributes.Public`) without specifying it as Final. The absence of the Final flag makes a member `virtual` in C# (`public virtual`), `overridable` in Visual Basic (`Public Overridable`). To avoid declaring the member as `virtual` or `overridable`, set both the Public and Final flags in the property. See the property for more information on setting member attributes. - +> There is no `Virtual` member attribute. A member is declared virtual by setting its member access to Public (`property1.Attributes = MemberAttributes.Public`) without specifying it as Final. The absence of the Final flag makes a member `virtual` in C# (`public virtual`), `overridable` in Visual Basic (`Public Overridable`). To avoid declaring the member as `virtual` or `overridable`, set both the Public and Final flags in the property. See the property for more information on setting member attributes. + > [!NOTE] -> The pattern for setting the access flags (flags containing the terms `Public`, `Private`, `Assembly`, or `Family`) is to mask out all access flags using the AccessMask mask and then set the desired access flag. For example, the code statement to identify a constructor (named `constructor1`) as public is `constructor1.Attributes = (constructor1.Attributes & ~MemberAttributes.AccessMask) | MemberAttributes.Public;`. Setting the property directly to an access flag (for example, `constructor1.Attributes = MemberAttributes.Public;`) erases all other flags that might be set. This pattern should also be used for setting the scope flags (Abstract, Final, Static, Override or Const) using the ScopeMask mask. - - - -## Examples - The following example code demonstrates use of a to define a `string` property with `get` and `set` accessors. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CodeMemberPropertyExample/CPP/codememberpropertyexample.cpp" id="Snippet3"::: +> The pattern for setting the access flags (flags containing the terms `Public`, `Private`, `Assembly`, or `Family`) is to mask out all access flags using the AccessMask mask and then set the desired access flag. For example, the code statement to identify a constructor (named `constructor1`) as public is `constructor1.Attributes = (constructor1.Attributes & ~MemberAttributes.AccessMask) | MemberAttributes.Public;`. Setting the property directly to an access flag (for example, `constructor1.Attributes = MemberAttributes.Public;`) erases all other flags that might be set. This pattern should also be used for setting the scope flags (Abstract, Final, Static, Override or Const) using the ScopeMask mask. + + + +## Examples + The following example code demonstrates use of a to define a `string` property with `get` and `set` accessors. + :::code language="csharp" source="~/snippets/csharp/System.CodeDom/CodeMemberProperty/Overview/codememberpropertyexample.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMemberPropertyExample/VB/codememberpropertyexample.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CodeMemberPropertyExample/VB/codememberpropertyexample.vb" id="Snippet3"::: + ]]> diff --git a/xml/System.Collections.Generic/Dictionary`2+Enumerator.xml b/xml/System.Collections.Generic/Dictionary`2+Enumerator.xml index 5ef1a0dcddb..c4800515109 100644 --- a/xml/System.Collections.Generic/Dictionary`2+Enumerator.xml +++ b/xml/System.Collections.Generic/Dictionary`2+Enumerator.xml @@ -80,27 +80,27 @@ Enumerates the elements of a . - is undefined. You must call to advance the enumerator to the first element of the collection before reading the value of . - - returns the same object until 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. You cannot set to the first element of the collection again; you must create a new enumerator instance instead. - + is undefined. You must call to advance the enumerator to the first element of the collection before reading the value of . + + returns the same object until 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. You cannot set to the first element of the collection again; you must create a new enumerator instance instead. + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding elements or changing the capacity, the enumerator is irrecoverably invalidated and the next call to or throws an . .NET Core 3.0+ only: The only mutating methods which do not invalidate enumerators are and . - - 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. - - Default implementations of collections in are not synchronized. - + + 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. + + Default implementations of collections in are not synchronized. + ]]> @@ -158,19 +158,19 @@ Gets the element at the current position of the enumerator. The element in the at the current position of the enumerator. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. + - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. - The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. + ]]> @@ -266,17 +266,17 @@ if the enumerator was successfully advanced to the next element; if the enumerator has passed the end of the collection. - advances the enumerator to 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`. - + advances the enumerator to 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`. + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding elements or changing the capacity, the enumerator is irrecoverably invalidated and the next call to or throws an . .NET Core 3.0+ only: The only mutating methods which do not invalidate enumerators are and . - + ]]> The collection was modified after the enumerator was created. @@ -326,19 +326,19 @@ Gets the element at the current position of the enumerator. The element in the dictionary at the current position of the enumerator, as a . - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. + - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. - The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. + ]]> @@ -397,19 +397,19 @@ Gets the key of the element at the current position of the enumerator. The key of the element in the dictionary at the current position of the enumerator. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. + - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. -- The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. +- The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. + + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - ]]> @@ -469,19 +469,19 @@ Gets the value of the element at the current position of the enumerator. The value of the element in the dictionary at the current position of the enumerator. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. + - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. - The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. + ]]> @@ -541,20 +541,20 @@ Gets the element at the current position of the enumerator. The element in the collection at the current position of the enumerator, as an . - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. + - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. - The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. + ]]> @@ -606,15 +606,15 @@ Sets the enumerator to its initial position, which is before the first element in the collection. - method, you must call the method to advance the enumerator to the first element of the collection before reading the value of the property. - + method, you must call the method to advance the enumerator to the first element of the collection before reading the value of the property. + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding elements or changing the capacity, the enumerator is irrecoverably invalidated and the next call to or throws an . .NET Core 3.0+ only: The only mutating methods which do not invalidate enumerators are and . - + ]]> The collection was modified after the enumerator was created. diff --git a/xml/System.Collections.Generic/Dictionary`2+KeyCollection+Enumerator.xml b/xml/System.Collections.Generic/Dictionary`2+KeyCollection+Enumerator.xml index e10b839e4ff..c3aba8d3ffc 100644 --- a/xml/System.Collections.Generic/Dictionary`2+KeyCollection+Enumerator.xml +++ b/xml/System.Collections.Generic/Dictionary`2+KeyCollection+Enumerator.xml @@ -75,27 +75,27 @@ Enumerates the elements of a . - is undefined. You must call to advance the enumerator to the first element of the collection before reading the value of . - - returns the same object until 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. You cannot set to the first element of the collection again; you must create a new enumerator instance instead. - + is undefined. You must call to advance the enumerator to the first element of the collection before reading the value of . + + returns the same object until 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. You cannot set to the first element of the collection again; you must create a new enumerator instance instead. + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding elements or changing the capacity, the enumerator is irrecoverably invalidated and the next call to or throws an . .NET Core 3.0+ only: The only mutating methods which do not invalidate enumerators are and . - - 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. - - Default implementations of collections in are not synchronized. - + + 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. + + Default implementations of collections in are not synchronized. + ]]> @@ -153,19 +153,19 @@ Gets the element at the current position of the enumerator. The element in the at the current position of the enumerator. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. + - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. - The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. + ]]> @@ -265,17 +265,17 @@ if the enumerator was successfully advanced to the next element; if the enumerator has passed the end of the collection. - advances the enumerator to 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`. - + advances the enumerator to 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`. + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding elements or changing the capacity, the enumerator is irrecoverably invalidated and the next call to or throws an . .NET Core 3.0+ only: The only mutating methods which do not invalidate enumerators are and . - + ]]> The collection was modified after the enumerator was created. @@ -332,20 +332,20 @@ Gets the element at the current position of the enumerator. The element in the collection at the current position of the enumerator. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. + - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. - The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. + ]]> @@ -398,15 +398,15 @@ Sets the enumerator to its initial position, which is before the first element in the collection. - method, you must call the method to advance the enumerator to the first element of the collection before reading the value of the property. - + method, you must call the method to advance the enumerator to the first element of the collection before reading the value of the property. + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding elements or changing the capacity, the enumerator is irrecoverably invalidated and the next call to or throws an . .NET Core 3.0+ only: The only mutating methods which do not invalidate enumerators are and . - + ]]> The collection was modified after the enumerator was created. diff --git a/xml/System.Collections.Generic/Dictionary`2+KeyCollection.xml b/xml/System.Collections.Generic/Dictionary`2+KeyCollection.xml index ae3ba09ec7b..ff56cafbeb4 100644 --- a/xml/System.Collections.Generic/Dictionary`2+KeyCollection.xml +++ b/xml/System.Collections.Generic/Dictionary`2+KeyCollection.xml @@ -354,7 +354,7 @@ Enumerates the elements of a . - is undefined. You must call to advance the enumerator to the first element of the collection before reading the value of . - - returns the same object until 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. You cannot set to the first element of the collection again; you must create a new enumerator instance instead. - - 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. 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. - - Default implementations of collections in are not synchronized. - + is undefined. You must call to advance the enumerator to the first element of the collection before reading the value of . + + returns the same object until 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. You cannot set to the first element of the collection again; you must create a new enumerator instance instead. + + 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. 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. + + Default implementations of collections in are not synchronized. + ]]> @@ -151,20 +151,20 @@ Gets the element at the current position of the enumerator. The element in the at the current position of the enumerator. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. + - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. - The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. + ]]> @@ -261,15 +261,15 @@ if the enumerator was successfully advanced to the next element; if the enumerator has passed the end of the collection. - advances the enumerator to 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`. - - 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 . - + advances the enumerator to 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`. + + 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 collection was modified after the enumerator was created. @@ -326,20 +326,20 @@ Gets the element at the current position of the enumerator. The element in the collection at the current position of the enumerator. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. + - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. - The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. + ]]> @@ -392,13 +392,13 @@ Sets the enumerator to its initial position, which is before the first element in the collection. - method, you must call the method to advance the enumerator to the first element of the collection before reading the value of the property. - - 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 . - + method, you must call the method to advance the enumerator to the first element of the collection before reading the value of the property. + + 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 collection was modified after the enumerator was created. diff --git a/xml/System.Collections.Generic/Dictionary`2+ValueCollection.xml b/xml/System.Collections.Generic/Dictionary`2+ValueCollection.xml index a2320f792d1..1caa8a7c33d 100644 --- a/xml/System.Collections.Generic/Dictionary`2+ValueCollection.xml +++ b/xml/System.Collections.Generic/Dictionary`2+ValueCollection.xml @@ -328,7 +328,7 @@ structure representing a value and its key. The order in which the items are returned is undefined. - The `foreach` statement of the C# language (`for each` in C++, `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: + 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"::: @@ -1375,7 +1375,7 @@ ## Remarks For purposes of enumeration, each item is a structure representing a value and its key. - The `foreach` statement of the C# language (`for each` in C++, `For Each` in Visual Basic) hides the complexity of enumerators. Therefore, using `foreach` is recommended, instead of directly manipulating the enumerator. + The `foreach` statement of the C# language (`For Each` in Visual Basic) hides the complexity of 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. @@ -2725,7 +2725,7 @@ Getting the value of this property is an O(1) operation. ## Remarks For purposes of enumeration, each item is a structure. - The `foreach` statement of the C# language (`for each` in C++, `For Each` in Visual Basic) hides the complexity of enumerators. Therefore, using `foreach` is recommended, instead of directly manipulating the enumerator. + The `foreach` statement of the C# language (`For Each` in Visual Basic) hides the complexity of 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. @@ -2748,7 +2748,7 @@ Getting the value of this property is an O(1) operation. ## Examples - The following code example shows how to enumerate the key/value pairs in the dictionary by using the `foreach` statement (`For Each` in Visual Basic, `for each` in C++), which hides the use of the enumerator. In particular, note that the enumerator for the interface returns objects rather than objects. + The following code example shows how to enumerate the key/value pairs in the dictionary by using the `foreach` statement (`For Each` in Visual Basic), which hides the use of the enumerator. In particular, note that the enumerator for the interface returns objects rather than objects. The code example is part of a larger example, including output, provided for the method. @@ -3246,7 +3246,7 @@ Getting the value of this property is an O(1) operation. ## Remarks - The `foreach` statement of the C# language (`for each` in C++, `For Each` in Visual Basic) hides the complexity of enumerators. Therefore, using `foreach` is recommended, instead of directly manipulating the enumerator. + The `foreach` statement of the C# language (`For Each` in Visual Basic) hides the complexity of 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. diff --git a/xml/System.Collections.Generic/HashSet`1+Enumerator.xml b/xml/System.Collections.Generic/HashSet`1+Enumerator.xml index 584c7cd03f8..50aef05e827 100644 --- a/xml/System.Collections.Generic/HashSet`1+Enumerator.xml +++ b/xml/System.Collections.Generic/HashSet`1+Enumerator.xml @@ -74,25 +74,25 @@ Enumerates the elements of a object. - property 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 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. You cannot set to the first element of the collection again; you must create a new enumerator object instead. - - 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. 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. - - Default implementations of collections in the namespace are not synchronized. - + property 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 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. You cannot set to the first element of the collection again; you must create a new enumerator object instead. + + 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. 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. + + Default implementations of collections in the namespace are not synchronized. + ]]> @@ -150,20 +150,20 @@ Gets the element at the current position of the enumerator. The element in the collection at the current position of the enumerator. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. + - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. - The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. + ]]> @@ -258,15 +258,15 @@ if the enumerator was successfully advanced to the next element; if the enumerator has passed the end of the collection. - method advances the enumerator to 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`. - - 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 . - + method advances the enumerator to 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`. + + 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 collection was modified after the enumerator was created. @@ -322,20 +322,20 @@ Gets the element at the current position of the enumerator. The element in the collection at the current position of the enumerator, as an . - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. + - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. - The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - + 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 element of the collection or after the last element. @@ -384,13 +384,13 @@ Sets the enumerator to its initial position, which is before the first element in the collection. - , you must call the method to advance the enumerator to the first element of the collection before reading the value of the property. - - 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 . - + , you must call the method to advance the enumerator to the first element of the collection before reading the value of the property. + + 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 collection was modified after the enumerator was created. diff --git a/xml/System.Collections.Generic/HashSet`1.xml b/xml/System.Collections.Generic/HashSet`1.xml index 8469914c693..071ce0e7d05 100644 --- a/xml/System.Collections.Generic/HashSet`1.xml +++ b/xml/System.Collections.Generic/HashSet`1.xml @@ -1376,7 +1376,7 @@ The following example demonstrates how to merge two disparate sets. This example 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, `for each` in C++) 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: + 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"::: diff --git a/xml/System.Collections.Generic/IEnumerator`1.xml b/xml/System.Collections.Generic/IEnumerator`1.xml index 5d1f909a8f3..0100545dbef 100644 --- a/xml/System.Collections.Generic/IEnumerator`1.xml +++ b/xml/System.Collections.Generic/IEnumerator`1.xml @@ -73,42 +73,42 @@ The type of objects to enumerate. Supports a simple iteration over a generic collection. - is the base interface for all generic enumerators. - - The `foreach` statement of the C# language (`for each` in C++, `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. 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 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. You cannot set to the first element of the collection again; you must create a new enumerator instance instead. - - The method is provided for COM interoperability. It does not necessarily need to be implemented; instead, the implementer can simply throw a . However, if you choose to do this, you should make sure no callers are relying on the functionality. - - If changes are made to the collection, such as adding, modifying, or deleting elements, the behavior of the enumerator 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. - - Default implementations of collections in the namespace are not synchronized. - - - -## Examples - The following example shows an implementation of the interface for a collection class of custom objects. The custom object is an instance of the type `Box`, and the collection class is `BoxCollection`. This code example is part of a larger example provided for the interface. - + is the base interface for all generic enumerators. + + 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. 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 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. You cannot set to the first element of the collection again; you must create a new enumerator instance instead. + + The method is provided for COM interoperability. It does not necessarily need to be implemented; instead, the implementer can simply throw a . However, if you choose to do this, you should make sure no callers are relying on the functionality. + + If changes are made to the collection, such as adding, modifying, or deleting elements, the behavior of the enumerator 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. + + Default implementations of collections in the namespace are not synchronized. + + + +## Examples + The following example shows an implementation of the interface for a collection class of custom objects. The custom object is an instance of the type `Box`, and the collection class is `BoxCollection`. This code example is part of a larger example provided for the interface. + :::code language="csharp" source="~/snippets/csharp/System.Collections.Generic/ICollectionT/Overview/program.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.collections.generic.boxexamples/vb/program.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.collections.generic.boxexamples/vb/program.vb" id="Snippet3"::: + ]]> - Implementing this interface requires implementing the nongeneric interface. The and methods do not depend on , and appear only on the nongeneric interface. The property appears on both interfaces, and has different return types. Implement the nongeneric property as an explicit interface implementation. This allows any consumer of the nongeneric interface to consume the generic interface. - + Implementing this interface requires implementing the nongeneric interface. The and methods do not depend on , and appear only on the nongeneric interface. The property appears on both interfaces, and has different return types. Implement the nongeneric property as an explicit interface implementation. This allows any consumer of the nongeneric interface to consume the generic interface. + In addition, implements , which requires you to implement the method. This enables you to close database connections or release file handles or similar operations when using other resources. If there are no additional resources to dispose of, provide an empty implementation. @@ -164,19 +164,19 @@ Gets the element in the collection at the current position of the enumerator. The element in the collection at the current position of the enumerator. - 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. + ]]> diff --git a/xml/System.Collections.Generic/IReadOnlyDictionary`2.xml b/xml/System.Collections.Generic/IReadOnlyDictionary`2.xml index f14e3c80ebc..88399f287f9 100644 --- a/xml/System.Collections.Generic/IReadOnlyDictionary`2.xml +++ b/xml/System.Collections.Generic/IReadOnlyDictionary`2.xml @@ -80,21 +80,21 @@ The type of values in the read-only dictionary. Represents a generic read-only collection of key/value pairs. - object. - - Each pair must have a unique key. Implementations can vary in whether they allow you to specify a key that is `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. - - The `foreach` statement of the C# language (`For Each` in Visual Basic, `for each` in C++) 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. - + object. + + Each pair must have a unique key. Implementations can vary in whether they allow you to specify a key that is `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. + + 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"::: - - The `foreach` statement is a wrapper around the enumerator; it allows only reading from the collection, not writing to the collection. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.IDictionary/VB/source2.vb" id="Snippet11"::: + + The `foreach` statement is a wrapper around the enumerator; it allows only reading from the collection, not writing to the collection. + ]]> @@ -145,13 +145,13 @@ if the read-only dictionary contains an element that has the specified key; otherwise, . - might use the property, or it might implement the method. - - Implementations can vary in whether they allow `key` to be `null`. - + might use the property, or it might implement the method. + + Implementations can vary in whether they allow `key` to be `null`. + ]]> @@ -203,15 +203,15 @@ Gets the element that has the specified key in the read-only dictionary. The element that has the specified key in the read-only dictionary. - might use the property, or it might implement the method. - - Implementations can vary in whether they allow `key` to be `null`. - + might use the property, or it might implement the method. + + Implementations can vary in whether they allow `key` to be `null`. + ]]> @@ -260,11 +260,11 @@ Gets an enumerable collection that contains the keys in the read-only dictionary. An enumerable collection that contains the keys in the read-only dictionary. - property. - + property. + ]]> @@ -324,13 +324,13 @@ if the object that implements the interface contains an element that has the specified key; otherwise, . - method and the property. - - If the key is not found, the `value` parameter gets the appropriate default value for the type `TValue`: for example, 0 (zero) for integer types, `false` for Boolean types, and `null` for reference types. - + method and the property. + + If the key is not found, the `value` parameter gets the appropriate default value for the type `TValue`: for example, 0 (zero) for integer types, `false` for Boolean types, and `null` for reference types. + ]]> @@ -378,11 +378,11 @@ Gets an enumerable collection that contains the values in the read-only dictionary. An enumerable collection that contains the values in the read-only dictionary. - property. - + property. + ]]> diff --git a/xml/System.Collections.Generic/KeyValuePair`2.xml b/xml/System.Collections.Generic/KeyValuePair`2.xml index 97a71140628..551be8a1551 100644 --- a/xml/System.Collections.Generic/KeyValuePair`2.xml +++ b/xml/System.Collections.Generic/KeyValuePair`2.xml @@ -85,30 +85,30 @@ The type of the value. Defines a key/value pair that can be set or retrieved. - property returns an instance of this type. - - The `foreach` statement of the C# language (`for each` in C++, `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: - + property returns an instance of this type. + + 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"::: - - 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 enumerate the keys and values in a dictionary, using the structure. - - This code is part of a larger example provided for the class. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source2.vb" id="Snippet11"::: + + 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 enumerate the keys and values in a dictionary, using the structure. + + 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb" id="Snippet7"::: + ]]> @@ -251,22 +251,22 @@ Gets the key in the key/value pair. A that is the key of the . - structure. - - This code is part of a larger example provided for the class. - + structure. + + 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb" id="Snippet7"::: + ]]> @@ -314,14 +314,14 @@ Returns a string representation of the , using the string representations of the key and value. A string representation of the , which includes the string representations of the key and value. - method for a structure with the string "Test" and the integer 14 returns the string "[Test, 14]". - + method for a structure with the string "Test" and the integer 14 returns the string "[Test, 14]". + > [!NOTE] -> This method uses the `ToString` methods provided by the key and value types. Some types do not return useful or informative values for their `ToString` methods. - +> This method uses the `ToString` methods provided by the key and value types. Some types do not return useful or informative values for their `ToString` methods. + ]]> @@ -368,22 +368,22 @@ Gets the value in the key/value pair. A that is the value of the . - structure. - - This code is part of a larger example provided for the class. - + structure. + + 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Generic.Dictionary/VB/source.vb" id="Snippet7"::: + ]]> diff --git a/xml/System.Collections.Generic/LinkedList`1+Enumerator.xml b/xml/System.Collections.Generic/LinkedList`1+Enumerator.xml index 632f1b3d7cc..9511e68aa72 100644 --- a/xml/System.Collections.Generic/LinkedList`1+Enumerator.xml +++ b/xml/System.Collections.Generic/LinkedList`1+Enumerator.xml @@ -88,7 +88,7 @@ Enumerates the elements of a . - 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 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. You cannot set to the first element of the collection again; you must create a new enumerator instance instead. - - 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. 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. - - Default implementations of collections in are not synchronized. - + 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 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. You cannot set to the first element of the collection again; you must create a new enumerator instance instead. + + 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. 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. + + Default implementations of collections in are not synchronized. + ]]> @@ -148,19 +148,19 @@ Gets the element at the current position of the enumerator. The element in the at the current position of the enumerator. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. + - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. - The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. + ]]> @@ -263,15 +263,15 @@ if the enumerator was successfully advanced to the next element; if the enumerator has passed the end of the collection. - advances the enumerator to 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`. - - 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 throws an . - + advances the enumerator to 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`. + + 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 throws an . + ]]> The collection was modified after the enumerator was created. @@ -328,19 +328,19 @@ Gets the element at the current position of the enumerator. The element in the at the current position of the enumerator. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. + - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. - The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. + ]]> @@ -392,13 +392,13 @@ Sets the enumerator to its initial position, which is before the first element in the collection. - , you must call to advance the enumerator to the first element of the collection before reading the value of . - + , you must call to advance the enumerator to the first element of the collection before reading the value of . + 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 throws an . - + ]]> The collection was modified after the enumerator was created. diff --git a/xml/System.Collections.Generic/List`1.xml b/xml/System.Collections.Generic/List`1.xml index 3f9844a76ff..be53559f1f0 100644 --- a/xml/System.Collections.Generic/List`1.xml +++ b/xml/System.Collections.Generic/List`1.xml @@ -616,7 +616,7 @@ ## Examples The following example demonstrates the method overload and the method overload. A of strings is created and populated with four strings, in no particular order. The list is displayed, sorted, and displayed again. - 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# and Visual 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. + 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"::: @@ -708,11 +708,11 @@ ## Examples The following example demonstrates the method overload and the method overload. - The example defines an alternative comparer for strings named DinoCompare, which implements the `IComparer` (`IComparer(Of String)` in Visual Basic, `IComparer` in Visual C++) generic interface. The comparer works as follows: First, the comparands are tested for `null`, and a null reference is treated as less than a non-null. Second, the string lengths are compared, and the longer string is deemed to be greater. Third, if the lengths are equal, ordinary string comparison is used. + The example defines an alternative comparer for strings named DinoCompare, which implements the `IComparer` (`IComparer(Of String)` in Visual Basic) generic interface. The comparer works as follows: First, the comparands are tested for `null`, and a null reference is treated as less than a non-null. Second, the string lengths are compared, and the longer string is deemed to be greater. Third, if the lengths are equal, ordinary string comparison is used. A of strings is created and populated with four strings, in no particular order. The list is displayed, sorted using the alternate comparer, and displayed again. - 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# and Visual C++, `Xor` -1 in Visual Basic) of the negative number returned by and use it as an index for inserting the new string. + 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"::: @@ -805,11 +805,11 @@ ## Examples The following example demonstrates the method overload and the method overload. - The example defines an alternative comparer for strings named DinoCompare, which implements the `IComparer` (`IComparer(Of String)` in Visual Basic, `IComparer` in Visual C++) generic interface. The comparer works as follows: First, the comparands are tested for `null`, and a null reference is treated as less than a non-null. Second, the string lengths are compared, and the longer string is deemed to be greater. Third, if the lengths are equal, ordinary string comparison is used. + The example defines an alternative comparer for strings named DinoCompare, which implements the `IComparer` (`IComparer(Of String)` in Visual Basic) generic interface. The comparer works as follows: First, the comparands are tested for `null`, and a null reference is treated as less than a non-null. Second, the string lengths are compared, and the longer string is deemed to be greater. Third, if the lengths are equal, ordinary string comparison is used. A of strings is created and populated with the names of five herbivorous dinosaurs and three carnivorous dinosaurs. Within each of the two groups, the names are not in any particular sort order. The list is displayed, the range of herbivores is sorted using the alternate comparer, and the list is displayed again. - 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# and Visual C++, `Xor` -1 in Visual Basic) of the negative number returned by the method is used as an index for inserting the new string. + 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"::: @@ -1540,7 +1540,7 @@ Finally, the method is called. It traverses the list from the beginning, passing each element in turn to the `EndsWithSaurus` method. The search stops and the method returns `true` if the `EndsWithSaurus` method returns `true` for any element. The method returns `false` because all such elements have been removed. > [!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. +> 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"::: @@ -1613,7 +1613,7 @@ The is a delegate to a method that returns `true` if the object passed to it matches the conditions defined in the delegate. The elements of the current are individually passed to the delegate, moving forward in the , starting with the first element and ending with the last element. Processing is stopped when a match is found. > [!IMPORTANT] -> When searching a list containing value types, make sure the default value for the type does not satisfy the search predicate. Otherwise, there is no way to distinguish between a default value indicating that no match was found and a list element that happens to have the default value for the type. If the default value satisfies the search predicate, use the method instead. +> When searching a list containing value types, make sure the default value for the type does not satisfy the search predicate. Otherwise, there is no way to distinguish between a default value indicating that no match was found and a list element that happens to have the default value for the type. If the default value satisfies the search predicate, use the method instead. This method performs a linear search; therefore, this method is an O(*n*) operation, where *n* is . @@ -2095,7 +2095,7 @@ Public Function StartsWith(e As Employee) As Boolean The is a delegate to a method that returns `true` if the object passed to it matches the conditions defined in the delegate. The elements of the current are individually passed to the delegate, moving backward in the , starting with the last element and ending with the first element. Processing is stopped when a match is found. > [!IMPORTANT] -> When searching a list containing value types, make sure the default value for the type does not satisfy the search predicate. Otherwise, there is no way to distinguish between a default value indicating that no match was found and a list element that happens to have the default value for the type. If the default value satisfies the search predicate, use the method instead. +> When searching a list containing value types, make sure the default value for the type does not satisfy the search predicate. Otherwise, there is no way to distinguish between a default value indicating that no match was found and a list element that happens to have the default value for the type. If the default value satisfies the search predicate, use the method instead. This method performs a linear search; therefore, this method is an O(*n*) operation, where *n* is . @@ -2456,7 +2456,7 @@ Public Function StartsWith(e As Employee) As Boolean The following example demonstrates the use of the delegate to print the contents of a object. In this example the `Print` method is used to display the contents of the list to the console. > [!NOTE] -> In addition to displaying the contents using the `Print` method, the C# example demonstrates the use of [anonymous methods](/dotnet/csharp/programming-guide/statements-expressions-operators/anonymous-methods) to display the results to the console. +> In addition to displaying the contents using the `Print` method, the C# example demonstrates the use of [anonymous methods](/dotnet/csharp/programming-guide/statements-expressions-operators/anonymous-methods) to display the results to the console. :::code language="csharp" source="~/snippets/csharp/System/ActionT/Overview/action.cs" interactive="try-dotnet-method" id="Snippet01"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Action_PrintExample/vb/action.vb" id="Snippet01"::: @@ -2519,7 +2519,7 @@ Public Function StartsWith(e As Employee) As Boolean property (the indexer in C#) and various other properties and methods of the generic class. After the list has been created and populated using the method, an element is retrieved and displayed using the property. (For an example that uses the property to set the value of a list element, see .) > [!NOTE] -> Visual Basic, C#, and C++ all have syntax for accessing the property without using its name. Instead, the variable containing the is used as if it were an array. +> Visual Basic, C#, and C++ all have syntax for accessing the property without using its name. Instead, the variable containing the is used as if it were an array. 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. @@ -3477,7 +3477,7 @@ Public Function StartsWith(e As Employee) As Boolean The method is used to remove all entries ending with "saurus". It traverses the list from the beginning, passing each element in turn to the `EndsWithSaurus` method. The element is removed if the `EndsWithSaurus` method returns `true`. > [!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. +> 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. Finally, the method verifies that there are no strings in the list that end with "saurus". @@ -3909,7 +3909,7 @@ Public Function StartsWith(e As Employee) As Boolean The following example demonstrates the method overload and the method overload. A of strings is created and populated with four strings, in no particular order. The list is displayed, sorted, and displayed again. - 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# and Visual 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. + 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"::: @@ -3994,11 +3994,11 @@ Public Function StartsWith(e As Employee) As Boolean ## Examples The following example demonstrates the method overload and the method overload. - The example defines an alternative comparer for strings named DinoCompare, which implements the `IComparer` (`IComparer(Of String)` in Visual Basic, `IComparer` in Visual C++) generic interface. The comparer works as follows: First, the comparands are tested for `null`, and a null reference is treated as less than a non-null. Second, the string lengths are compared, and the longer string is deemed to be greater. Third, if the lengths are equal, ordinary string comparison is used. + The example defines an alternative comparer for strings named DinoCompare, which implements the `IComparer` (`IComparer(Of String)` in Visual Basic) generic interface. The comparer works as follows: First, the comparands are tested for `null`, and a null reference is treated as less than a non-null. Second, the string lengths are compared, and the longer string is deemed to be greater. Third, if the lengths are equal, ordinary string comparison is used. A of strings is created and populated with four strings, in no particular order. The list is displayed, sorted using the alternate comparer, and displayed again. - 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# and Visual C++, `Xor` -1 in Visual Basic) of the negative number returned by and use it as an index for inserting the new string. + 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"::: @@ -4176,11 +4176,11 @@ Public Function StartsWith(e As Employee) As Boolean ## Examples The following example demonstrates the method overload and the method overload. - The example defines an alternative comparer for strings named DinoCompare, which implements the `IComparer` (`IComparer(Of String)` in Visual Basic, `IComparer` in Visual C++) generic interface. The comparer works as follows: First, the comparands are tested for `null`, and a null reference is treated as less than a non-null. Second, the string lengths are compared, and the longer string is deemed to be greater. Third, if the lengths are equal, ordinary string comparison is used. + The example defines an alternative comparer for strings named DinoCompare, which implements the `IComparer` (`IComparer(Of String)` in Visual Basic) generic interface. The comparer works as follows: First, the comparands are tested for `null`, and a null reference is treated as less than a non-null. Second, the string lengths are compared, and the longer string is deemed to be greater. Third, if the lengths are equal, ordinary string comparison is used. A of strings is created and populated with the names of five herbivorous dinosaurs and three carnivorous dinosaurs. Within each of the two groups, the names are not in any particular sort order. The list is displayed, the range of herbivores is sorted using the alternate comparer, and the list is displayed again. - 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# and Visual C++, `Xor` -1 in Visual Basic) of the negative number returned by the method is used as an index for inserting the new string. + 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"::: @@ -4321,7 +4321,7 @@ Public Function StartsWith(e As Employee) As Boolean [!NOTE] -> If the type of the source cannot be cast automatically to the type of the destination `array`, the nongeneric implementations of throw , whereas the generic implementations throw . +> If the type of the source cannot be cast automatically to the type of the destination `array`, the nongeneric implementations of throw , whereas the generic implementations throw . This method is an O(*n*) operation, where *n* is . @@ -4616,7 +4616,7 @@ Retrieving the value of this property is an O(1) operation. can be considerable, however, so the method does nothing if the list is at more than 90 percent of capacity. This avoids incurring a large reallocation cost for a relatively small gain. > [!NOTE] -> The current threshold of 90 percent might change in future releases. +> The current threshold of 90 percent might change in future releases. This method is an O(*n*) operation, where *n* is . @@ -5342,7 +5342,7 @@ Retrieving the value of this property is an O(1) operation. The method traverses the list from the beginning, passing each element in turn to the `EndsWithSaurus` method. The search stops when the `EndsWithSaurus` method returns `false`. > [!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. +> 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"::: diff --git a/xml/System.Collections.Generic/Queue`1+Enumerator.xml b/xml/System.Collections.Generic/Queue`1+Enumerator.xml index e92d0e11b50..0f510331fc2 100644 --- a/xml/System.Collections.Generic/Queue`1+Enumerator.xml +++ b/xml/System.Collections.Generic/Queue`1+Enumerator.xml @@ -74,25 +74,25 @@ Enumerates the elements of a . - 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 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. You cannot set to the first element of the collection again; you must create a new enumerator instance instead. - - 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. 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. - - Default implementations of collections in are not synchronized. - + 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 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. You cannot set to the first element of the collection again; you must create a new enumerator instance instead. + + 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. 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. + + Default implementations of collections in are not synchronized. + ]]> @@ -148,19 +148,19 @@ Gets the element at the current position of the enumerator. The element in the at the current position of the enumerator. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. + - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. - The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. + ]]> @@ -258,15 +258,15 @@ if the enumerator was successfully advanced to the next element; if the enumerator has passed the end of the collection. - advances the enumerator to 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`. - - 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 . - + advances the enumerator to 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`. + + 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 collection was modified after the enumerator was created. @@ -323,20 +323,20 @@ Gets the element at the current position of the enumerator. The element in the collection at the current position of the enumerator. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. + - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. - The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. + ]]> @@ -387,11 +387,11 @@ Sets the enumerator to its initial position, which is before the first element in the collection. - or throws an . - + or throws an . + ]]> The collection was modified after the enumerator was created. diff --git a/xml/System.Collections.Generic/Queue`1.xml b/xml/System.Collections.Generic/Queue`1.xml index 34d8f3a551f..8cdbaae207d 100644 --- a/xml/System.Collections.Generic/Queue`1.xml +++ b/xml/System.Collections.Generic/Queue`1.xml @@ -876,7 +876,7 @@ generic class is enumerable. The `foreach` statement (`For Each` in Visual Basic, `for each` in C++) is used to enumerate the queue. + The following code example demonstrates that the generic class is enumerable. The `foreach` statement (`For Each` in Visual Basic) is used to enumerate the queue. The code example creates a queue of strings with default capacity and uses the method to queue five strings. The elements of the queue are enumerated, which does not change the state of the queue. The method is used to dequeue the first string. The method is used to look at the next item in the queue, and then the method is used to dequeue it. @@ -1038,7 +1038,7 @@ Enumerates the elements of a . - is undefined. You must call the method to advance the enumerator to the first element of the collection before reading the value of . - - The property returns the same object until 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. You cannot set to the first element of the collection again; you must create a new enumerator instance instead. - - 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. 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. - - Default implementations of collections in the namespace are not synchronized. - + is undefined. You must call the method to advance the enumerator to the first element of the collection before reading the value of . + + The property returns the same object until 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. You cannot set to the first element of the collection again; you must create a new enumerator instance instead. + + 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. 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. + + Default implementations of collections in the namespace are not synchronized. + ]]> @@ -149,19 +149,19 @@ Gets the element at the current position of the enumerator. The element in the at the current position of the enumerator. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. + - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. - The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. + ]]> @@ -257,15 +257,15 @@ if the enumerator was successfully advanced to the next element; if the enumerator has passed the end of the collection. - method advances the enumerator to 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`. - - 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 . - + method advances the enumerator to 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`. + + 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 collection was modified after the enumerator was created. @@ -315,20 +315,20 @@ Gets the element at the current position of the enumerator as a structure. The element in the collection at the current position of the dictionary, as a structure. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. + - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. - The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. + ]]> @@ -387,19 +387,19 @@ Gets the key of the element at the current position of the enumerator. The key of the element in the collection at the current position of the enumerator. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. + - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. - The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. + ]]> @@ -459,19 +459,19 @@ Gets the value of the element at the current position of the enumerator. The value of the element in the collection at the current position of the enumerator. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. + - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. - The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. + ]]> @@ -531,20 +531,20 @@ Gets the element at the current position of the enumerator. The element in the collection at the current position of the enumerator. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. + - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. - The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. + ]]> @@ -597,13 +597,13 @@ Sets the enumerator to its initial position, which is before the first element in the collection. - method, you must call the method to advance the enumerator to the first element of the collection before reading the value of the property. - - 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 . - + method, you must call the method to advance the enumerator to the first element of the collection before reading the value of the property. + + 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 collection was modified after the enumerator was created. diff --git a/xml/System.Collections.Generic/SortedDictionary`2+KeyCollection+Enumerator.xml b/xml/System.Collections.Generic/SortedDictionary`2+KeyCollection+Enumerator.xml index 758cf962511..fbd67c6b6ea 100644 --- a/xml/System.Collections.Generic/SortedDictionary`2+KeyCollection+Enumerator.xml +++ b/xml/System.Collections.Generic/SortedDictionary`2+KeyCollection+Enumerator.xml @@ -68,25 +68,25 @@ Enumerates the elements of a . - is undefined. You must call the method to advance the enumerator to the first element of the collection before reading the value of . - - The property returns the same object until 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. You cannot set to the first element of the collection again; you must create a new enumerator instance instead. - - 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. 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. - - Default implementations of collections in the namespace are not synchronized. - + is undefined. You must call the method to advance the enumerator to the first element of the collection before reading the value of . + + The property returns the same object until 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. You cannot set to the first element of the collection again; you must create a new enumerator instance instead. + + 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. 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. + + Default implementations of collections in the namespace are not synchronized. + ]]> @@ -144,20 +144,20 @@ Gets the element at the current position of the enumerator. The element in the at the current position of the enumerator. - is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. - The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. + ]]> @@ -254,15 +254,15 @@ if the enumerator was successfully advanced to the next element; if the enumerator has passed the end of the collection. - method advances the enumerator to 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`. - - 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 . - + method advances the enumerator to 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`. + + 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 collection was modified after the enumerator was created. @@ -319,20 +319,20 @@ Gets the element at the current position of the enumerator. The element in the collection at the current position of the enumerator. - is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. -- The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. +- The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. + + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - ]]> @@ -385,13 +385,13 @@ Sets the enumerator to its initial position, which is before the first element in the collection. - method, you must call the method to advance the enumerator to the first element of the collection before reading the value of the property. - - 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 . - + method, you must call the method to advance the enumerator to the first element of the collection before reading the value of the property. + + 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 collection was modified after the enumerator was created. diff --git a/xml/System.Collections.Generic/SortedDictionary`2+KeyCollection.xml b/xml/System.Collections.Generic/SortedDictionary`2+KeyCollection.xml index 8dfbf93404a..dbde7237165 100644 --- a/xml/System.Collections.Generic/SortedDictionary`2+KeyCollection.xml +++ b/xml/System.Collections.Generic/SortedDictionary`2+KeyCollection.xml @@ -359,7 +359,7 @@ Enumerates the elements of a . - interface. - - 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. At this position, is undefined. You must call the method to advance the enumerator to the first element of the collection before reading the value of . - - The property returns the same object until 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. You cannot set to the first element of the collection again; you must create a new enumerator instance instead. - - 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. 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. - - Default implementations of collections in the namespace are not synchronized. - + interface. + + 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. At this position, is undefined. You must call the method to advance the enumerator to the first element of the collection before reading the value of . + + The property returns the same object until 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. You cannot set to the first element of the collection again; you must create a new enumerator instance instead. + + 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. 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. + + Default implementations of collections in the namespace are not synchronized. + ]]> @@ -144,20 +144,20 @@ Gets the element at the current position of the enumerator. The element in the at the current position of the enumerator. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. + - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. - The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. + ]]> @@ -254,15 +254,15 @@ if the enumerator was successfully advanced to the next element; if the enumerator has passed the end of the collection. - method advances the enumerator to 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`. - - 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 . - + method advances the enumerator to 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`. + + 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 collection was modified after the enumerator was created. @@ -319,20 +319,20 @@ Gets the element at the current position of the enumerator. The element in the collection at the current position of the enumerator. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. + - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. - The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. + ]]> @@ -385,13 +385,13 @@ Sets the enumerator to its initial position, which is before the first element in the collection. - method, you must call the method to advance the enumerator to the first element of the collection before reading the value of the property. - - 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 . - + method, you must call the method to advance the enumerator to the first element of the collection before reading the value of the property. + + 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 collection was modified after the enumerator was created. diff --git a/xml/System.Collections.Generic/SortedDictionary`2+ValueCollection.xml b/xml/System.Collections.Generic/SortedDictionary`2+ValueCollection.xml index 6340ca930bf..1642d7d89a0 100644 --- a/xml/System.Collections.Generic/SortedDictionary`2+ValueCollection.xml +++ b/xml/System.Collections.Generic/SortedDictionary`2+ValueCollection.xml @@ -328,7 +328,7 @@ requires a comparer implementation to perform key comparisons. You can specify an implementation of the generic interface by using a constructor that accepts a `comparer` parameter; if you do not specify an implementation, the default generic comparer is used. If type `TKey` implements the generic interface, the default comparer uses that implementation. - The `foreach` statement of the C# language (`for each` in C++, `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 C#, C++, and Visual Basic syntax. + 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"::: @@ -138,8 +138,6 @@ The `foreach` statement is a wrapper around the enumerator, which allows only reading from the collection, not writing to it. - - ## Examples The following code example creates an empty of strings with string keys and uses the method to add some elements. The example demonstrates that the method throws an when attempting to add a duplicate key. @@ -960,7 +958,7 @@ ## Remarks For purposes of enumeration, each item is a structure representing a value and its key. - The `foreach` statement of the C# language (`for each` in C++, `For Each` in Visual Basic) hides the complexity of enumerators. Therefore, using `foreach` is recommended, instead of directly manipulating the enumerator. + The `foreach` statement of the C# language (`For Each` in Visual Basic) hides the complexity of 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. @@ -2061,7 +2059,7 @@ Getting the value of this property is an O(1) operation. ## Remarks For purposes of enumeration, each item is a structure. - The `foreach` statement of the C# language (`for each` in C++, `For Each` in Visual Basic) hides the complexity of enumerators. Therefore, using `foreach` is recommended, instead of directly manipulating the enumerator. + The `foreach` statement of the C# language (`For Each` in Visual Basic) hides the complexity of 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. @@ -2082,7 +2080,7 @@ Getting the value of this property is an O(1) operation. ## Examples - The following code example shows how to enumerate the key/value pairs in the dictionary by using the `foreach` statement (`For Each` in Visual Basic, `for each` in C++), which hides the use of the enumerator. In particular, note that the enumerator for the interface returns objects rather than objects. + The following code example shows how to enumerate the key/value pairs in the dictionary by using the `foreach` statement (`For Each` in Visual Basic), which hides the use of the enumerator. In particular, note that the enumerator for the interface returns objects rather than objects. The code example is part of a larger example, including output, provided for the method. @@ -2581,7 +2579,7 @@ Getting the value of this property is an O(1) operation. ## Remarks - The `foreach` statement of the C# language (`for each` in C++, `For Each` Visual Basic) hides the complexity of enumerators. Therefore, using `foreach` is recommended, instead of directly manipulating the enumerator. + The `foreach` statement of the C# language (`For Each` Visual Basic) hides the complexity of 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. diff --git a/xml/System.Collections.Generic/SortedList`2.xml b/xml/System.Collections.Generic/SortedList`2.xml index dd3062b9228..cbfd5bc244d 100644 --- a/xml/System.Collections.Generic/SortedList`2.xml +++ b/xml/System.Collections.Generic/SortedList`2.xml @@ -142,7 +142,7 @@ **.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 `foreach` statement of the C# language (`for each` in C++, `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: + 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"::: @@ -1148,7 +1148,7 @@ interface returns objects rather than objects. + The following code example shows how to enumerate the key/value pairs in the sorted list by using the `foreach` statement (`For Each` in Visual Basic), which hides the use of the enumerator. In particular, note that the enumerator for the interface returns objects rather than objects. The code example is part of a larger example, including output, provided for the method. @@ -3111,7 +3111,7 @@ Retrieving the value of this property is an O(1) operation. Enumerates the elements of a . - 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 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. You cannot set to the first element of the collection again; you must create a new enumerator instance instead. - - 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. 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. - - Default implementations of collections in are not synchronized. - + 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 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. You cannot set to the first element of the collection again; you must create a new enumerator instance instead. + + 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. 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. + + Default implementations of collections in are not synchronized. + ]]> @@ -148,19 +148,19 @@ Gets the element at the current position of the enumerator. The element in the at the current position of the enumerator. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. + - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. - The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. + ]]> @@ -258,15 +258,15 @@ if the enumerator was successfully advanced to the next element; if the enumerator has passed the end of the collection. - advances the enumerator to 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`. - - 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 . - + advances the enumerator to 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`. + + 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 collection was modified after the enumerator was created. @@ -323,20 +323,20 @@ Gets the element at the current position of the enumerator. The element in the collection at the current position of the enumerator. - is undefined under any of the following conditions: - -- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. - + is undefined under any of the following conditions: + +- The enumerator is positioned before the first element of the collection. That happens after an enumerator is created or after the method is called. The method must be called to advance the enumerator to the first element of the collection before reading the value of the property. + - The last call to returned `false`, which indicates the end of the collection and that the enumerator is positioned after the last element of the collection. - The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements. - does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. - + does not move the position of the enumerator, and consecutive calls to return the same object until either or is called. + ]]> @@ -387,11 +387,11 @@ Sets the enumerator to its initial position, which is before the first element in the collection. This class cannot be inherited. - or throws an . - + or throws an . + ]]> The collection was modified after the enumerator was created. diff --git a/xml/System.Collections.Generic/Stack`1.xml b/xml/System.Collections.Generic/Stack`1.xml index 0f541852568..9a57f63105a 100644 --- a/xml/System.Collections.Generic/Stack`1.xml +++ b/xml/System.Collections.Generic/Stack`1.xml @@ -773,7 +773,7 @@ generic class is enumerable. The `foreach` statement (`For Each` in Visual Basic, `for each` in C++) is used to enumerate the stack. + The following code example demonstrates that the generic class is enumerable. The `foreach` statement (`For Each` in Visual Basic) is used to enumerate the stack. The code example creates a stack of strings with default capacity and uses the method to push five strings onto the stack. The elements of the stack are enumerated, which does not change the state of the stack. The method is used to pop the first string off the stack. The method is used to look at the next item on the stack, and then the method is used to pop it off. @@ -1086,7 +1084,7 @@ includes a lookup dictionary that you can obtain with the property. When an item is added to the , the item's key is extracted once and saved in the lookup dictionary for faster searches. This behavior is overridden by specifying a dictionary creation threshold when you create the . The lookup dictionary is created the first time the number of elements exceeds that threshold. If you specify -1 as the threshold, the lookup dictionary is never created. > [!NOTE] -> When the internal lookup dictionary is used, it contains references to all the items in the collection if `TItem` is a reference type, or copies of all the items in the collection if `TItem` is a value type. Thus, using the lookup dictionary may not be appropriate if `TItem` is a value type. +> When the internal lookup dictionary is used, it contains references to all the items in the collection if `TItem` is a reference type, or copies of all the items in the collection if `TItem` is a value type. Thus, using the lookup dictionary may not be appropriate if `TItem` is a value type. You can access an item by its index or key by using the property. You can add items without a key, but these items can subsequently be accessed only by index. @@ -190,7 +190,7 @@ By default, the includes a lookup dictionary that is created when the first item is added. When an item is added to the , the item's key is extracted once and saved in the lookup dictionary for faster searches. This behavior can be overridden by using the constructor and specifying a dictionary creation threshold. > [!NOTE] -> Because the class is abstract (`MustInherit` in Visual Basic), you must derive from it in order to use it. In the constructor for your derived type, call the appropriate constructor. It is not necessary to expose functionality like the equality comparer or the dictionary creation threshold in your constructors. +> Because the class is abstract (`MustInherit` in Visual Basic), you must derive from it in order to use it. In the constructor for your derived type, call the appropriate constructor. It is not necessary to expose functionality like the equality comparer or the dictionary creation threshold in your constructors. This constructor is an O(1) operation. @@ -264,7 +264,7 @@ By default, the includes a lookup dictionary that is created when the first item is added. When an item is added to the , the item's key is extracted once and saved in the lookup dictionary for faster searches. This behavior can be overridden by using the constructor and specifying a dictionary creation threshold. > [!NOTE] -> Because the class is abstract (`MustInherit` in Visual Basic), you must derive from it in order to use it. In the constructor for your derived type, call the appropriate constructor. It is not necessary to expose functionality like the equality comparer or the dictionary creation threshold in your constructors. +> Because the class is abstract (`MustInherit` in Visual Basic), you must derive from it in order to use it. In the constructor for your derived type, call the appropriate constructor. It is not necessary to expose functionality like the equality comparer or the dictionary creation threshold in your constructors. This constructor is an O(1) operation. @@ -331,7 +331,7 @@ For very small collections the improvement in retrieval speed provided by the lookup dictionary might not be worth the extra memory required by the dictionary. Setting a threshold allows you to decide when to make that tradeoff. > [!NOTE] -> Because the class is abstract (`MustInherit` in Visual Basic), you must derive from it in order to use it. In the constructor for your derived type, call the appropriate constructor. It is not necessary to expose functionality like the equality comparer or the dictionary creation threshold in your constructors. +> Because the class is abstract (`MustInherit` in Visual Basic), you must derive from it in order to use it. In the constructor for your derived type, call the appropriate constructor. It is not necessary to expose functionality like the equality comparer or the dictionary creation threshold in your constructors. This constructor is an O(1) operation. @@ -938,7 +938,7 @@ In order to maintain the connection between a `MutableKey` object and the `Mutab This property provides the ability to access a specific element in the collection by using the following syntax: `myCollection[key]` (`myCollection(key)` in Visual Basic). > [!NOTE] -> This property is distinct from the inherited property, which gets and sets elements by numeric index. However, if `TKey` is of type , this property masks the inherited property. In that case, you can access the inherited property by casting the to its base type. For example, `KeyedCollection` (`KeyedCollection(Of Integer, MyType)` in Visual Basic, `KeyedCollection` in C++) can be cast to `Collection` (`Collection(Of MyType)` in Visual Basic, `Collection` in C++). +> This property is distinct from the inherited property, which gets and sets elements by numeric index. However, if `TKey` is of type , this property masks the inherited property. In that case, you can access the inherited property by casting the to its base type. For example, `KeyedCollection` (`KeyedCollection(Of Integer, MyType)` in Visual Basic) can be cast to `Collection` (`Collection(Of MyType)` in Visual Basic). If the has a lookup dictionary, `key` is used to retrieve the element from the dictionary. If there is no lookup dictionary, the key of each element is extracted using the method and compared with the specified key. @@ -1018,7 +1018,7 @@ In order to maintain the connection between a `MutableKey` object and the `Mutab If the number of elements has exceeded the dictionary creation threshold and the is using a lookup dictionary, it will continue to use a lookup dictionary even though the number of elements is again under the threshold. > [!NOTE] -> To customize the behavior of this method, override the method. +> To customize the behavior of this method, override the method. This method is an O(`n`) operation, where `n` is . diff --git a/xml/System.Collections.ObjectModel/ReadOnlyCollection`1.xml b/xml/System.Collections.ObjectModel/ReadOnlyCollection`1.xml index 3bde909b91d..bfad36ee848 100644 --- a/xml/System.Collections.ObjectModel/ReadOnlyCollection`1.xml +++ b/xml/System.Collections.ObjectModel/ReadOnlyCollection`1.xml @@ -544,7 +544,7 @@ that wraps a . The enumerator is concealed by the `foreach` statement (`For Each` in Visual Basic, `for each` in C++). + 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"::: @@ -1479,7 +1477,7 @@ This member is an explicit interface member implementation. It can be used only are not sorted by the key, unlike the elements of a class. You can access elements either by the key or by the index. - 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 C#, Visual Basic and C++ syntax. + 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"::: diff --git a/xml/System.Collections/ArrayList.xml b/xml/System.Collections/ArrayList.xml index c30f843970f..9a732e300af 100644 --- a/xml/System.Collections/ArrayList.xml +++ b/xml/System.Collections/ArrayList.xml @@ -1826,7 +1826,7 @@ This method is an `O(1)` operation. Indicates to compilers that a method call or attribute should be ignored unless a specified conditional compilation symbol is defined. - attribute to methods and classes. However, its use on classes is valid only for types that are derived from . either will be ignored or will produce a compiler warning or error message if you apply it to any other type. - - Applying to a method indicates to compilers that a call to the method should not be compiled into Microsoft intermediate language (MSIL) unless the conditional compilation symbol that is associated with is defined. You will get a compilation error in Visual Studio if you apply this attribute to a method that does not return void. Applying to an attribute indicates that the attribute should not be emitted to metadata unless the conditional compilation symbol is defined. Any arguments passed to the method or attribute are still type-checked by the compiler. - - You can use the following techniques to define conditional compilation symbols: - -- Use compiler command-line options; for example, **/define:DEBUG**. - -- Use environment variables in the operating system shell; for example, **set DEBUG=1**. - -- Use pragmas in the source code; for example, define the compilation variable as follows: - - ```csharp - #define DEBUG - ``` - - ```vb - #Const DEBUG=True - ``` - - To undefine the variable, use the following: - - ```csharp - #undef DEBUG - ``` - - ```vb - #Const DEBUG=False - ``` - - Compilers that comply with the Common Language Specification (CLS) are permitted to ignore . The C#, F#, Visual Basic, and C++ compilers support ; the JScript compiler does not support the attribute. - + attribute to methods and classes. However, its use on classes is valid only for types that are derived from . either will be ignored or will produce a compiler warning or error message if you apply it to any other type. + + Applying to a method indicates to compilers that a call to the method should not be compiled into Microsoft intermediate language (MSIL) unless the conditional compilation symbol that is associated with is defined. You will get a compilation error in Visual Studio if you apply this attribute to a method that does not return void. Applying to an attribute indicates that the attribute should not be emitted to metadata unless the conditional compilation symbol is defined. Any arguments passed to the method or attribute are still type-checked by the compiler. + + You can use the following techniques to define conditional compilation symbols: + +- Use compiler command-line options; for example, **/define:DEBUG**. + +- Use environment variables in the operating system shell; for example, **set DEBUG=1**. + +- Use pragmas in the source code; for example, define the compilation variable as follows: + + ```csharp + #define DEBUG + ``` + + ```vb + #Const DEBUG=True + ``` + + To undefine the variable, use the following: + + ```csharp + #undef DEBUG + ``` + + ```vb + #Const DEBUG=False + ``` + + Compilers that comply with the Common Language Specification (CLS) are permitted to ignore . The C#, F#, Visual Basic, and C++ compilers support ; the JScript compiler does not support the attribute. + > [!NOTE] -> In Visual Basic, the `AddressOf` operator is not affected by this attribute. For example, `Call CType(AddressOf delegate, Action)` always invokes `delegate`, although `Call delegate()` might not. - - is applied to the methods that are defined in the and classes. - - For more information about how to use attributes, see [Attributes](/dotnet/standard/attributes/). - - - -## Examples - The following example demonstrates the use of . The example assumes that the condition is defined with the **/define** compiler option. You can obtain different results by changing the compiler option. You can optionally define the conditions by using pragmas in the sample code instead of identifying them as compiler options. - +> In Visual Basic, the `AddressOf` operator is not affected by this attribute. For example, `Call CType(AddressOf delegate, Action)` always invokes `delegate`, although `Call delegate()` might not. + + is applied to the methods that are defined in the and classes. + + For more information about how to use attributes, see [Attributes](/dotnet/standard/attributes/). + +## Examples + The following example demonstrates the use of . The example assumes that the condition is defined with the **/define** compiler option. You can obtain different results by changing the compiler option. You can optionally define the conditions by using pragmas in the sample code instead of identifying them as compiler options. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/ConditionalAttribute/Overview/cas.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ConditionalAttributeSample1/VB/cas.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ConditionalAttributeSample1/VB/cas.vb" id="Snippet7"::: + ]]> @@ -170,14 +168,14 @@ A string that specifies the case-sensitive conditional compilation symbol that is associated with the attribute. Initializes a new instance of the class. - constructor. This example is part of a larger example provided for the class. - + constructor. This example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Diagnostics/ConditionalAttribute/Overview/cas.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ConditionalAttributeSample1/VB/cas.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ConditionalAttributeSample1/VB/cas.vb" id="Snippet8"::: + ]]> @@ -225,11 +223,11 @@ Gets the conditional compilation symbol that is associated with the attribute. A string that specifies the case-sensitive conditional compilation symbol that is associated with the attribute. - diff --git a/xml/System.Diagnostics/Trace.xml b/xml/System.Diagnostics/Trace.xml index 3ffc7d7e1bf..c33ac03aef6 100644 --- a/xml/System.Diagnostics/Trace.xml +++ b/xml/System.Diagnostics/Trace.xml @@ -51,56 +51,56 @@ Provides a set of methods and properties that help you trace the execution of your code. This class cannot be inherited. - class to instrument release builds. Instrumentation allows you to monitor the health of your application running in real-life settings. Tracing helps you isolate problems and fix them without disturbing a running system. - + class to instrument release builds. Instrumentation allows you to monitor the health of your application running in real-life settings. Tracing helps you isolate problems and fix them without disturbing a running system. + This class provides methods to display an dialog box, and to emit an assertion that will always . This class provides write methods in the following variations: - + - - - - - - The and classes provide means to dynamically control the tracing output. In .NET Framework apps, you can modify the values of these switches without recompiling your application. For information on using the configuration file to set a switch in a .NET Framework app, see the class and [How to: Create, Initialize, and Configure Trace Switches](/dotnet/framework/debug-trace-profile/how-to-create-initialize-and-configure-trace-switches). - - You can customize the tracing output's target by adding instances to or removing instances from the collection. The collection is shared by both the and the classes; adding a trace listener to either class adds the listener to both. By default, trace output is emitted using the class. - + + The and classes provide means to dynamically control the tracing output. In .NET Framework apps, you can modify the values of these switches without recompiling your application. For information on using the configuration file to set a switch in a .NET Framework app, see the class and [How to: Create, Initialize, and Configure Trace Switches](/dotnet/framework/debug-trace-profile/how-to-create-initialize-and-configure-trace-switches). + + You can customize the tracing output's target by adding instances to or removing instances from the collection. The collection is shared by both the and the classes; adding a trace listener to either class adds the listener to both. By default, trace output is emitted using the class. + > [!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. - +> 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. + > [!NOTE] -> If you add trace listeners to partially trusted code, you will get a exception, because adding trace listeners requires permission. To trace partially trusted code that is running in a sandbox in Visual Studio, do not add trace listeners. Instead, view the and messages in the **Output** window. - - The class provides properties to get or set the level of and the , and whether to after each write. - -In .NET Framework apps, you can set the and for by editing the configuration file that corresponds to the name of your application. The configuration file should be formatted like the following example: - -```xml - - - - - -``` - - The attribute is applied to the methods of . Compilers that support ignore calls to these methods unless `TRACE` is defined as a conditional compilation symbol. Refer to a compiler's documentation to determine whether is supported and the syntax for defining a conditional compilation symbol. - +> If you add trace listeners to partially trusted code, you will get a exception, because adding trace listeners requires permission. To trace partially trusted code that is running in a sandbox in Visual Studio, do not add trace listeners. Instead, view the and messages in the **Output** window. + + The class provides properties to get or set the level of and the , and whether to after each write. + +In .NET Framework apps, you can set the and for by editing the configuration file that corresponds to the name of your application. The configuration file should be formatted like the following example: + +```xml + + + + + +``` + + The attribute is applied to the methods of . Compilers that support ignore calls to these methods unless `TRACE` is defined as a conditional compilation symbol. Refer to a compiler's documentation to determine whether is supported and the syntax for defining a conditional compilation symbol. + > [!NOTE] -> In Visual Studio projects, by default, the `DEBUG` conditional compilation symbol is defined for debug builds, and the `TRACE` symbol is defined for both debug and release builds. - - To define the `TRACE` conditional compilation symbol in C#, add the `/d:TRACE` option to the compiler command line when you compile your code using a command line, or add `#define TRACE` to the top of your file. In Visual Basic, add the `/d:TRACE=True` option to the compiler command line or add `#Const TRACE=True` to the file. - +> In Visual Studio projects, by default, the `DEBUG` conditional compilation symbol is defined for debug builds, and the `TRACE` symbol is defined for both debug and release builds. + + To define the `TRACE` conditional compilation symbol in C#, add the `/d:TRACE` option to the compiler command line when you compile your code using a command line, or add `#define TRACE` to the top of your file. In Visual Basic, add the `/d:TRACE=True` option to the compiler command line or add `#Const TRACE=True` to the file. + is not supported by the C++ compiler. To provide equivalent functionality, you must enclose calls to the methods of in an `#if defined(TRACE) ... #endif` block, and add the `/DTRACE` option to the compiler command line or add `#define TRACE` to the file. - -## Examples - The following example uses 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). - + +## Examples + The following example uses 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace Example/VB/source.vb" id="Snippet1"::: + ]]> This type is thread safe. @@ -185,39 +185,39 @@ In .NET Framework apps, you can set the The conditional expression to evaluate. If the condition is , a failure message is not sent and the message box is not displayed. Checks for a condition; if the condition is , displays a message box that shows the call stack. - method if you want to do assertions in release builds. The method works only in debug builds. For more information, see [Assertions in Managed Code](/visualstudio/debugger/assertions-in-managed-code). - - Typically, the method is used to identify logic errors during program development. evaluates the condition. If the result is `false`, it sends a failure message to the collection. You can customize this behavior by adding a to, or removing one from, the collection. - - When the application runs in user-interface mode, it displays a message box that shows the call stack with file and line numbers. The message box contains three buttons: **Abort**, **Retry**, and **Ignore**. Clicking the **Abort** button terminates the application. Clicking **Retry** sends you to the code in the debugger if your application is running in a debugger, or offers to open a debugger if it is not. Clicking **Ignore** continues with the next instruction in the code. - + method if you want to do assertions in release builds. The method works only in debug builds. For more information, see [Assertions in Managed Code](/visualstudio/debugger/assertions-in-managed-code). + + Typically, the method is used to identify logic errors during program development. evaluates the condition. If the result is `false`, it sends a failure message to the collection. You can customize this behavior by adding a to, or removing one from, the collection. + + When the application runs in user-interface mode, it displays a message box that shows the call stack with file and line numbers. The message box contains three buttons: **Abort**, **Retry**, and **Ignore**. Clicking the **Abort** button terminates the application. Clicking **Retry** sends you to the code in the debugger if your application is running in a debugger, or offers to open a debugger if it is not. Clicking **Ignore** continues with the next instruction in the code. + > [!NOTE] -> The display of the message box depends on the presence of the . If the is not in the collection, the message box is not displayed. The can be removed by calling the method on the property (`System.Diagnostics.Trace.Listeners.Clear()`). For .NET Framework apps, you can also use the [\ element](/dotnet/framework/configure-apps/file-schema/trace-debug/clear-element-for-listeners-for-trace) and the [\ element](/dotnet/framework/configure-apps/file-schema/trace-debug/remove-element-for-listeners-for-trace) in your app's configuration file. - -For .NET Framework apps, you can change the behavior of the in the configuration file that corresponds to the name of your application. In this file, you can enable and disable the assert message box or set the property. The configuration file should be formatted as follows: - -```xml - - - - - - - - - +> The display of the message box depends on the presence of the . If the is not in the collection, the message box is not displayed. The can be removed by calling the method on the property (`System.Diagnostics.Trace.Listeners.Clear()`). For .NET Framework apps, you can also use the [\ element](/dotnet/framework/configure-apps/file-schema/trace-debug/clear-element-for-listeners-for-trace) and the [\ element](/dotnet/framework/configure-apps/file-schema/trace-debug/remove-element-for-listeners-for-trace) in your app's configuration file. + +For .NET Framework apps, you can change the behavior of the in the configuration file that corresponds to the name of your application. In this file, you can enable and disable the assert message box or set the property. The configuration file should be formatted as follows: + +```xml + + + + + + + + + ``` - -## Examples - The following example creates an index for an array. Then some action is performed that sets the value of the index. Next the code calls to verify the index value is valid. If it is not valid, the outputs the call stack. - + +## Examples + The following example creates an index for an array. Then some action is performed that sets the value of the index. Next the code calls 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Assert Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -297,39 +297,39 @@ For .NET Framework apps, you can change the behavior of the The message to send to the collection. Checks for a condition; if the condition is , outputs a specified message and displays a message box that shows the call stack. - method if you want to do assertions in release builds. The method works only in debug builds. For more information, see [Assertions in Managed Code](/visualstudio/debugger/assertions-in-managed-code). - - Typically, the method is used to identify logic errors during program development. evaluates the condition. If the result is `false`, it sends the specified diagnostic message to the collection. You can customize this behavior by adding a to, or removing one from, the collection. - - When the application runs in user-interface mode, it displays a message box that shows the call stack with file and line numbers. The message box contains three buttons: **Abort**, **Retry**, and **Ignore**. Clicking the **Abort** button terminates the application. Clicking **Retry** sends you to the code in the debugger if your application is running in a debugger, or offers to open a debugger if it is not. Clicking **Ignore** continues with the next instruction in the code. - + method if you want to do assertions in release builds. The method works only in debug builds. For more information, see [Assertions in Managed Code](/visualstudio/debugger/assertions-in-managed-code). + + Typically, the method is used to identify logic errors during program development. evaluates the condition. If the result is `false`, it sends the specified diagnostic message to the collection. You can customize this behavior by adding a to, or removing one from, the collection. + + When the application runs in user-interface mode, it displays a message box that shows the call stack with file and line numbers. The message box contains three buttons: **Abort**, **Retry**, and **Ignore**. Clicking the **Abort** button terminates the application. Clicking **Retry** sends you to the code in the debugger if your application is running in a debugger, or offers to open a debugger if it is not. Clicking **Ignore** continues with the next instruction in the code. + > [!NOTE] -> The display of the message box depends on the presence of the . If the is not in the collection, the message box is not displayed. The can be removed by calling the method on the property (`System.Diagnostics.Trace.Listeners.Clear()`). For .NET Framework apps, you can also use the [\ element](/dotnet/framework/configure-apps/file-schema/trace-debug/clear-element-for-listeners-for-trace) and the [\ element](/dotnet/framework/configure-apps/file-schema/trace-debug/remove-element-for-listeners-for-trace) in your app's configuration file. - -For .NET Framework apps, you can change the behavior of the in the configuration file that corresponds to the name of your application. In this file, you can enable and disable the assert message box or set the property. The configuration file should be formatted as follows: - -```xml - - - - - - - - - +> The display of the message box depends on the presence of the . If the is not in the collection, the message box is not displayed. The can be removed by calling the method on the property (`System.Diagnostics.Trace.Listeners.Clear()`). For .NET Framework apps, you can also use the [\ element](/dotnet/framework/configure-apps/file-schema/trace-debug/clear-element-for-listeners-for-trace) and the [\ element](/dotnet/framework/configure-apps/file-schema/trace-debug/remove-element-for-listeners-for-trace) in your app's configuration file. + +For .NET Framework apps, you can change the behavior of the in the configuration file that corresponds to the name of your application. In this file, you can enable and disable the assert message box or set the property. The configuration file should be formatted as follows: + +```xml + + + + + + + + + ``` - -## Examples - The following example checks to see that the `type` parameter is valid. If the `type` passed in is `null`, the outputs a message. - + +## Examples + The following example checks to see that the `type` parameter is valid. If the `type` passed in is `null`, 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Assert1 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -402,39 +402,39 @@ For .NET Framework apps, you can change the behavior of the The detailed message to send to the collection. Checks for a condition; if the condition is , outputs two specified messages and displays a message box that shows the call stack. - method if you want to do assertions in release builds. The method works only in debug builds. For more information, see [Assertions in Managed Code](/visualstudio/debugger/assertions-in-managed-code). - - Typically, the method is used to identify logic errors during program development. evaluates the condition. If the result is `false`, it sends the specified diagnostic message and detailed message to the collection. You can customize this behavior by adding a to, or removing one from, the collection. - - When the application runs in user-interface mode, it displays a message box that shows the call stack with file and line numbers. The message box contains three buttons: **Abort**, **Retry**, and **Ignore**. Clicking the **Abort** button terminates the application. Clicking **Retry** sends you to the code in the debugger if your application is running in a debugger, or offers to open a debugger if it is not. Clicking **Ignore** continues with the next instruction in the code. - + method if you want to do assertions in release builds. The method works only in debug builds. For more information, see [Assertions in Managed Code](/visualstudio/debugger/assertions-in-managed-code). + + Typically, the method is used to identify logic errors during program development. evaluates the condition. If the result is `false`, it sends the specified diagnostic message and detailed message to the collection. You can customize this behavior by adding a to, or removing one from, the collection. + + When the application runs in user-interface mode, it displays a message box that shows the call stack with file and line numbers. The message box contains three buttons: **Abort**, **Retry**, and **Ignore**. Clicking the **Abort** button terminates the application. Clicking **Retry** sends you to the code in the debugger if your application is running in a debugger, or offers to open a debugger if it is not. Clicking **Ignore** continues with the next instruction in the code. + > [!NOTE] -> The display of the message box depends on the presence of the . If the is not in the collection, the message box is not displayed. The can be removed by calling the method on the property (`System.Diagnostics.Trace.Listeners.Clear()`). For .NET Framework apps, you can also use the [\ element](/dotnet/framework/configure-apps/file-schema/trace-debug/clear-element-for-listeners-for-trace) and the [\ element](/dotnet/framework/configure-apps/file-schema/trace-debug/remove-element-for-listeners-for-trace) in your app's configuration file. - -For .NET Framework apps, you can change the behavior of the in the configuration file that corresponds to the name of your application. In this file, you can enable and disable the assert message box or set the property. The configuration file should be formatted as follows: - -```xml - - - - - - - - - +> The display of the message box depends on the presence of the . If the is not in the collection, the message box is not displayed. The can be removed by calling the method on the property (`System.Diagnostics.Trace.Listeners.Clear()`). For .NET Framework apps, you can also use the [\ element](/dotnet/framework/configure-apps/file-schema/trace-debug/clear-element-for-listeners-for-trace) and the [\ element](/dotnet/framework/configure-apps/file-schema/trace-debug/remove-element-for-listeners-for-trace) in your app's configuration file. + +For .NET Framework apps, you can change the behavior of the in the configuration file that corresponds to the name of your application. In this file, you can enable and disable the assert message box or set the property. The configuration file should be formatted as follows: + +```xml + + + + + + + + + ``` - -## Examples - The following example checks to see that the `type` parameter is valid. If the `type` passed in is `null`, the outputs a message. - + +## Examples + The following example checks to see that the `type` parameter is valid. If the `type` passed in is `null`, 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Assert2 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -487,23 +487,23 @@ For .NET Framework apps, you can change the behavior of the if is called on the after every write; otherwise, . - or . 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. - - To set the and for in .NET Framework apps, you can also edit the configuration file that corresponds to the name of your application. The configuration file should be formatted like the following example: - -```xml - - - - - -``` - + or . 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. + + To set the and for in .NET Framework apps, you can also edit the configuration file that corresponds to the name of your application. The configuration file should be formatted like the following example: + +```xml + + + + + +``` + ]]> @@ -561,22 +561,22 @@ For .NET Framework apps, you can change the behavior of the Flushes the output buffer, and then closes the . - . - - Flushing the stream will not flush its underlying encoder unless you explicitly call or . 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 - The following example creates a 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. - + . + + Flushing the stream will not flush its underlying encoder unless you explicitly call or . 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 + The following example creates a 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Flush Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -632,15 +632,15 @@ For .NET Framework apps, you can change the behavior of the Gets the correlation manager for the thread for this trace. The object associated with the thread for this trace. - [!NOTE] -> This is an advanced property that most applications should not have occasion to use. - - The 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. - +> This is an advanced property that most applications should not have occasion to use. + + The 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. + ]]> @@ -710,31 +710,31 @@ For .NET Framework apps, you can change the behavior of the A message to emit. Emits the specified error message. - instances in the collection. - + instances in the collection. + > [!NOTE] -> The display of the message box is dependent on the presence of the . If the is not in the collection, the message box is not displayed. The can be removed by the [<clear>](/dotnet/framework/configure-apps/file-schema/trace-debug/clear-element-for-listeners-for-trace), the [<remove>](/dotnet/framework/configure-apps/file-schema/trace-debug/remove-element-for-listeners-for-trace), or by calling the method on the property (`System.Diagnostics.Trace.Listeners.Clear()`). - - You can customize this behavior by adding a to, or by removing one from, the collection. - - - -## Examples - The following example uses the method to print a message during exception handling. - +> The display of the message box is dependent on the presence of the . If the is not in the collection, the message box is not displayed. The can be removed by the [<clear>](/dotnet/framework/configure-apps/file-schema/trace-debug/clear-element-for-listeners-for-trace), the [<remove>](/dotnet/framework/configure-apps/file-schema/trace-debug/remove-element-for-listeners-for-trace), or by calling the method on the property (`System.Diagnostics.Trace.Listeners.Clear()`). + + You can customize this behavior by adding a to, or by removing one from, the collection. + + + +## Examples + The following example uses 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="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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Fail Example/VB/source.vb" id="Snippet2"::: + ]]> @@ -802,31 +802,31 @@ For .NET Framework apps, you can change the behavior of the A detailed message to emit. Emits an error message, and a detailed error message. - instances in the collection. - + instances in the collection. + > [!NOTE] -> The display of the message box is dependent on the presence of the . If the is not in the collection, the message box is not displayed. The can be removed by the [<clear>](/dotnet/framework/configure-apps/file-schema/trace-debug/clear-element-for-listeners-for-trace), the [<remove>](/dotnet/framework/configure-apps/file-schema/trace-debug/remove-element-for-listeners-for-trace), or by calling the method on the property (`System.Diagnostics.Trace.Listeners.Clear()`). - - You can customize this behavior by adding a to, or by removing one from, the collection. - - - -## Examples - The following example uses the method to print a message during exception handling. - +> The display of the message box is dependent on the presence of the . If the is not in the collection, the message box is not displayed. The can be removed by the [<clear>](/dotnet/framework/configure-apps/file-schema/trace-debug/clear-element-for-listeners-for-trace), the [<remove>](/dotnet/framework/configure-apps/file-schema/trace-debug/remove-element-for-listeners-for-trace), or by calling the method on the property (`System.Diagnostics.Trace.Listeners.Clear()`). + + You can customize this behavior by adding a to, or by removing one from, the collection. + + + +## Examples + The following example uses 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="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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Fail1 Example/VB/source.vb" id="Snippet2"::: + ]]> @@ -884,20 +884,20 @@ For .NET Framework apps, you can change the behavior of the Flushes the output buffer, and causes buffered data to be written to the . - or . 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 - The following example creates a 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. - + or . 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 + The following example creates a 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Flush Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -955,24 +955,24 @@ For .NET Framework apps, you can change the behavior of the Increases the current by one. - @@ -1020,31 +1020,31 @@ End of list of errors Gets or sets the indent level. The indent level. The default is zero. - property represents the number of times the indent of size is applied. This property is stored on per-thread/per-request basis. - - - -## Examples - The following example increments and decrements the indent level and emits tracing messages. - + property represents the number of times the indent of size is applied. This property is stored on per-thread/per-request basis. + + + +## 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"::: - - This example produces the following output: - -``` - -List of errors: - Error 1: File not found - Error 2: Directory not found -End of list of errors - -``` - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.IndentLevel Example/VB/source.vb" id="Snippet1"::: + + This example produces the following output: + +``` + +List of errors: + Error 1: File not found + Error 2: Directory not found +End of list of errors + +``` + ]]> @@ -1097,23 +1097,23 @@ End of list of errors Gets or sets the number of spaces in an indent. The number of spaces in an indent. The default is four. - interprets this number as spaces. An ignores this value. - - This property is stored on per-thread/per-request basis. - - To set the and for in .NET Framework apps, you can also edit the configuration file that corresponds to the name of your application. The configuration file should be formatted like the following example: - -```xml - - - - - -``` - + interprets this number as spaces. An ignores this value. + + This property is stored on per-thread/per-request basis. + + To set the and for in .NET Framework apps, you can also edit the configuration file that corresponds to the name of your application. The configuration file should be formatted like the following example: + +```xml + + + + + +``` + ]]> @@ -1172,23 +1172,23 @@ End of list of errors Gets the collection of listeners that is monitoring the trace output. A that represents a collection of type monitoring the trace output. - class. If you want to remove the default listener, call the method, and pass it the instance of the . To redirect output to the console window, add an instance of the class. - + class. If you want to remove the default listener, call the method, and pass it the instance of the . To redirect output to the console window, add an instance of the class. + > [!NOTE] -> The collection is shared by both the and the classes; adding a trace listener to either class adds the listener to both. - - - -## Examples - The following example creates a that outputs to the console screen. The code then adds the new listener to the . - +> The collection is shared by both the and the classes; adding a trace listener to either class adds the listener to both. + + + +## 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 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Listeners Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -1239,11 +1239,11 @@ End of list of errors Refreshes the trace configuration data. - method to update the trace configuration data. - + method to update the trace configuration data. + ]]> @@ -1333,11 +1333,11 @@ End of list of errors The informative message to write. Writes an error message to the trace listeners in the collection using the specified message. - calls the `TraceEvent` method for each trace listener, with the trace event type , passing the informative message as the message string. - + calls the `TraceEvent` method for each trace listener, with the trace event type , passing the informative message as the message string. + ]]> @@ -1418,11 +1418,11 @@ End of list of errors An array containing zero or more objects to format. Writes an error message to the trace listeners in the collection using the specified array of objects and formatting information. - calls the `TraceEvent` methods in the trace listeners with the trace event type , passing the message content as an object array with formatting information. See the method for more information about the `format` and `args` parameters. - + calls the `TraceEvent` methods in the trace listeners with the trace event type , passing the message content as an object array with formatting information. See the method for more information about the `format` and `args` parameters. + ]]> @@ -1493,11 +1493,11 @@ End of list of errors The informative message to write. Writes an informational message to the trace listeners in the collection using the specified message. - calls the `TraceEvent` method for each trace listener, with the trace event type , passing the informative message as the message string. - + calls the `TraceEvent` method for each trace listener, with the trace event type , passing the informative message as the message string. + ]]> @@ -1578,11 +1578,11 @@ End of list of errors An array containing zero or more objects to format. Writes an informational message to the trace listeners in the collection using the specified array of objects and formatting information. - calls the `TraceEvent` methods in the trace listeners with the trace event type , passing the message content as an object array with formatting information. See the method for more information about the `format` and `args` parameters. - + calls the `TraceEvent` methods in the trace listeners with the trace event type , passing the message content as an object array with formatting information. See the method for more information about the `format` and `args` parameters. + ]]> @@ -1653,11 +1653,11 @@ End of list of errors The informative message to write. Writes a warning message to the trace listeners in the collection using the specified message. - calls the `TraceEvent` method for each trace listener with the trace event type , passing the informative message as the message string. - + calls the `TraceEvent` method for each trace listener with the trace event type , passing the informative message as the message string. + ]]> @@ -1738,11 +1738,11 @@ End of list of errors An array containing zero or more objects to format. Writes a warning message to the trace listeners in the collection using the specified array of objects and formatting information. - calls the `TraceEvent` methods in the trace listeners with the trace event type , passing the message content as an object array with formatting information. See the method for more information about the `format` and `args` parameters. - + calls the `TraceEvent` methods in the trace listeners with the trace event type , passing the message content as an object array with formatting information. See the method for more information about the `format` and `args` parameters. + ]]> @@ -1800,26 +1800,26 @@ End of list of errors Decreases the current by one. - @@ -1867,21 +1867,21 @@ End of list of errors if the global lock is to be used; otherwise, . The default is . - . The property is used to determine if the listener is thread safe. The global lock is not used only if the value of is `false` and the value of is `true`. The default behavior is to use the global lock. - - To set the for in .NET Framework apps, you can also edit the configuration file that corresponds to the name of your application. The configuration file should be formatted like the following example: - -```xml - - - - - -``` - + . The property is used to determine if the listener is thread safe. The global lock is not used only if the value of is `false` and the value of is `true`. The default behavior is to use the global lock. + + To set the for in .NET Framework apps, you can also edit the configuration file that corresponds to the name of your application. The configuration file should be formatted like the following example: + +```xml + + + + + +``` + ]]> @@ -1946,31 +1946,31 @@ End of list of errors An whose name is sent to the . Writes the value of the object's method to the trace listeners in the collection. - . - - This method calls the method of the trace listener. - + . + + This method calls the method of the trace listener. + > [!NOTE] -> ASP.NET supplies tracing functionality tailored for Web pages. To write trace messages in ASP.NET pages, use the property. - - By default, in code associated with an ASP.NET Web page, the statement `Trace.Write("...")` is a call to the method of the property. To use the class in Web pages, you must include the namespace, for example, `System.Diagnostics.Trace.Write("...")`. - - - -## Examples - The following example creates a named `generalSwitch`. This switch is set outside the code sample. - - If the switch is set to the `Error` or higher, the example outputs the first name of the `value` parameter to the . For information on adding a listener to the collection, see the class. - - 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. - +> ASP.NET supplies tracing functionality tailored for Web pages. To write trace messages in ASP.NET pages, use the property. + + By default, in code associated with an ASP.NET Web page, the statement `Trace.Write("...")` is a call to the method of the property. To use the class in Web pages, you must include the namespace, for example, `System.Diagnostics.Trace.Write("...")`. + + + +## Examples + The following example creates a named `generalSwitch`. This switch is set outside the code sample. + + If the switch is set to the `Error` or higher, the example outputs the first name of the `value` parameter to the . For information on adding a listener to the collection, see the class. + + 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Write1 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2032,31 +2032,31 @@ End of list of errors A message to write. Writes a message to the trace listeners in the collection. - . - - This method calls the method of the trace listener. - + . + + This method calls the method of the trace listener. + > [!NOTE] -> ASP.NET supplies tracing functionality tailored for Web pages. To write trace messages in ASP.NET pages, use the property. - - By default, in code associated with an ASP.NET Web page, the statement `Trace.Write("...")` is a call to the method of the property. To use the class in Web pages, you must include the namespace, for example, `System.Diagnostics.Trace.Write("...")`. - - - -## Examples - The following example creates a named `generalSwitch`. This switch is set outside the code sample. - - If the switch is set to the `Error` or higher, the example outputs the first error message to the . For information on adding a listener to the collection, see the class. - - 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. - +> ASP.NET supplies tracing functionality tailored for Web pages. To write trace messages in ASP.NET pages, use the property. + + By default, in code associated with an ASP.NET Web page, the statement `Trace.Write("...")` is a call to the method of the property. To use the class in Web pages, you must include the namespace, for example, `System.Diagnostics.Trace.Write("...")`. + + + +## Examples + The following example creates a named `generalSwitch`. This switch is set outside the code sample. + + If the switch is set to the `Error` or higher, the example outputs the first error message to the . For information on adding a listener to the collection, see the class. + + 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Write Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2120,33 +2120,33 @@ End of list of errors A category name used to organize the output. Writes a category name and the value of the object's method to the trace listeners in the collection. - . - - The `category` parameter can be used to group output messages. - - This method calls the method of the trace listener. - + . + + The `category` parameter can be used to group output messages. + + This method calls the method of the trace listener. + > [!NOTE] -> ASP.NET supplies tracing functionality tailored for Web pages. To write trace messages in ASP.NET pages, use the property. - - By default, in code associated with an ASP.NET Web page, the statement `Trace.Write("...")` is a call to the method of the property. To use the class in Web pages, you must include the namespace, for example, `System.Diagnostics.Trace.Write("...")`. - - - -## Examples - The following example creates a named `generalSwitch`. This switch is set outside the code sample. - - If the switch is set to the `Verbose`, the example outputs the name of the `myObject` and the `category` to the . For information on adding a listener to the collection, see the class. - - 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. - +> ASP.NET supplies tracing functionality tailored for Web pages. To write trace messages in ASP.NET pages, use the property. + + By default, in code associated with an ASP.NET Web page, the statement `Trace.Write("...")` is a call to the method of the property. To use the class in Web pages, you must include the namespace, for example, `System.Diagnostics.Trace.Write("...")`. + + + +## Examples + The following example creates a named `generalSwitch`. This switch is set outside the code sample. + + If the switch is set to the `Verbose`, the example outputs the name of the `myObject` and the `category` to the . For information on adding a listener to the collection, see the class. + + 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Write3 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2210,33 +2210,33 @@ End of list of errors A category name used to organize the output. Writes a category name and a message to the trace listeners in the collection. - . - - The `category` parameter can be used to group output messages. - - This method calls the method of the trace listener. - + . + + The `category` parameter can be used to group output messages. + + This method calls the method of the trace listener. + > [!NOTE] -> ASP.NET supplies tracing functionality tailored for Web pages. To write trace messages in ASP.NET pages, use the property. - - By default, in code associated with an ASP.NET Web page, the statement `Trace.Write("...")` is a call to the method of the property. To use the class in Web pages, you must include the namespace, for example, `System.Diagnostics.Trace.Write("...")`. - - - -## Examples - The following example creates a named `generalSwitch`. This switch is set outside the code sample. - - If the switch is set to the `Verbose`, the example outputs the first error message to the . For information on adding a listener to the collection, see the class. - - 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. - +> ASP.NET supplies tracing functionality tailored for Web pages. To write trace messages in ASP.NET pages, use the property. + + By default, in code associated with an ASP.NET Web page, the statement `Trace.Write("...")` is a call to the method of the property. To use the class in Web pages, you must include the namespace, for example, `System.Diagnostics.Trace.Write("...")`. + + + +## Examples + The following example creates a named `generalSwitch`. This switch is set outside the code sample. + + If the switch is set to the `Verbose`, the example outputs the first error message to the . For information on adding a listener to the collection, see the class. + + 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Write2 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2311,42 +2311,42 @@ End of list of errors An whose name is sent to the . Writes the value of the object's method to the trace listeners in the collection if a condition is . - . - - This method calls the method of the trace listener. - - - -## Examples - The following example creates a named `generalSwitch`. This switch is set outside the code sample. - - If the switch is set to the `Error` or higher, the example outputs the first name of the value parameter to the . For information on adding a listener to the collection, see the class. - - 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. - + . + + This method calls the method of the trace listener. + + + +## Examples + The following example creates a named `generalSwitch`. This switch is set outside the code sample. + + If the switch is set to the `Error` or higher, the example outputs the first name of the value parameter to the . For information on adding a listener to the collection, see the class. + + 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.WriteIf1 Example/VB/source.vb" id="Snippet1"::: + ]]> - You can minimize the performance penalty of instrumenting your application by using statements instead of using statements. The following two code examples send the same debugging message. However, the first example is much faster when tracing is off, because if mySwitch.TraceError evaluates to you do not call . The second example always calls , even when mySwitch.TraceError is and no tracing output is produced. This can result in unnecessary execution of arbitrarily complex code. - - **First example** - -```csharp -if(mySwitch.TraceError) - Trace.Write("aNumber = " + aNumber + " out of range"); -``` - - **Second example** - -```csharp -Trace.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); + You can minimize the performance penalty of instrumenting your application by using statements instead of using statements. The following two code examples send the same debugging message. However, the first example is much faster when tracing is off, because if mySwitch.TraceError evaluates to you do not call . The second example always calls , even when mySwitch.TraceError is and no tracing output is produced. This can result in unnecessary execution of arbitrarily complex code. + + **First example** + +```csharp +if(mySwitch.TraceError) + Trace.Write("aNumber = " + aNumber + " out of range"); +``` + + **Second example** + +```csharp +Trace.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); ``` @@ -2411,42 +2411,42 @@ Trace.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); A message to write. Writes a message to the trace listeners in the collection if a condition is . - . - - This method calls the method of the trace listener. - - - -## Examples - The following example creates a named `generalSwitch`. This switch is set outside the code sample. - - If the switch is set to the `Error` or higher, the example outputs the first error message to the . For information on adding a listener to the collection, see the class. - - 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. - + . + + This method calls the method of the trace listener. + + + +## Examples + The following example creates a named `generalSwitch`. This switch is set outside the code sample. + + If the switch is set to the `Error` or higher, the example outputs the first error message to the . For information on adding a listener to the collection, see the class. + + 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.WriteIf Example/VB/source.vb" id="Snippet1"::: + ]]> - You can minimize the performance penalty of instrumenting your application by using statements instead of using statements. The following two code examples send the same debugging message. However, the first example is much faster when tracing is off, because if mySwitch.TraceError evaluates to you do not call . The second example always calls , even when mySwitch.TraceError is and no tracing output is produced. This can result in unnecessary execution of arbitrarily complex code. - - **First example** - -```csharp -if(mySwitch.TraceError) - Trace.Write("aNumber = " + aNumber + " out of range"); -``` - - **Second example** - -```csharp -Trace.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); + You can minimize the performance penalty of instrumenting your application by using statements instead of using statements. The following two code examples send the same debugging message. However, the first example is much faster when tracing is off, because if mySwitch.TraceError evaluates to you do not call . The second example always calls , even when mySwitch.TraceError is and no tracing output is produced. This can result in unnecessary execution of arbitrarily complex code. + + **First example** + +```csharp +if(mySwitch.TraceError) + Trace.Write("aNumber = " + aNumber + " out of range"); +``` + + **Second example** + +```csharp +Trace.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); ``` @@ -2513,44 +2513,44 @@ Trace.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); A category name used to organize the output. Writes a category name and the value of the object's method to the trace listeners in the collection if a condition is . - . - - The `category` parameter can be used to group output messages. - - This method calls the method of the trace listener. - - - -## Examples - The following example creates a named `generalSwitch`. This switch is set outside the code sample. - - If the switch is set to the `Verbose`, the example outputs the name of the `myObject` and the `category` to the . For information on adding a listener to the collection, see the class. - - 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. - + . + + The `category` parameter can be used to group output messages. + + This method calls the method of the trace listener. + + + +## Examples + The following example creates a named `generalSwitch`. This switch is set outside the code sample. + + If the switch is set to the `Verbose`, the example outputs the name of the `myObject` and the `category` to the . For information on adding a listener to the collection, see the class. + + 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.WriteIf3 Example/VB/source.vb" id="Snippet1"::: + ]]> - You can minimize the performance penalty of instrumenting your application by using statements instead of using statements. The following two code examples send the same debugging message. However, the first example is much faster when tracing is off, because if mySwitch.TraceError evaluates to you do not call . The second example always calls , even when mySwitch.TraceError is and no tracing output is produced. This can result in unnecessary execution of arbitrarily complex code. - - **First example** - -```csharp -if(mySwitch.TraceError) - Trace.Write("aNumber = " + aNumber + " out of range"); -``` - - **Second example** - -```csharp -Trace.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); + You can minimize the performance penalty of instrumenting your application by using statements instead of using statements. The following two code examples send the same debugging message. However, the first example is much faster when tracing is off, because if mySwitch.TraceError evaluates to you do not call . The second example always calls , even when mySwitch.TraceError is and no tracing output is produced. This can result in unnecessary execution of arbitrarily complex code. + + **First example** + +```csharp +if(mySwitch.TraceError) + Trace.Write("aNumber = " + aNumber + " out of range"); +``` + + **Second example** + +```csharp +Trace.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); ``` @@ -2617,44 +2617,44 @@ Trace.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); A category name used to organize the output. Writes a category name and message to the trace listeners in the collection if a condition is . - . - - The `category` parameter can be used to group output messages. - - This method calls the method of the trace listener. - - - -## Examples - The following example creates a named `generalSwitch`. This switch is set outside the code sample. - - If the switch is set to the `Verbose`, the example outputs the first error message to the . For information on adding a listener to the collection, see the class. - - 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. - + . + + The `category` parameter can be used to group output messages. + + This method calls the method of the trace listener. + + + +## Examples + The following example creates a named `generalSwitch`. This switch is set outside the code sample. + + If the switch is set to the `Verbose`, the example outputs the first error message to the . For information on adding a listener to the collection, see the class. + + 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.WriteIf2 Example/VB/source.vb" id="Snippet1"::: + ]]> - You can minimize the performance penalty of instrumenting your application by using statements instead of using statements. The following two code examples send the same debugging message. However, the first example is much faster when tracing is off, because if mySwitch.TraceError evaluates to you do not call . The second example always calls , even when mySwitch.TraceError is and no tracing output is produced. This can result in unnecessary execution of arbitrarily complex code. - - **First example** - -```csharp -if(mySwitch.TraceError) - Trace.Write("aNumber = " + aNumber + " out of range"); -``` - - **Second example** - -```csharp -Trace.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); + You can minimize the performance penalty of instrumenting your application by using statements instead of using statements. The following two code examples send the same debugging message. However, the first example is much faster when tracing is off, because if mySwitch.TraceError evaluates to you do not call . The second example always calls , even when mySwitch.TraceError is and no tracing output is produced. This can result in unnecessary execution of arbitrarily complex code. + + **First example** + +```csharp +if(mySwitch.TraceError) + Trace.Write("aNumber = " + aNumber + " out of range"); +``` + + **Second example** + +```csharp +Trace.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); ``` @@ -2726,26 +2726,26 @@ Trace.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); An whose name is sent to the . Writes the value of the object's method to the trace listeners in the collection. - . - - This method calls the method of the trace listener. - - - -## Examples - The following example creates a named `generalSwitch`. This switch is set outside the code sample. - - If the switch is set to the `Error` or higher, the example outputs the first error message to the . For information on adding a listener to the collection, see the class. - - 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. - + . + + This method calls the method of the trace listener. + + + +## Examples + The following example creates a named `generalSwitch`. This switch is set outside the code sample. + + If the switch is set to the `Error` or higher, the example outputs the first error message to the . For information on adding a listener to the collection, see the class. + + 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.WriteLine1 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2807,26 +2807,26 @@ Trace.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); A message to write. Writes a message to the trace listeners in the collection. - . - - This method calls the method of the trace listener. - - - -## Examples - The following example creates a named `generalSwitch`. This switch is set outside the code sample. - - If the switch is set to the `Error` or higher, the example outputs the first error message to the . For information on adding a listener to the collection, see the class. - - 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. - + . + + This method calls the method of the trace listener. + + + +## Examples + The following example creates a named `generalSwitch`. This switch is set outside the code sample. + + If the switch is set to the `Error` or higher, the example outputs the first error message to the . For information on adding a listener to the collection, see the class. + + 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.Write Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2890,28 +2890,28 @@ Trace.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); A category name used to organize the output. Writes a category name and the value of the object's method to the trace listeners in the collection. - . - - The `category` parameter can be used to group output messages. - - This method calls the method of the trace listener. - - - -## Examples - The following example creates a named `generalSwitch`. This switch is set outside the code sample. - - If the switch is set to the `Error` or higher, the example outputs the first error message to the . For information on adding a listener to the collection, see the class. - - 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. - + . + + The `category` parameter can be used to group output messages. + + This method calls the method of the trace listener. + + + +## Examples + The following example creates a named `generalSwitch`. This switch is set outside the code sample. + + If the switch is set to the `Error` or higher, the example outputs the first error message to the . For information on adding a listener to the collection, see the class. + + 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.WriteLine3 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2975,28 +2975,28 @@ Trace.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); A category name used to organize the output. Writes a category name and message to the trace listeners in the collection. - . - - The `category` parameter can be used to group output messages. - - This method calls the method of the trace listener. - - - -## Examples - The following example creates a named `generalSwitch`. This switch is set outside the code sample. - - If the switch is set to the `Error` or higher, the example outputs the first error message to the . For information on adding a listener to the collection, see the class. - - 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. - + . + + The `category` parameter can be used to group output messages. + + This method calls the method of the trace listener. + + + +## Examples + The following example creates a named `generalSwitch`. This switch is set outside the code sample. + + If the switch is set to the `Error` or higher, the example outputs the first error message to the . For information on adding a listener to the collection, see the class. + + 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.WriteLine2 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -3071,42 +3071,42 @@ Trace.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); An whose name is sent to the . Writes the value of the object's method to the trace listeners in the collection if a condition is . - . - - This method calls the method of the trace listener. - - - -## Examples - The following example creates a named `generalSwitch`. This switch is set outside the code sample. - - If the switch is set to the `Error` or higher, the example outputs the first error message to the . For information on adding a listener to the collection, see the class. - - 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. - + . + + This method calls the method of the trace listener. + + + +## Examples + The following example creates a named `generalSwitch`. This switch is set outside the code sample. + + If the switch is set to the `Error` or higher, the example outputs the first error message to the . For information on adding a listener to the collection, see the class. + + 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf1 Example/VB/source.vb" id="Snippet1"::: + ]]> - You can minimize the performance penalty of instrumenting your application by using statements instead of using statements. The following two code examples send the same debugging message. However, the first example is much faster when tracing is off, because if mySwitch.TraceError evaluates to you do not call . The second example always calls , even when mySwitch.TraceError is and no tracing output is produced. This can result in unnecessary execution of arbitrarily complex code. - - **First example** - -```csharp -if(mySwitch.TraceError) - Trace.WriteLine("aNumber = " + aNumber + " out of range"); -``` - - **Second example** - -```csharp -Trace.WriteLineIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); + You can minimize the performance penalty of instrumenting your application by using statements instead of using statements. The following two code examples send the same debugging message. However, the first example is much faster when tracing is off, because if mySwitch.TraceError evaluates to you do not call . The second example always calls , even when mySwitch.TraceError is and no tracing output is produced. This can result in unnecessary execution of arbitrarily complex code. + + **First example** + +```csharp +if(mySwitch.TraceError) + Trace.WriteLine("aNumber = " + aNumber + " out of range"); +``` + + **Second example** + +```csharp +Trace.WriteLineIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); ``` @@ -3171,42 +3171,42 @@ Trace.WriteLineIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range") A message to write. Writes a message to the trace listeners in the collection if a condition is . - . - - This method calls the method of the trace listener. - - - -## Examples - The following example creates a named `generalSwitch`. This switch is set outside the code sample. - - If the switch is set to the `Error` or higher, the example outputs the first error message to the . For information on adding a listener to the collection, see the class. - - 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. - + . + + This method calls the method of the trace listener. + + + +## Examples + The following example creates a named `generalSwitch`. This switch is set outside the code sample. + + If the switch is set to the `Error` or higher, the example outputs the first error message to the . For information on adding a listener to the collection, see the class. + + 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.WriteIf Example/VB/source.vb" id="Snippet1"::: + ]]> - You can minimize the performance penalty of instrumenting your application by using statements instead of using statements. The following two code examples send the same debugging message. However, the first example is much faster when tracing is off, because if mySwitch.TraceError evaluates to you do not call . The second example always calls , even when mySwitch.TraceError is and no tracing output is produced. This can result in unnecessary execution of arbitrarily complex code. - - **First example** - -```csharp -if(mySwitch.TraceError) - Trace.WriteLine("aNumber = " + aNumber + " out of range"); -``` - - **Second example** - -```csharp -Trace.WriteLineIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); + You can minimize the performance penalty of instrumenting your application by using statements instead of using statements. The following two code examples send the same debugging message. However, the first example is much faster when tracing is off, because if mySwitch.TraceError evaluates to you do not call . The second example always calls , even when mySwitch.TraceError is and no tracing output is produced. This can result in unnecessary execution of arbitrarily complex code. + + **First example** + +```csharp +if(mySwitch.TraceError) + Trace.WriteLine("aNumber = " + aNumber + " out of range"); +``` + + **Second example** + +```csharp +Trace.WriteLineIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); ``` @@ -3273,44 +3273,44 @@ Trace.WriteLineIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range") A category name used to organize the output. Writes a category name and the value of the object's method to the trace listeners in the collection if a condition is . - . - - The `category` parameter can be used to group output messages. - - This method calls the method of the trace listener. - - - -## Examples - The following example creates a named `generalSwitch`. This switch is set outside the code sample. - - If the switch is set to the `Error` or higher, the example outputs the first error message to the . For information on adding a listener to the collection, see the class. - - 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. - + . + + The `category` parameter can be used to group output messages. + + This method calls the method of the trace listener. + + + +## Examples + The following example creates a named `generalSwitch`. This switch is set outside the code sample. + + If the switch is set to the `Error` or higher, the example outputs the first error message to the . For information on adding a listener to the collection, see the class. + + 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf3 Example/VB/source.vb" id="Snippet1"::: + ]]> - You can minimize the performance penalty of instrumenting your application by using statements instead of using statements. The following two code examples send the same debugging message. However, the first example is much faster when tracing is off, because if mySwitch.TraceError evaluates to you do not call . The second example always calls , even when mySwitch.TraceError is and no tracing output is produced. This can result in unnecessary execution of arbitrarily complex code. - - **First example** - -```csharp -if(mySwitch.TraceError) - Trace.WriteLine("aNumber = " + aNumber + " out of range"); -``` - - **Second example** - -```csharp -Trace.WriteLineIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); + You can minimize the performance penalty of instrumenting your application by using statements instead of using statements. The following two code examples send the same debugging message. However, the first example is much faster when tracing is off, because if mySwitch.TraceError evaluates to you do not call . The second example always calls , even when mySwitch.TraceError is and no tracing output is produced. This can result in unnecessary execution of arbitrarily complex code. + + **First example** + +```csharp +if(mySwitch.TraceError) + Trace.WriteLine("aNumber = " + aNumber + " out of range"); +``` + + **Second example** + +```csharp +Trace.WriteLineIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); ``` @@ -3377,44 +3377,44 @@ Trace.WriteLineIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range") A category name used to organize the output. Writes a category name and message to the trace listeners in the collection if a condition is . - . - - The `category` parameter can be used to group output messages. - - This method calls the method of the trace listener. - - - -## Examples - The following example creates a named `generalSwitch`. This switch is set outside the code sample. - - If the switch is set to the `Error` or higher, the example outputs the first error message to the . For information on adding a listener to the collection, see the class. - - 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. - + . + + The `category` parameter can be used to group output messages. + + This method calls the method of the trace listener. + + + +## Examples + The following example creates a named `generalSwitch`. This switch is set outside the code sample. + + If the switch is set to the `Error` or higher, the example outputs the first error message to the . For information on adding a listener to the collection, see the class. + + 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"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Trace.WriteLineIf2 Example/VB/source.vb" id="Snippet1"::: + ]]> - You can minimize the performance penalty of instrumenting your application by using statements instead of using statements. The following two code examples send the same debugging message. However, the first example is much faster when tracing is off, because if mySwitch.TraceError evaluates to you do not call . The second example always calls , even when mySwitch.TraceError is and no tracing output is produced. This can result in unnecessary execution of arbitrarily complex code. - - **First example** - -```csharp -if(mySwitch.TraceError) - Trace.WriteLine("aNumber = " + aNumber + " out of range"); -``` - - **Second example** - -```csharp -Trace.WriteLineIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); + You can minimize the performance penalty of instrumenting your application by using statements instead of using statements. The following two code examples send the same debugging message. However, the first example is much faster when tracing is off, because if mySwitch.TraceError evaluates to you do not call . The second example always calls , even when mySwitch.TraceError is and no tracing output is produced. This can result in unnecessary execution of arbitrarily complex code. + + **First example** + +```csharp +if(mySwitch.TraceError) + Trace.WriteLine("aNumber = " + aNumber + " out of range"); +``` + + **Second example** + +```csharp +Trace.WriteLineIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range"); ``` diff --git a/xml/System.Reflection.Emit/TypeBuilder.xml b/xml/System.Reflection.Emit/TypeBuilder.xml index 5e9160077b3..57ac7fbec80 100644 --- a/xml/System.Reflection.Emit/TypeBuilder.xml +++ b/xml/System.Reflection.Emit/TypeBuilder.xml @@ -4674,7 +4674,7 @@ See for a description of the format of the ## Remarks The method provides a way to get a object that represents a constructor of a constructed generic type whose generic type definition is represented by a object. - For example, suppose you have a object that represents the type `G` in C# syntax (`G(Of T)` in Visual Basic, `generic ref class G` in C++) and a object that represents a constructor of `G`. Suppose that `G` has a generic method with type parameter `U` that creates an instance of the constructed type `G`. In order to emit the code to create an instance of the constructed type, you need a object that represents the constructor of this constructed type - in other words, that creates an instance of `G`. To do this, first call the method on the object, specifying the object that represents `U` as the type argument. Then call the method with the return value of the method as parameter `type` and the object that represents the constructor of `G` as parameter `constructor`. The return value is the object you need to emit the function call. The code example demonstrates this scenario. + For example, suppose you have a object that represents the type `G` in C# syntax (`G(Of T)` in Visual Basic) and a object that represents a constructor of `G`. Suppose that `G` has a generic method with type parameter `U` that creates an instance of the constructed type `G`. In order to emit the code to create an instance of the constructed type, you need a object that represents the constructor of this constructed type - in other words, that creates an instance of `G`. To do this, first call the method on the object, specifying the object that represents `U` as the type argument. Then call the method with the return value of the method as parameter `type` and the object that represents the constructor of `G` as parameter `constructor`. The return value is the object you need to emit the function call. The code example demonstrates this scenario. @@ -5340,7 +5340,7 @@ See for a description of the format of the ## Remarks The method provides a way to get a object that represents a field of a constructed generic type whose generic type definition is represented by a object. - For example, suppose you have a object that represents the type `G` in C# syntax (`G(Of T)` in Visual Basic, `generic ref class G` in C++) and a object that represents a field `public T F` in C# syntax (`Public F As T` in Visual Basic, `public: T F` in C++) that is defined by `G`. Suppose that `G` has a generic method with type parameter `U` that creates an instance of the constructed type `G` and calls field `F` on that instance. In order to emit the function call, you need a object that represents `F` on the constructed type - in other words, that is of type `U` rather than type `T`. To do this, first call the method on the object, specifying the object that represents `U` as the type argument. Then call the method with the return value of the method as parameter `type` and the object that represents `F` as parameter `field`. The return value is the object you need to emit the function call. The code example demonstrates this scenario. + For example, suppose you have a object that represents the type `G` in C# syntax (`G(Of T)` in Visual Basic) and a object that represents a field `public T F` in C# syntax (`Public F As T` in Visual Basic) that's defined by `G`. Suppose that `G` has a generic method with type parameter `U` that creates an instance of the constructed type `G` and calls field `F` on that instance. In order to emit the function call, you need a object that represents `F` on the constructed type - in other words, that is of type `U` rather than type `T`. To do this, first call the method on the object, specifying the object that represents `U` as the type argument. Then call the method with the return value of the method as parameter `type` and the object that represents `F` as parameter `field`. The return value is the object you need to emit the function call. The code example demonstrates this scenario. @@ -5939,7 +5939,7 @@ See for a description of the format of the ## Remarks The method provides a way to get a object that represents a method of a constructed generic type whose generic type definition is represented by a object. - For example, suppose you have a object that represents the type `G` in C# syntax (`G(Of T)` in Visual Basic, `generic ref class G` in C++) and a object that represents a method `T M()` in C# syntax (`Function M() As T` in Visual Basic, `T M()` in C++) that is defined by `G`. Suppose that `G` has a generic method with type parameter `U` that creates an instance of the constructed type `G` and calls method `M` on that instance. In order to emit the function call, you need a object that represents `M` on the constructed type - in other words, that returns type `U` rather than type `T`. To do this, first call the method on the object, specifying the object that represents `U` as the type argument. Then call the method with the return value of the method as parameter `type` and the object that represents `T M()` as parameter `method`. The return value is the object you need to emit the function call. The code example demonstrates a scenario similar to this. + For example, suppose you have a object that represents the type `G` in C# syntax (`G(Of T)` in Visual Basic) and a object that represents a method `T M()` in C# syntax (`Function M() As T` in Visual Basic) that is defined by `G`. Suppose that `G` has a generic method with type parameter `U` that creates an instance of the constructed type `G` and calls method `M` on that instance. In order to emit the function call, you need a object that represents `M` on the constructed type - in other words, that returns type `U` rather than type `T`. To do this, first call the method on the object, specifying the object that represents `U` as the type argument. Then call the method with the return value of the method as parameter `type` and the object that represents `T M()` as parameter `method`. The return value is the object you need to emit the function call. The code example demonstrates a scenario similar to this. diff --git a/xml/System.Reflection/AssemblyDelaySignAttribute.xml b/xml/System.Reflection/AssemblyDelaySignAttribute.xml index 74fc664fd72..df73e0add59 100644 --- a/xml/System.Reflection/AssemblyDelaySignAttribute.xml +++ b/xml/System.Reflection/AssemblyDelaySignAttribute.xml @@ -80,7 +80,7 @@ For more information, see the [Common Language Infrastructure (CLI) documentatio sn -k TestPublicKey.snk ``` - Compile the example as a .dll. If you compile from the command line, use the `/t:library` option for C# or Visual Basic, or the `/LD` linker option for Visual C++. + Compile the example as a .dll. If you compile from the command line, use the `/t:library` option. :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyDelaySignAttribute/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyDelaySignAttribute/Overview/source.cs" id="Snippet1"::: diff --git a/xml/System.Reflection/AssemblyKeyFileAttribute.xml b/xml/System.Reflection/AssemblyKeyFileAttribute.xml index e88238e6a3b..686d82cfcee 100644 --- a/xml/System.Reflection/AssemblyKeyFileAttribute.xml +++ b/xml/System.Reflection/AssemblyKeyFileAttribute.xml @@ -68,31 +68,31 @@ Specifies the name of a file containing the key pair used to generate a strong name. - . If has also been specified, it is likely that this file will only contain the public key. - - An example of the syntax is `[assembly:AssemblyKeyFileAttribute("myKey.snk")]`. - + . If has also been specified, it is likely that this file will only contain the public key. + + An example of the syntax is `[assembly:AssemblyKeyFileAttribute("myKey.snk")]`. + > [!CAUTION] -> Since the path and file name persist, ensure that the string you use with `AssemblyKeyFileAttribute` does not contain sensitive information. - - - -## Examples - The following code example shows the use of the attribute with the . To compile this example, you must create a strong-name key file named TestPublicKey.snk using the [Sn.exe (Strong Name Tool)](/dotnet/framework/tools/sn-exe-strong-name-tool): - -```console -sn -k TestPublicKey.snk -``` - - Compile the example as a .dll. If you compile from the command line, use the `/t:library` option for C# or Visual Basic, or the `/LD` linker option for Visual C++. - +> Since the path and file name persist, ensure that the string you use with `AssemblyKeyFileAttribute` does not contain sensitive information. + + + +## Examples + The following code example shows the use of the attribute with the . To compile this example, you must create a strong-name key file named TestPublicKey.snk using the [Sn.exe (Strong Name Tool)](/dotnet/framework/tools/sn-exe-strong-name-tool): + +```console +sn -k TestPublicKey.snk +``` + + Compile the example as a .dll. If you compile from the command line, use the `/t:library` option. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AssemblyDelaySignAttribute/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/AssemblyDelaySignAttribute/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyDelaySignAttribute/vb/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AssemblyDelaySignAttribute/vb/source.vb" id="Snippet1"::: + ]]> Metadata and Self-Describing Components @@ -142,16 +142,16 @@ sn -k TestPublicKey.snk The name of the file containing the key pair. Initializes a new instance of the class with the name of the file containing the key pair to generate a strong name for the assembly being attributed. - constructor. The value set by the constructor is interpreted by the linker, or by Microsoft Visual Studio 2005, that invokes the linker. - - The default setting for the [Al.exe (Assembly Linker)](/dotnet/framework/tools/al-exe-assembly-linker) tool assumes that the key file is in the current directory. In Visual Studio 2005, the Visual Basic and Visual C# compilers build and link to subdirectories of the project directory, so if you put the key file in the project directory the relative path might be "..\\..\keyfile.snk" or "..\keyfile.snk" in Visual Basic, or "..\\\\..\\\keyfile.snk" or "..\\\keyfile.snk" in C#. For C#, this attribute can be set in the project properties. - + constructor. The value set by the constructor is interpreted by the linker, or by Microsoft Visual Studio 2005, that invokes the linker. + + The default setting for the [Al.exe (Assembly Linker)](/dotnet/framework/tools/al-exe-assembly-linker) tool assumes that the key file is in the current directory. In Visual Studio 2005, the Visual Basic and Visual C# compilers build and link to subdirectories of the project directory, so if you put the key file in the project directory the relative path might be "..\\..\keyfile.snk" or "..\keyfile.snk" in Visual Basic, or "..\\\\..\\\keyfile.snk" or "..\\\keyfile.snk" in C#. For C#, this attribute can be set in the project properties. + > [!CAUTION] -> Because the path and file name persist, ensure that the string you use with `AssemblyKeyFileAttribute` does not contain sensitive information. - +> Because the path and file name persist, ensure that the string you use with `AssemblyKeyFileAttribute` does not contain sensitive information. + ]]> @@ -199,13 +199,13 @@ sn -k TestPublicKey.snk Gets the name of the file containing the key pair used to generate a strong name for the attributed assembly. A string containing the name of the file that contains the key pair. - [!CAUTION] -> Because the path and file name persist, ensure that the string you use with `AssemblyKeyFileAttribute` does not contain sensitive information. - +> Because the path and file name persist, ensure that the string you use with `AssemblyKeyFileAttribute` does not contain sensitive information. + ]]> diff --git a/xml/System.Reflection/FieldInfo.xml b/xml/System.Reflection/FieldInfo.xml index 6b3e9afcc34..7e87c54a3f9 100644 --- a/xml/System.Reflection/FieldInfo.xml +++ b/xml/System.Reflection/FieldInfo.xml @@ -1103,9 +1103,7 @@ Note: In .NET for Win ## Remarks The actual visibility of a field is limited by the visibility of its type. The property might be `true` for a field, but if it is a field of a private nested type then the field is not visible outside the containing type. - The visibility of a field is exactly described by if the only visibility modifier is `internal` (`Friend` in Visual Basic). This property is `false` for fields that are `protected internal` in C# (`Protected Friend` in Visual Basic, `protected public` in C++); use the property to identify such fields. - - + The visibility of a field is exactly described by if the only visibility modifier is `internal` (`Friend` in Visual Basic). This property is `false` for fields that are `protected internal` in C# (`Protected Friend` in Visual Basic); use the property to identify such fields. ## Examples The following code example defines fields with varying levels of visibility, and displays the values of their , , , and properties. @@ -1174,9 +1172,7 @@ Note: In .NET for Win if the only visibility modifier is `protected`. This property is `false` for fields that are `protected internal` in C# (`Protected Friend` in Visual Basic, `protected public` in C++); use the property to identify such fields. - - + The visibility of a field is exactly described by if the only visibility modifier is `protected`. This property is `false` for fields that are `protected internal` in C# (`Protected Friend` in Visual Basic); use the property to identify such fields. ## Examples The following code example defines fields with varying levels of visibility, and displays the values of their , , , and properties. @@ -1249,14 +1245,11 @@ Note: In .NET for Win ## Remarks If a field has level visibility, it can be called from any member in a derived class that is also in the same assembly, but not from any other type. - The visibility of a field is exactly described by if the visibility modifier is `private protected` in C#, `Private Protected` in Visual Basic, or `protected private` in C++. - - + The visibility of a field is exactly described by if the visibility modifier is `private protected` in C# or `Private Protected` in Visual Basic. ## Examples The following code example defines fields with varying levels of visibility, and displays the values of their , , , and properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.IsAssembly Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/FieldInfo/IsAssembly/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FieldInfo.IsAssembly Example/VB/source.vb" id="Snippet1"::: @@ -1325,14 +1318,11 @@ Note: In .NET for Win The actual visibility of a field is limited by the visibility of its type. The property might be `true` for a field, but if it is a field of a private nested type then the field is not visible outside the containing type. - The visibility of a field is exactly described by if the visibility modifier is `protected internal` in C# (`Protected Friend` in Visual Basic, `protected public` in C++). - - + The visibility of a field is exactly described by if the visibility modifier is `protected internal` in C# (`Protected Friend` in Visual Basic). ## Examples The following code example defines fields with varying levels of visibility, and displays the values of their , , , and properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FieldInfo.IsAssembly Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/FieldInfo/IsAssembly/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FieldInfo.IsAssembly Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Reflection/MethodBase.xml b/xml/System.Reflection/MethodBase.xml index c646944a5b2..ece55bab79c 100644 --- a/xml/System.Reflection/MethodBase.xml +++ b/xml/System.Reflection/MethodBase.xml @@ -825,7 +825,7 @@ ## Remarks Handles are valid only in the application domain in which they were obtained. - A structure for a constructor or method of a generic type can represent different objects, depending on the types specified for the type parameters of the generic type. For example, if `class G` (`class G(Of T)` in Visual Basic, `generic ref class G` in C++) has a method that returns type `T`, the object for that method in a constructed class such as `G` is different from the object for that method in the generic type definition. + A structure for a constructor or method of a generic type can represent different objects, depending on the types specified for the type parameters of the generic type. For example, if `class G` (`class G(Of T)` in Visual Basic) has a method that returns type `T`, the object for that method in a constructed class such as `G` is different from the object for that method in the generic type definition. ]]> @@ -1370,9 +1370,7 @@ This method dynamically invokes the method reflected by this instance on `obj`, ## Remarks The actual visibility of a method is limited by the visibility of its type. The property might be `true` for a method, but if it is a method of a private nested type then the method is not visible outside the containing type. - The visibility of a method or constructor is exactly described by if the only visibility modifier is `internal` (`Friend` in Visual Basic). This property is `false` for methods that are `protected internal` in C# (`Protected Friend` in Visual Basic, `protected public` in C++); use the property to identify such methods. - - + The visibility of a method or constructor is exactly described by if the only visibility modifier is `internal` (`Friend` in Visual Basic). This property is `false` for methods that are `protected internal` in C# (`Protected Friend` in Visual Basic); use the property to identify such methods. ## Examples The following code example defines methods with varying levels of visibility, and displays the values of their , , , and properties. @@ -1546,9 +1544,7 @@ This method dynamically invokes the method reflected by this instance on `obj`, if the only visibility modifier is `protected`. This property is `false` for methods that are `protected internal` in C# (`Protected Friend` in Visual Basic, `protected public` in C++); use the property to identify such methods. - - + The visibility of a method or constructor is exactly described by if the only visibility modifier is `protected`. This property is `false` for methods that are `protected internal` in C# (`Protected Friend` in Visual Basic); use the property to identify such methods. ## Examples The following code example defines methods with varying levels of visibility, and displays the values of their , , , and properties. @@ -1617,9 +1613,7 @@ This method dynamically invokes the method reflected by this instance on `obj`, if the visibility modifier is `private protected` in C#, `Private Protected` in Visual Basic, or `protected private` in C++. - - + The visibility of a method or constructor is exactly described by if the visibility modifier is `private protected` in C# or `Private Protected` in Visual Basic. ## Examples The following code example defines methods with varying levels of visibility, and displays the values of their , , , and properties. @@ -1692,9 +1686,7 @@ This method dynamically invokes the method reflected by this instance on `obj`, The actual visibility of a method is limited by the visibility of its type. The property might be `true` for a method, but if it is a method of a private nested type then the method is not visible outside the containing type. - The visibility of a method or constructor is exactly described by if the visibility modifier is `protected internal` in C# (`Protected Friend` in Visual Basic, `protected public` in C++). - - + The visibility of a method or constructor is exactly described by if the visibility modifier is `protected internal` in C# (`Protected Friend` in Visual Basic). ## Examples The following code example defines methods with varying levels of visibility, and displays the values of their , , , and properties. @@ -1764,7 +1756,7 @@ This method dynamically invokes the method reflected by this instance on `obj`, ## Remarks -If the virtual method is marked `final`, it can't be overridden in derived classes. The overridden virtual method can be marked `final` using the [sealed](/dotnet/csharp/language-reference/keywords/sealed) keyword in C#, [NotOverridable](/dotnet/visual-basic/language-reference/modifiers/notoverridable) keyword in Visual Basic, or [sealed](/cpp/extensions/sealed-cpp-component-extensions) keyword in C++/CLI. The method can also be marked `final` implicitly by the compiler. For example, a method might be defined as non-virtual in your code, but it implements an interface method. The Common Language Runtime requires that all methods that implement interface members must be marked as `virtual`; therefore, the compiler marks the method `virtual final`. +If the virtual method is marked `final`, it can't be overridden in derived classes. The overridden virtual method can be marked `final` using the [sealed](/dotnet/csharp/language-reference/keywords/sealed) keyword in C# or [NotOverridable](/dotnet/visual-basic/language-reference/modifiers/notoverridable) keyword in Visual Basic. The method can also be marked `final` implicitly by the compiler. For example, a method might be defined as non-virtual in your code, but it implements an interface method. The Common Language Runtime requires that all methods that implement interface members must be marked as `virtual`; therefore, the compiler marks the method `virtual final`. You can use this property, in conjunction with the property, to determine if a method is overridable. For a method to be overridable, property must be `true` and `IsFinal` property must be `false`. To establish with certainty whether a method is overridable, use code such as this: @@ -1778,8 +1770,6 @@ If MethodInfo.IsVirtual AndAlso Not MethodInfo.IsFinal Then If `IsVirtual` is `false` or `IsFinal` is `true`, then the method cannot be overridden. - - ## Examples The following example displays `false` for `IsFinal`, which might lead you to think that MyMethod is overridable. The code prints `false` even though MyMethod is not marked `virtual` and thus cannot be overridden. diff --git a/xml/System.Reflection/PropertyInfo.xml b/xml/System.Reflection/PropertyInfo.xml index 10de1965426..3b636fe94cf 100644 --- a/xml/System.Reflection/PropertyInfo.xml +++ b/xml/System.Reflection/PropertyInfo.xml @@ -98,13 +98,13 @@ Properties are logically the same as fields. A property is a named aspect of an object's state whose value is typically accessible through `get` and `set` accessors. Properties may be read-only, in which case a set routine is not supported. > [!NOTE] -> To determine whether a property is `static`, you must obtain the for the `get` or `set` accessor, by calling the or the method, and examine its property. +> To determine whether a property is `static`, you must obtain the for the `get` or `set` accessor, by calling the or the method, and examine its property. Several methods in this class assume that the `get` accessor and `set` accessor methods of a property have certain formats. The signatures of the `get` and `set` methods must match the following convention: -- The return type of the `get` method and the last argument of the `set` method must be identical. This is the type of the property. +- The return type of the `get` method and the last argument of the `set` method must be identical. This is the type of the property. -- The `get` and `set` methods must have the same number, type, and order of indices. +- The `get` and `set` methods must have the same number, type, and order of indices. If this format is not followed, the behavior of the `GetValue` and `SetValue` methods is undefined. @@ -116,7 +116,7 @@ This example shows how to use various reflection classes to analyze the metadata contained in an assembly. > [!NOTE] -> This example generates about 55,000 lines of data, which you can redirect to a text file at the command prompt, as follows: **example.exe > propertyinfo.txt** +> This example generates about 55,000 lines of data, which you can redirect to a text file at the command prompt, as follows: **example.exe > propertyinfo.txt** :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Reflection/CPP/reflection.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/Assembly/GetReferencedAssemblies/Reflection.cs" id="Snippet1"::: @@ -224,7 +224,7 @@ The property returns the attributes associated with the property represented by this object. The attributes are primarily modifiers applied by a compiler when creating a property; they indicate whether a property is the default property, a `SpecialName` property, and so on. Note that, for almost all properties found in types in the .NET Framework class library, the value of the property is . > [!TIP] -> In most cases, you probably want to retrieve the custom attributes associated with a property. To do this, retrieve the value of the property, or call one of the overloads of the method. +> In most cases, you probably want to retrieve the custom attributes associated with a property. To do this, retrieve the value of the property, or call one of the overloads of the method. To get the property: @@ -647,7 +647,7 @@ This method is provided for designers of managed compilers and code analyzers. > [!NOTE] -> Do not use this method in the reflection-only context, because it might cause code to execute. Use the method instead. +> Do not use this method in the reflection-only context, because it might cause code to execute. Use the method instead. In unmanaged metadata, the Constant table is used to store constant values for fields, parameters, and properties. Constant information does not directly influence runtime behavior. Compilers inspect this information, at compile time, when importing metadata. If used, the value of a constant is embedded in the Microsoft intermediate language (MSIL) stream the compiler emits. There are no MSIL instructions that can be used to access the Constant table at run time. @@ -1532,7 +1532,7 @@ Console.WriteLine("CurrCult: " + To use the `GetValue` method, first get the class `Type`. From the `Type`, get the `PropertyInfo`. From the `PropertyInfo`, use the `GetValue` method. > [!NOTE] -> Starting with .NET Framework 2.0, this method can be used to access non-public members if the caller has been granted with the flag and if the grant set of the non-public members is restricted to the caller's grant set, or a subset thereof. (See [Security Considerations for Reflection](/dotnet/framework/reflection-and-codedom/security-considerations-for-reflection).) To use this functionality, your application should target .NET Framework 3.5 or later. +> Starting with .NET Framework 2.0, this method can be used to access non-public members if the caller has been granted with the flag and if the grant set of the non-public members is restricted to the caller's grant set, or a subset thereof. (See [Security Considerations for Reflection](/dotnet/framework/reflection-and-codedom/security-considerations-for-reflection).) To use this functionality, your application should target .NET Framework 3.5 or later. @@ -1634,7 +1634,7 @@ Console.WriteLine("CurrCult: " + To use the `GetValue` method, first get the class `Type`. From the `Type`, get the `PropertyInfo`. From the `PropertyInfo`, use the `GetValue` method. > [!NOTE] -> Starting with .NET Framework 2.0, this method can be used to access non-public members if the caller has been granted with the flag and if the grant set of the non-public members is restricted to the caller's grant set, or a subset thereof. (See [Security Considerations for Reflection](/dotnet/framework/reflection-and-codedom/security-considerations-for-reflection).) To use this functionality, your application should target .NET Framework 3.5 or later. +> Starting with .NET Framework 2.0, this method can be used to access non-public members if the caller has been granted with the flag and if the grant set of the non-public members is restricted to the caller's grant set, or a subset thereof. (See [Security Considerations for Reflection](/dotnet/framework/reflection-and-codedom/security-considerations-for-reflection).) To use this functionality, your application should target .NET Framework 3.5 or later. ]]> @@ -2100,9 +2100,7 @@ Console.WriteLine("CurrCult: " + To use the method, first get a object that represents the class. From the , get the object. From the object, call the method. > [!NOTE] -> Starting with .NET Framework 2.0, this method can be used to access non-public members if the caller has been granted with the flag and if the grant set of the non-public members is restricted to the caller's grant set, or a subset thereof. (See [Security Considerations for Reflection](/dotnet/framework/reflection-and-codedom/security-considerations-for-reflection).) To use this functionality, your application should target .NET Framework 3.5 or later. - - +> Starting with .NET Framework 2.0, this method can be used to access non-public members if the caller has been granted with the flag and if the grant set of the non-public members is restricted to the caller's grant set, or a subset thereof. (See [Security Considerations for Reflection](/dotnet/framework/reflection-and-codedom/security-considerations-for-reflection).) To use this functionality, your application should target .NET Framework 3.5 or later. ## Examples The following example declares a class named `Example` with one `static` (`Shared` in Visual Basic) and one instance property. The example uses the method to change the original property values and displays the original and final values. @@ -2205,9 +2203,7 @@ Note: In attribute to give the indexer a different name. In this example, the name is `IndexedInstanceProperty`. +- In Visual Basic, the property name is always used to search for the property with reflection. You can use the `Default` keyword to make the property a default indexed property, in which case you can omit the name when accessing the property, as in this example. You can also use the property name. -- In C++, the `default` specifier can be used to make an indexed property a default indexed property (class indexer). In that case, the name of the property by default is `Item`, and you must use that name when you search for the property with reflection, as in this example. You can use the attribute to give the class indexer a different name in reflection, but you cannot use that name to access the property in code. An indexed property that is not a class indexer is accessed using its name, both in code and in reflection. +- In C#, the indexed instance property is a default property called an indexer, and the name is never used when accessing the property in code. By default, the name of the property is `Item`, and you must use that name when you search for the property with reflection. You can use the attribute to give the indexer a different name. In this example, the name is `IndexedInstanceProperty`. :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/PropertyInfo.SetValue/cpp/Example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Reflection/PropertyInfo/SetValue/Example.cs" id="Snippet1"::: @@ -2324,7 +2318,7 @@ Note: In to include the in the filtered list; otherwise . - objects. The method uses this delegate to filter the list of interfaces that it returns. Every derived class of and has a constructor and a `DynamicInvoke` method. See the Visual C++ code example given in the description for `Delegate`. - - - -## Examples - This example shows how to define a method matching the delegate prototype allowing you to use reflection to filter or return a subset of matching entries. - - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/TypeFilter/VB/Typefilter.vb" id="Snippet1"::: - + objects. The method uses this delegate to filter the list of interfaces that it returns. Every derived class of and has a constructor and a `DynamicInvoke` method. + +## Examples + This example shows how to define a method matching the delegate prototype allowing you to use reflection to filter or return a subset of matching entries. + + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/TypeFilter/VB/Typefilter.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Runtime.Caching/MemoryCache.xml b/xml/System.Runtime.Caching/MemoryCache.xml index 9d94f787f82..c15be27505a 100644 --- a/xml/System.Runtime.Caching/MemoryCache.xml +++ b/xml/System.Runtime.Caching/MemoryCache.xml @@ -425,13 +425,14 @@ private void btnGet_Click(object sender, EventArgs e) property, the cache implementation removes cache entries. Each cache instance in the application can use the amount of memory that is specified by the property. +> [!IMPORTANT] +> In .NET Core and .NET 5.0 and later, the property does not have any effect. The underlying implementation for enforcing this limit is not functional outside of .NET Framework. - The settings for the property can be specified in the application configuration file. Alternatively, they can be passed in the constructor when the class is initialized. For more information about how to configure this property, see [<namedCaches> Element (Cache Settings)](/dotnet/framework/configure-apps/file-schema/runtime/namedcaches-element-cache-settings). For more information about how to set this value when the class is being initialized, see the method. +In .NET Framework (4.x), if the current instance of the cache exceeds the limit on memory set by the property, the cache implementation removes cache entries. Each cache instance in the application can use the amount of memory that is specified by the property. In .NET Core and later, this property returns the value from configuration or constructor parameters but is not enforced. - does not instantly enforce each time a new item is added to a instance. The internal heuristics which evicts extra items from the does it gradually and takes into account information from the garbage collector (see [Garbage Collection](/dotnet/standard/garbage-collection/)) and other factors such as current cache size and overall system memory pressure. Therefore even though the tries to keep the cache size within the configured it is possible to temporarily exceed the limit by adding cache items at a very high rate. +You can specify the settings for the property in the application configuration file. Alternatively, they can be passed in the constructor or by a caller when the instance is initialized. - ]]> + ]]> <namedCaches> Element (Cache Settings) @@ -928,15 +929,15 @@ private void btnGet_Click(object sender, EventArgs e) System.Int64 - Gets the percentage of physical memory that the cache can use. - The percentage of physical memory that the cache can use. + Gets the percentage of total system physical memory usage at which the cache will begin evicting entries. + The percentage of overall physical memory usage on the system that triggers cache eviction. property returns the percentage of total physical computer memory that can be used by a single instance of the class. If the cache instance exceeds the specified limit, cache entries are removed. + The property specifies the percentage of total physical memory usage on the system (by all processes) at which the cache will begin to evict entries. This setting is not a limit on the memory that a single instance can use. Instead, when overall system physical memory usage exceeds this percentage, the cache proactively removes entries to help reduce memory pressure and avoid exhausting system memory, even if the cache itself is not over its other size limits. - The settings for the property can be specified in the application configuration file. Alternatively, they can be passed by a caller when the class is initialized. For more information about how to configure this property, see [<namedCaches> Element (Cache Settings)](/dotnet/framework/configure-apps/file-schema/runtime/namedcaches-element-cache-settings). For more information about how to configure the property when the class is being initialized, see the method. + You can specify the settings for the property in the application configuration file. Alternatively, they can be passed by a caller when the instance is initialized. ]]> diff --git a/xml/System.Runtime.CompilerServices/CallConvCdecl.xml b/xml/System.Runtime.CompilerServices/CallConvCdecl.xml index 6794fef3551..9b5fec47e9f 100644 --- a/xml/System.Runtime.CompilerServices/CallConvCdecl.xml +++ b/xml/System.Runtime.CompilerServices/CallConvCdecl.xml @@ -61,25 +61,25 @@ Indicates that a method should use the calling convention. - are for compiler writers' use only. - - Compilers emit custom modifiers within metadata to change the way that the just-in-time (JIT) compiler handles values when the default behavior is not appropriate. When the JIT compiler encounters a custom modifier, it handles the value in the way that the modifier specifies. Compilers can apply custom modifiers to methods, parameters, and return values. The JIT compiler must respond to required modifiers but can ignore optional modifiers. A C++ compiler could emit a custom modifier to describe how a byte should be treated in cases where the JIT compiler treats bytes in a manner that is not compatible with C++ by default. - - You can emit custom modifiers into metadata using one of the following techniques: - -- Using methods in the class such as , , , and . - -- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). - -- Using the unmanaged reflection API. - + are for compiler writers' use only. + + Compilers emit custom modifiers within metadata to change the way that the just-in-time (JIT) compiler handles values when the default behavior is not appropriate. When the JIT compiler encounters a custom modifier, it handles the value in the way that the modifier specifies. Compilers can apply custom modifiers to methods, parameters, and return values. The JIT compiler must respond to required modifiers but can ignore optional modifiers. A C++ compiler could emit a custom modifier to describe how a byte should be treated in cases where the JIT compiler treats bytes in a manner that is not compatible with C++ by default. + + You can emit custom modifiers into metadata using one of the following techniques: + +- Using methods in the class such as , , , and . + +- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). + +- Using the unmanaged reflection API. + ]]> @@ -123,11 +123,11 @@ Initializes a new instance of the class. - are for compiler writers' use only. - + are for compiler writers' use only. + ]]> diff --git a/xml/System.Runtime.CompilerServices/CallConvFastcall.xml b/xml/System.Runtime.CompilerServices/CallConvFastcall.xml index 917305da7ab..8cc4b418066 100644 --- a/xml/System.Runtime.CompilerServices/CallConvFastcall.xml +++ b/xml/System.Runtime.CompilerServices/CallConvFastcall.xml @@ -61,23 +61,23 @@ This calling convention is not supported in this version of .NET. - are for compiler writers' use only. - - Compilers emit custom modifiers within metadata to change the way that the just-in-time (JIT) compiler handles values when the default behavior is not appropriate. When the JIT compiler encounters a custom modifier, it handles the value in the way that the modifier specifies. Compilers can apply custom modifiers to methods, parameters, and return values. The JIT compiler must respond to required modifiers but can ignore optional modifiers. A C++ compiler could emit a custom modifier to describe how a byte should be treated in cases where the JIT compiler treats bytes in manner that is not compatible with C++ by default. - - You can emit custom modifiers into metadata using one of the following techniques: - -- Using methods in the class like , , , and . - -- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). - -- Using the unmanaged reflection API. - + are for compiler writers' use only. + + Compilers emit custom modifiers within metadata to change the way that the just-in-time (JIT) compiler handles values when the default behavior is not appropriate. When the JIT compiler encounters a custom modifier, it handles the value in the way that the modifier specifies. Compilers can apply custom modifiers to methods, parameters, and return values. The JIT compiler must respond to required modifiers but can ignore optional modifiers. A C++ compiler could emit a custom modifier to describe how a byte should be treated in cases where the JIT compiler treats bytes in manner that is not compatible with C++ by default. + + You can emit custom modifiers into metadata using one of the following techniques: + +- Using methods in the class like , , , and . + +- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). + +- Using the unmanaged reflection API. + ]]> @@ -121,11 +121,11 @@ Initializes a new instance of the class. - are for compiler writers' use only. - + are for compiler writers' use only. + ]]> diff --git a/xml/System.Runtime.CompilerServices/CallConvStdcall.xml b/xml/System.Runtime.CompilerServices/CallConvStdcall.xml index 6475f7e545c..f612c2d110c 100644 --- a/xml/System.Runtime.CompilerServices/CallConvStdcall.xml +++ b/xml/System.Runtime.CompilerServices/CallConvStdcall.xml @@ -61,23 +61,23 @@ Indicates that a method should use the calling convention. - are for compiler writers' use only. - - Compilers emit custom modifiers within metadata to change the way that the just-in-time (JIT) compiler handles values when the default behavior is not appropriate. When the JIT compiler encounters a custom modifier, it handles the value in the way that the modifier specifies. Compilers can apply custom modifiers to methods, parameters, and return values. The JIT compiler must respond to required modifiers but can ignore optional modifiers. A C++ compiler could emit a custom modifier to describe how a byte should be treated in cases where the JIT compiler treats bytes in a manner that is not compatible with C++ by default. - - You can emit custom modifiers into metadata using one of the following techniques: - -- Using methods in the class such as , , , and . - -- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). - -- Using the unmanaged reflection API. - + are for compiler writers' use only. + + Compilers emit custom modifiers within metadata to change the way that the just-in-time (JIT) compiler handles values when the default behavior is not appropriate. When the JIT compiler encounters a custom modifier, it handles the value in the way that the modifier specifies. Compilers can apply custom modifiers to methods, parameters, and return values. The JIT compiler must respond to required modifiers but can ignore optional modifiers. A C++ compiler could emit a custom modifier to describe how a byte should be treated in cases where the JIT compiler treats bytes in a manner that is not compatible with C++ by default. + + You can emit custom modifiers into metadata using one of the following techniques: + +- Using methods in the class such as , , , and . + +- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). + +- Using the unmanaged reflection API. + ]]> @@ -121,11 +121,11 @@ Initializes a new instance of the class. - are for compiler writers' use only. - + are for compiler writers' use only. + ]]> diff --git a/xml/System.Runtime.CompilerServices/CallConvThiscall.xml b/xml/System.Runtime.CompilerServices/CallConvThiscall.xml index 991a87f15df..be1457695fe 100644 --- a/xml/System.Runtime.CompilerServices/CallConvThiscall.xml +++ b/xml/System.Runtime.CompilerServices/CallConvThiscall.xml @@ -61,23 +61,23 @@ Indicates that a method should use the calling convention. - are for compiler writers' use only. - - Compilers emit custom modifiers within metadata to change the way that the just-in-time (JIT) compiler handles values when the default behavior is not appropriate. When the JIT compiler encounters a custom modifier, it handles the value in the way that the modifier specifies. Compilers can apply custom modifiers to methods, parameters, and return values. The JIT compiler must respond to required modifiers but can ignore optional modifiers. A C++ compiler could emit a custom modifier to describe how a byte should be treated in cases where the JIT compiler treats bytes in a manner that is not compatible with C++ by default. - - You can emit custom modifiers into metadata using one of the following techniques: - -- Using methods in the class such as , , , and . - -- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). - -- Using the unmanaged reflection API. - + are for compiler writers' use only. + + Compilers emit custom modifiers within metadata to change the way that the just-in-time (JIT) compiler handles values when the default behavior is not appropriate. When the JIT compiler encounters a custom modifier, it handles the value in the way that the modifier specifies. Compilers can apply custom modifiers to methods, parameters, and return values. The JIT compiler must respond to required modifiers but can ignore optional modifiers. A C++ compiler could emit a custom modifier to describe how a byte should be treated in cases where the JIT compiler treats bytes in a manner that is not compatible with C++ by default. + + You can emit custom modifiers into metadata using one of the following techniques: + +- Using methods in the class such as , , , and . + +- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). + +- Using the unmanaged reflection API. + ]]> @@ -121,11 +121,11 @@ Initializes a new instance of the class. - are for compiler writers' use only. - + are for compiler writers' use only. + ]]> diff --git a/xml/System.Runtime.CompilerServices/FixedAddressValueTypeAttribute.xml b/xml/System.Runtime.CompilerServices/FixedAddressValueTypeAttribute.xml index c401e5b05bb..c15855e9480 100644 --- a/xml/System.Runtime.CompilerServices/FixedAddressValueTypeAttribute.xml +++ b/xml/System.Runtime.CompilerServices/FixedAddressValueTypeAttribute.xml @@ -54,22 +54,20 @@ Fixes the address of a static value type field throughout its lifetime. This class cannot be inherited. - attribute to mark static value types as pinned upon creation. - - This attribute is used by the Microsoft Visual C++ compiler. - - Static value type fields are created as boxed objects. This means that their address can change as garbage collection is performed. When you apply this attribute to a static value type, its address remains constant during its lifetime. - - - -## Examples - The following example illustrates the use of the attribute to pin a static field in memory. It defines an `Age` structure and initializes two classes that have static fields of type `Age`. The second class applies to pin the field's address. A number of memory allocations are made before and after these two objects are instantiated and the garbage collector is invoked. The output from the example shows that although the address of the first `Age` field has changed after garbage collection, the address of the field to which is applied has not. - - :::code language="csharp" source="~/snippets/csharp/System.Runtime.CompilerServices/FixedAddressValueTypeAttribute/Overview/example1.cs" id="Snippet1"::: - + attribute to mark static value types as pinned upon creation. + + This attribute is used by the Microsoft Visual C++ compiler. + + Static value type fields are created as boxed objects. This means that their address can change as garbage collection is performed. When you apply this attribute to a static value type, its address remains constant during its lifetime. + +## Examples + The following example illustrates the use of the attribute to pin a static field in memory. It defines an `Age` structure and initializes two classes that have static fields of type `Age`. The second class applies to pin the field's address. A number of memory allocations are made before and after these two objects are instantiated and the garbage collector is invoked. The output from the example shows that although the address of the first `Age` field has changed after garbage collection, the address of the field to which is applied has not. + + :::code language="csharp" source="~/snippets/csharp/System.Runtime.CompilerServices/FixedAddressValueTypeAttribute/Overview/example1.cs" id="Snippet1"::: + ]]> @@ -108,13 +106,13 @@ Initializes a new instance of the class. - attribute to pin a static field in memory. It defines an `Age` structure and initializes two classes that have static fields of type `Age`. The second class applies to pin the field's address. A number of memory allocations are made before and after these two objects are instantiated and the garbage collector is invoked. The output from the example shows that although the address of the first `Age` field has changed after garbage collection, the address of the field to which is applied has not. - - :::code language="csharp" source="~/snippets/csharp/System.Runtime.CompilerServices/FixedAddressValueTypeAttribute/Overview/example1.cs" id="Snippet1"::: - + attribute to pin a static field in memory. It defines an `Age` structure and initializes two classes that have static fields of type `Age`. The second class applies to pin the field's address. A number of memory allocations are made before and after these two objects are instantiated and the garbage collector is invoked. The output from the example shows that although the address of the first `Age` field has changed after garbage collection, the address of the field to which is applied has not. + + :::code language="csharp" source="~/snippets/csharp/System.Runtime.CompilerServices/FixedAddressValueTypeAttribute/Overview/example1.cs" id="Snippet1"::: + ]]> diff --git a/xml/System.Runtime.CompilerServices/IsBoxed.xml b/xml/System.Runtime.CompilerServices/IsBoxed.xml index 1da1912aaf7..748480dd134 100644 --- a/xml/System.Runtime.CompilerServices/IsBoxed.xml +++ b/xml/System.Runtime.CompilerServices/IsBoxed.xml @@ -44,28 +44,26 @@ Indicates that the modified reference type is a boxed value type. This class cannot be inherited. - class such as , , , and . - -- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). - -- Using the unmanaged reflection API. - - - -## Examples - The following example demonstrates how to emit an object into an assembly using reflection. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Runtime.CompilerServices.IsBoxed/cpp/sample.cpp" id="Snippet1"::: - + class such as , , , and . + +- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). + +- Using the unmanaged reflection API. + +## Examples + The following example demonstrates how to emit an object into an assembly using reflection. + + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Runtime.CompilerServices.IsBoxed/cpp/sample.cpp" id="Snippet1"::: + ]]> diff --git a/xml/System.Runtime.CompilerServices/IsConst.xml b/xml/System.Runtime.CompilerServices/IsConst.xml index 5998ee7c6a8..88deafeb1a9 100644 --- a/xml/System.Runtime.CompilerServices/IsConst.xml +++ b/xml/System.Runtime.CompilerServices/IsConst.xml @@ -47,28 +47,26 @@ Indicates that the modified type has a modifier. This class cannot be inherited. - class such as , , , and . - -- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). - -- Using the unmanaged reflection API. - - - -## Examples - The following example demonstrates how to emit an object into an assembly using reflection. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Runtime.CompilerServices.IsConst/cpp/sample.cpp" id="Snippet1"::: - + class such as , , , and . + +- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). + +- Using the unmanaged reflection API. + +## Examples + The following example demonstrates how to emit an object into an assembly using reflection. + + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Runtime.CompilerServices.IsConst/cpp/sample.cpp" id="Snippet1"::: + ]]> diff --git a/xml/System.Runtime.CompilerServices/IsCopyConstructed.xml b/xml/System.Runtime.CompilerServices/IsCopyConstructed.xml index 17d74b56a69..91118c6ed7c 100644 --- a/xml/System.Runtime.CompilerServices/IsCopyConstructed.xml +++ b/xml/System.Runtime.CompilerServices/IsCopyConstructed.xml @@ -48,25 +48,25 @@ - Indicates that any copying of values of this type must use the copy constructor provided by the type. This class cannot be inherited. + Indicates that any copying of values of this type must use the copy constructor provided by the type. This class cannot be inherited. - class must implement a method named `MarshalCopy` that calls the native copy constructor. - - Any native C++ type that is emitted into metadata with copy constructors needs to have those methods called by the marshaler when copying values across the marshaling boundary. The Microsoft C++ compiler modifies all native C++ types in method parameters and return types that have this modifier to trigger this behavior in the marshaling code. - - Compilers emit custom modifiers within metadata to change the way that the just-in-time (JIT) compiler handles values when the default behavior is not appropriate. When the JIT compiler encounters a custom modifier, it handles the value in the way that the modifier specifies. Compilers can apply custom modifiers to methods, parameters, and return values. The JIT compiler must respond to required modifiers but can ignore optional modifiers. - - You can emit custom modifiers into metadata using one of the following techniques: - -- Using methods in the class such as , , , and . - -- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). - -- Using the unmanaged reflection API. - + class must implement a method named `MarshalCopy` that calls the native copy constructor. + + Any native C++ type that is emitted into metadata with copy constructors needs to have those methods called by the marshaler when copying values across the marshaling boundary. The Microsoft C++ compiler modifies all native C++ types in method parameters and return types that have this modifier to trigger this behavior in the marshaling code. + + Compilers emit custom modifiers within metadata to change the way that the just-in-time (JIT) compiler handles values when the default behavior is not appropriate. When the JIT compiler encounters a custom modifier, it handles the value in the way that the modifier specifies. Compilers can apply custom modifiers to methods, parameters, and return values. The JIT compiler must respond to required modifiers but can ignore optional modifiers. + + You can emit custom modifiers into metadata using one of the following techniques: + +- Using methods in the class such as , , , and . + +- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). + +- Using the unmanaged reflection API. + ]]> diff --git a/xml/System.Runtime.CompilerServices/IsExplicitlyDereferenced.xml b/xml/System.Runtime.CompilerServices/IsExplicitlyDereferenced.xml index 73682ed3e20..ca4a3d7da2c 100644 --- a/xml/System.Runtime.CompilerServices/IsExplicitlyDereferenced.xml +++ b/xml/System.Runtime.CompilerServices/IsExplicitlyDereferenced.xml @@ -44,28 +44,26 @@ Indicates that a managed pointer represents a pointer parameter within a method signature. This class cannot be inherited. - class and its partner, the class, disambiguate reference parameters from pointer parameters. - - Compilers emit custom modifiers within metadata to change the way that the just-in-time (JIT) compiler handles values when the default behavior is not appropriate. When the JIT compiler encounters a custom modifier, it handles the value in the way that the modifier specifies. Compilers can apply custom modifiers to methods, parameters, and return values. The JIT compiler must respond to required modifiers but can ignore optional modifiers. - - You can emit custom modifiers into metadata using one of the following techniques: - -- Using methods in the class such as , , , and . - -- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). - -- Using the unmanaged reflection API. - - - -## Examples - The following example demonstrates how to emit an object into an assembly using reflection. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Runtime.CompilerServices.IsExplicitlyDereferenced/cpp/sample.cpp" id="Snippet1"::: - + class and its partner, the class, disambiguate reference parameters from pointer parameters. + + Compilers emit custom modifiers within metadata to change the way that the just-in-time (JIT) compiler handles values when the default behavior is not appropriate. When the JIT compiler encounters a custom modifier, it handles the value in the way that the modifier specifies. Compilers can apply custom modifiers to methods, parameters, and return values. The JIT compiler must respond to required modifiers but can ignore optional modifiers. + + You can emit custom modifiers into metadata using one of the following techniques: + +- Using methods in the class such as , , , and . + +- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). + +- Using the unmanaged reflection API. + +## Examples + The following example demonstrates how to emit an object into an assembly using reflection. + + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Runtime.CompilerServices.IsExplicitlyDereferenced/cpp/sample.cpp" id="Snippet1"::: + ]]> diff --git a/xml/System.Runtime.CompilerServices/IsImplicitlyDereferenced.xml b/xml/System.Runtime.CompilerServices/IsImplicitlyDereferenced.xml index b395e5c90b8..e6326c5b363 100644 --- a/xml/System.Runtime.CompilerServices/IsImplicitlyDereferenced.xml +++ b/xml/System.Runtime.CompilerServices/IsImplicitlyDereferenced.xml @@ -44,28 +44,26 @@ Indicates that the modified garbage collection reference represents a reference parameter within a method signature. This class cannot be inherited. - modifier to distinguish reference classes that are passed by managed reference from those passed by managed pointer. The class and its partner, the class, disambiguate reference parameters from pointer parameters. - - Compilers emit custom modifiers within metadata to change the way that the just-in-time (JIT) compiler handles values when the default behavior is not appropriate. When the JIT compiler encounters a custom modifier, it handles the value in the way that the modifier specifies. Compilers can apply custom modifiers to methods, parameters, and return values. The JIT compiler must respond to required modifiers but can ignore optional modifiers. - - You can emit custom modifiers into metadata using one of the following techniques: - -- Using methods in the class such as , , , and . - -- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). - -- Using the unmanaged reflection API. - - - -## Examples - The following example demonstrates how to emit an object into an assembly using reflection. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Runtime.CompilerServices.IsImplicitlyDereferenced/cpp/sample.cpp" id="Snippet1"::: - + modifier to distinguish reference classes that are passed by managed reference from those passed by managed pointer. The class and its partner, the class, disambiguate reference parameters from pointer parameters. + + Compilers emit custom modifiers within metadata to change the way that the just-in-time (JIT) compiler handles values when the default behavior is not appropriate. When the JIT compiler encounters a custom modifier, it handles the value in the way that the modifier specifies. Compilers can apply custom modifiers to methods, parameters, and return values. The JIT compiler must respond to required modifiers but can ignore optional modifiers. + + You can emit custom modifiers into metadata using one of the following techniques: + +- Using methods in the class such as , , , and . + +- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). + +- Using the unmanaged reflection API. + +## Examples + The following example demonstrates how to emit an object into an assembly using reflection. + + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Runtime.CompilerServices.IsImplicitlyDereferenced/cpp/sample.cpp" id="Snippet1"::: + ]]> diff --git a/xml/System.Runtime.CompilerServices/IsLong.xml b/xml/System.Runtime.CompilerServices/IsLong.xml index ec8d6d6667e..f100eb35143 100644 --- a/xml/System.Runtime.CompilerServices/IsLong.xml +++ b/xml/System.Runtime.CompilerServices/IsLong.xml @@ -44,28 +44,26 @@ Indicates that a modified integer is a standard C++ value. This class cannot be inherited. - modifier to any instance of a `long` when the instance is emited. This process is critically important for maintaining language-level type safety. - - Compilers emit custom modifiers within metadata to change the way that the just-in-time (JIT) compiler handles values when the default behavior is not appropriate. When the JIT compiler encounters a custom modifier, it handles the value in the way that the modifier specifies. Compilers can apply custom modifiers to methods, parameters, and return values. The JIT compiler must respond to required modifiers but can ignore optional modifiers. - - You can emit custom modifiers into metadata using one of the following techniques: - -- Using methods in the class such as , , , and . - -- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). - -- Using the unmanaged reflection API. - - - -## Examples - The following example demonstrates how to emit an object into an assembly using reflection. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Runtime.CompilerServices.IsLong/cpp/sample.cpp" id="Snippet1"::: - + modifier to any instance of a `long` when the instance is emited. This process is critically important for maintaining language-level type safety. + + Compilers emit custom modifiers within metadata to change the way that the just-in-time (JIT) compiler handles values when the default behavior is not appropriate. When the JIT compiler encounters a custom modifier, it handles the value in the way that the modifier specifies. Compilers can apply custom modifiers to methods, parameters, and return values. The JIT compiler must respond to required modifiers but can ignore optional modifiers. + + You can emit custom modifiers into metadata using one of the following techniques: + +- Using methods in the class such as , , , and . + +- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). + +- Using the unmanaged reflection API. + +## Examples + The following example demonstrates how to emit an object into an assembly using reflection. + + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Runtime.CompilerServices.IsLong/cpp/sample.cpp" id="Snippet1"::: + ]]> diff --git a/xml/System.Runtime.CompilerServices/IsPinned.xml b/xml/System.Runtime.CompilerServices/IsPinned.xml index 27b1e0aae04..ff354891bcf 100644 --- a/xml/System.Runtime.CompilerServices/IsPinned.xml +++ b/xml/System.Runtime.CompilerServices/IsPinned.xml @@ -43,26 +43,24 @@ Indicates that a modified instance is pinned in memory. This class cannot be inherited. - class such as , , , and . - -- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). - -- Using the unmanaged reflection API. - - - -## Examples - The following example demonstrates how to emit an object into an assembly using reflection. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Runtime.CompilerServices.IsPinned/cpp/sample.cpp" id="Snippet1"::: - + class such as , , , and . + +- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). + +- Using the unmanaged reflection API. + +## Examples + The following example demonstrates how to emit an object into an assembly using reflection. + + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Runtime.CompilerServices.IsPinned/cpp/sample.cpp" id="Snippet1"::: + ]]> diff --git a/xml/System.Runtime.CompilerServices/IsSignUnspecifiedByte.xml b/xml/System.Runtime.CompilerServices/IsSignUnspecifiedByte.xml index f0c114d5ba6..4c05f0c8c79 100644 --- a/xml/System.Runtime.CompilerServices/IsSignUnspecifiedByte.xml +++ b/xml/System.Runtime.CompilerServices/IsSignUnspecifiedByte.xml @@ -44,28 +44,28 @@ Indicates that a modifier is neither signed nor unsigned. This class cannot be inherited. - modifier to each `char` type emitted to an assembly. - - Compilers emit custom modifiers within metadata to change the way that the just-in-time (JIT) compiler handles values when the default behavior is not appropriate. When the JIT compiler encounters a custom modifier, it handles the value in the way that the modifier specifies. Compilers can apply custom modifiers to methods, parameters, and return values. The JIT compiler must respond to required modifiers but can ignore optional modifiers. - - You can emit custom modifiers into metadata using one of the following techniques: - -- Using methods in the class such as , , , and . - -- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). - -- Using the unmanaged reflection API. - - - -## Examples - The following code example creates an assembly using classes in the namespace and emits the modifier into that assembly. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Runtime.CompilerServices.IsSignUnspecifiedByte/cpp/sample.cpp" id="Snippet1"::: - + modifier to each `char` type emitted to an assembly. + + Compilers emit custom modifiers within metadata to change the way that the just-in-time (JIT) compiler handles values when the default behavior is not appropriate. When the JIT compiler encounters a custom modifier, it handles the value in the way that the modifier specifies. Compilers can apply custom modifiers to methods, parameters, and return values. The JIT compiler must respond to required modifiers but can ignore optional modifiers. + + You can emit custom modifiers into metadata using one of the following techniques: + +- Using methods in the class such as , , , and . + +- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). + +- Using the unmanaged reflection API. + + + +## Examples + The following code example creates an assembly using classes in the namespace and emits the modifier into that assembly. + + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Runtime.CompilerServices.IsSignUnspecifiedByte/cpp/sample.cpp" id="Snippet1"::: + ]]> diff --git a/xml/System.Runtime.CompilerServices/IsUdtReturn.xml b/xml/System.Runtime.CompilerServices/IsUdtReturn.xml index 913a7aec61a..9d685f127a9 100644 --- a/xml/System.Runtime.CompilerServices/IsUdtReturn.xml +++ b/xml/System.Runtime.CompilerServices/IsUdtReturn.xml @@ -44,28 +44,26 @@ Indicates that a return type is a user-defined type. This class cannot be inherited. - modifier is used by the C++ compiler to mark return types of methods that have native C++ object return semantics. The managed debugger recognizes this modifier to correctly determine that the native calling convention is in use. - - Compilers emit custom modifiers within metadata to change the way that the just-in-time (JIT) compiler handles values when the default behavior is not appropriate. When the JIT compiler encounters a custom modifier, it handles the value in the way that the modifier specifies. Compilers can apply custom modifiers to methods, parameters, and return values. The JIT compiler must respond to required modifiers but can ignore optional modifiers. - - You can emit custom modifiers into metadata using one of the following techniques: - -- Using methods in the class such as , , , and . - -- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). - -- Using the unmanaged reflection API. - - - -## Examples - The following code example creates an assembly using classes in the namespace and emits the modifier into that assembly. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Runtime.CompilerServices.IsUdtReturn/CPP/sample.cpp" id="Snippet1"::: - + modifier is used by the C++ compiler to mark return types of methods that have native C++ object return semantics. The managed debugger recognizes this modifier to correctly determine that the native calling convention is in use. + + Compilers emit custom modifiers within metadata to change the way that the just-in-time (JIT) compiler handles values when the default behavior is not appropriate. When the JIT compiler encounters a custom modifier, it handles the value in the way that the modifier specifies. Compilers can apply custom modifiers to methods, parameters, and return values. The JIT compiler must respond to required modifiers but can ignore optional modifiers. + + You can emit custom modifiers into metadata using one of the following techniques: + +- Using methods in the class such as , , , and . + +- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). + +- Using the unmanaged reflection API. + +## Examples + The following code example creates an assembly using classes in the namespace and emits the modifier into that assembly. + + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Runtime.CompilerServices.IsUdtReturn/CPP/sample.cpp" id="Snippet1"::: + ]]> diff --git a/xml/System.Runtime.CompilerServices/IsVolatile.xml b/xml/System.Runtime.CompilerServices/IsVolatile.xml index 091c43389dc..0af9f18f233 100644 --- a/xml/System.Runtime.CompilerServices/IsVolatile.xml +++ b/xml/System.Runtime.CompilerServices/IsVolatile.xml @@ -60,23 +60,23 @@ Marks a field as volatile. This class cannot be inherited. - are for compiler writers' use only. - - Compilers emit custom modifiers within metadata to change the way that the just-in-time (JIT) compiler handles values when the default behavior is not appropriate. When the JIT compiler encounters a custom modifier, it handles the value in the way that the modifier specifies. Compilers can apply custom modifiers to methods, parameters, and return values. The JIT compiler must respond to required modifiers but can ignore optional modifiers. A C++ compiler could emit a custom modifier to describe how a byte should be treated in cases where the JIT compiler treats bytes in a manner that is not compatible with C++ by default. - - You can emit custom modifiers into metadata using one of the following techniques: - -- Using methods in the class such as , , , and . - -- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). - -- Using the unmanaged reflection API. - + are for compiler writers' use only. + + Compilers emit custom modifiers within metadata to change the way that the just-in-time (JIT) compiler handles values when the default behavior is not appropriate. When the JIT compiler encounters a custom modifier, it handles the value in the way that the modifier specifies. Compilers can apply custom modifiers to methods, parameters, and return values. The JIT compiler must respond to required modifiers but can ignore optional modifiers. A C++ compiler could emit a custom modifier to describe how a byte should be treated in cases where the JIT compiler treats bytes in a manner that is not compatible with C++ by default. + + You can emit custom modifiers into metadata using one of the following techniques: + +- Using methods in the class such as , , , and . + +- Generating a Microsoft intermediate language (MSIL) instruction file that contains calls to `modopt` and `modreq`, and assembling the file with the [Ilasm.exe (IL Assembler)](/dotnet/framework/tools/ilasm-exe-il-assembler). + +- Using the unmanaged reflection API. + ]]> diff --git a/xml/System.Runtime.CompilerServices/NativeCppClassAttribute.xml b/xml/System.Runtime.CompilerServices/NativeCppClassAttribute.xml index a62ffd6db1e..f80faff9497 100644 --- a/xml/System.Runtime.CompilerServices/NativeCppClassAttribute.xml +++ b/xml/System.Runtime.CompilerServices/NativeCppClassAttribute.xml @@ -57,13 +57,13 @@ - Applies metadata to an assembly that indicates that a type is an unmanaged type. This class cannot be inherited. + Applies metadata to an assembly that indicates that a type is an unmanaged type. This class cannot be inherited. - attribute when building assemblies to indicate that a type is an unmanaged type defined in C or C++. This attribute is used later to correctly handle the unmanaged type when it is imported during interop. - + attribute when building assemblies to indicate that a type is an unmanaged type defined in C or C++. This attribute is used later to correctly handle the unmanaged type when it is imported during interop. + ]]> @@ -103,11 +103,11 @@ Initializes a new instance of the class. - attribute when building assemblies to indicate that a type is an unmanaged type defined in C or C++. This attribute is used later to correctly handle the unmanaged type when it is imported during interop. - + attribute when building assemblies to indicate that a type is an unmanaged type defined in C or C++. This attribute is used later to correctly handle the unmanaged type when it is imported during interop. + ]]> diff --git a/xml/System.Runtime.CompilerServices/RequiredAttributeAttribute.xml b/xml/System.Runtime.CompilerServices/RequiredAttributeAttribute.xml index 1ba5640dba7..b84c86ccc69 100644 --- a/xml/System.Runtime.CompilerServices/RequiredAttributeAttribute.xml +++ b/xml/System.Runtime.CompilerServices/RequiredAttributeAttribute.xml @@ -66,17 +66,17 @@ - Specifies that an importing compiler must fully understand the semantics of a type definition, or refuse to use it. This class cannot be inherited. + Specifies that an importing compiler must fully understand the semantics of a type definition, or refuse to use it. This class cannot be inherited. - are for compiler writers use only. - + are for compiler writers use only. + ]]> @@ -118,8 +118,8 @@ - A type that an importing compiler must fully understand. - + A type that an importing compiler must fully understand. + This parameter is not supported in the .NET Framework version 2.0 and later. Initializes a new instance of the class. To be added. @@ -165,11 +165,11 @@ Gets a type that an importing compiler must fully understand. A type that an importing compiler must fully understand. - diff --git a/xml/System.Runtime.CompilerServices/RuntimeCompatibilityAttribute.xml b/xml/System.Runtime.CompilerServices/RuntimeCompatibilityAttribute.xml index 7ed9e331683..f9a3624838d 100644 --- a/xml/System.Runtime.CompilerServices/RuntimeCompatibilityAttribute.xml +++ b/xml/System.Runtime.CompilerServices/RuntimeCompatibilityAttribute.xml @@ -60,22 +60,20 @@ Specifies whether to wrap exceptions that do not derive from the class with a object. This class cannot be inherited. - class. To maintain compatibility between languages, the common language runtime (CLR) wraps objects that do not derive from in a object. - - You can use the class to specify whether exceptions should appear wrapped inside catch blocks and exception filters for an assembly. Many language compilers, including the Microsoft C# and Visual Basic compilers, apply this attribute by default to specify the wrapping behavior. - - Note that the runtime still wraps exceptions even if you use the class to specify that you do not want them wrapped. In this case, exceptions are unwrapped only inside catch blocks or exception filters. - - - -## Examples - The following code example demonstrates how to apply the class to an assembly that throws a object as an exception in C++ and catches it using a object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Runtime.CompilerServices.RuntimeWrappedException/cpp/sample.cpp" id="Snippet1"::: - + class. To maintain compatibility between languages, the common language runtime (CLR) wraps objects that do not derive from in a object. + + You can use the class to specify whether exceptions should appear wrapped inside catch blocks and exception filters for an assembly. Many language compilers, including the Microsoft C# and Visual Basic compilers, apply this attribute by default to specify the wrapping behavior. + + Note that the runtime still wraps exceptions even if you use the class to specify that you do not want them wrapped. In this case, exceptions are unwrapped only inside catch blocks or exception filters. + +## Examples + The following code example demonstrates how to apply the class to an assembly that throws a object as an exception in C++ and catches it using a object. + + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Runtime.CompilerServices.RuntimeWrappedException/cpp/sample.cpp" id="Snippet1"::: + ]]> @@ -118,13 +116,13 @@ Initializes a new instance of the class. - attribute to an assembly to disable exception wrapping. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Runtime.CompilerServices.RuntimeCompatibilityAttribute/cpp/sample.cpp" id="Snippet1"::: - + attribute to an assembly to disable exception wrapping. + + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Runtime.CompilerServices.RuntimeCompatibilityAttribute/cpp/sample.cpp" id="Snippet1"::: + ]]> @@ -172,13 +170,13 @@ if exceptions that do not derive from the class should appear wrapped with a object; otherwise, . - attribute to an assembly to disable exception wrapping. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Runtime.CompilerServices.RuntimeCompatibilityAttribute/cpp/sample.cpp" id="Snippet1"::: - + attribute to an assembly to disable exception wrapping. + + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Runtime.CompilerServices.RuntimeCompatibilityAttribute/cpp/sample.cpp" id="Snippet1"::: + ]]> diff --git a/xml/System.Runtime.CompilerServices/RuntimeWrappedException.xml b/xml/System.Runtime.CompilerServices/RuntimeWrappedException.xml index 7910bb1e035..91d332bbc09 100644 --- a/xml/System.Runtime.CompilerServices/RuntimeWrappedException.xml +++ b/xml/System.Runtime.CompilerServices/RuntimeWrappedException.xml @@ -54,22 +54,20 @@ Wraps an exception that does not derive from the class. This class cannot be inherited. - class. To maintain compatibility between languages, the common language runtime (CLR) wraps objects that do not derive from in a object. - - You can use the class to specify whether exceptions should appear wrapped inside catch blocks and exception filters for an assembly. Many language compilers, including the Microsoft C# and Visual Basic compilers, apply this attribute by default to specify the wrapping behavior. - - Note that the runtime still wraps exceptions even if you use the class to specify that you do not want them wrapped. In this case, exceptions are unwrapped only inside catch blocks or exception filters. - - - -## Examples - The following code example demonstrates how to throw a object as an exception in C++ and catch it using a object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Runtime.CompilerServices.RuntimeWrappedException/cpp/sample.cpp" id="Snippet1"::: - + class. To maintain compatibility between languages, the common language runtime (CLR) wraps objects that do not derive from in a object. + + You can use the class to specify whether exceptions should appear wrapped inside catch blocks and exception filters for an assembly. Many language compilers, including the Microsoft C# and Visual Basic compilers, apply this attribute by default to specify the wrapping behavior. + + Note that the runtime still wraps exceptions even if you use the class to specify that you do not want them wrapped. In this case, exceptions are unwrapped only inside catch blocks or exception filters. + +## Examples + The following code example demonstrates how to throw a object as an exception in C++ and catch it using a object. + + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Runtime.CompilerServices.RuntimeWrappedException/cpp/sample.cpp" id="Snippet1"::: + ]]> @@ -163,11 +161,11 @@ The object that contains contextual information about the source or destination. Sets the object with information about the exception. - method sets a object with all the exception object data targeted for serialization. During deserialization, the exception is reconstituted from the `SerializationInfo` transmitted over the stream. - + method sets a object with all the exception object data targeted for serialization. During deserialization, the exception is reconstituted from the `SerializationInfo` transmitted over the stream. + ]]> The parameter is . @@ -211,11 +209,11 @@ Gets the object that was wrapped by the object. The object that was wrapped by the object. - property gets an object that was thrown as an exception from a language that allows exceptions that do not derive from the class. - + property gets an object that was thrown as an exception from a language that allows exceptions that do not derive from the class. + ]]> diff --git a/xml/System.Runtime.CompilerServices/ScopelessEnumAttribute.xml b/xml/System.Runtime.CompilerServices/ScopelessEnumAttribute.xml index c9e13b14843..607354afb3f 100644 --- a/xml/System.Runtime.CompilerServices/ScopelessEnumAttribute.xml +++ b/xml/System.Runtime.CompilerServices/ScopelessEnumAttribute.xml @@ -54,11 +54,11 @@ Indicates that a native enumeration is not qualified by the enumeration type name. This class cannot be inherited. - attribute to native enumeration types to indicate that they do not need to be qualified by the enumeration type name when referenced in C++ programs. This attribute distinguishes native enumeration types from managed enumeration types. - + attribute to native enumeration types to indicate that they do not need to be qualified by the enumeration type name when referenced in C++ programs. This attribute distinguishes native enumeration types from managed enumeration types. + ]]> diff --git a/xml/System.Runtime.CompilerServices/UnsafeValueTypeAttribute.xml b/xml/System.Runtime.CompilerServices/UnsafeValueTypeAttribute.xml index cb50ff09071..7d379c3fb25 100644 --- a/xml/System.Runtime.CompilerServices/UnsafeValueTypeAttribute.xml +++ b/xml/System.Runtime.CompilerServices/UnsafeValueTypeAttribute.xml @@ -60,13 +60,13 @@ Specifies that a type contains an unmanaged array that might potentially overflow. This class cannot be inherited. - class to instruct the common language runtime (CLR) that a type contains an unmanaged array that can potentially overflow. When this attribute is encountered, the CLR inserts runtime checks to prevent the array from overflowing and to prevent buffer overrun attacks. - - This class is used by the Microsoft Visual C++ and the Microsoft Visual C# compilers. - + class to instruct the common language runtime (CLR) that a type contains an unmanaged array that can potentially overflow. When this attribute is encountered, the CLR inserts runtime checks to prevent the array from overflowing and to prevent buffer overrun attacks. + + This class is used by the Microsoft Visual C++ and the Microsoft Visual C# compilers. + ]]> diff --git a/xml/System.Runtime.InteropServices.WindowsRuntime/ReadOnlyArrayAttribute.xml b/xml/System.Runtime.InteropServices.WindowsRuntime/ReadOnlyArrayAttribute.xml index f614d5f9a97..65ce8dd9e67 100644 --- a/xml/System.Runtime.InteropServices.WindowsRuntime/ReadOnlyArrayAttribute.xml +++ b/xml/System.Runtime.InteropServices.WindowsRuntime/ReadOnlyArrayAttribute.xml @@ -44,9 +44,9 @@ Applying both attributes to a parameter causes an error. For more information, including the standard pattern for making changes to an array, see [Passing arrays to a Windows Runtime component](https://go.microsoft.com/fwlink/?LinkId=251026) in the Windows Dev Center. > [!IMPORTANT] -> Parameters that have the attribute behave differently depending on whether the caller is written in native code or managed code. If the caller is native code (JavaScript or Visual C++ component extensions), the array is copied when the call crosses the application binary interface (ABI) boundary. Elements are converted if necessary. Therefore, any accidental changes the method makes to an input-only array are not visible to the caller. +> Parameters that have the attribute behave differently depending on whether the caller is written in native code or managed code. If the caller is native code (JavaScript or Visual C++ component extensions), the array is copied when the call crosses the application binary interface (ABI) boundary. Elements are converted if necessary. Therefore, any accidental changes the method makes to an input-only array are not visible to the caller. > -> If the caller is managed code, the array is not copied. The original array is available to the called method, as it would be in any method call in the .NET Framework. Array contents are mutable in .NET Framework code, so any changes the method makes to the array are visible to the caller. This is important to remember because it affects unit tests written for a Windows Runtime component. If the tests are written in managed code, the contents of an array will appear to be mutable during testing. +> If the caller is managed code, the array is not copied. The original array is available to the called method, as it would be in any method call in the .NET Framework. Array contents are mutable in .NET Framework code, so any changes the method makes to the array are visible to the caller. This is important to remember because it affects unit tests written for a Windows Runtime component. If the tests are written in managed code, the contents of an array will appear to be mutable during testing. Applying this attribute to a parameter that has the or attribute causes an error when the module is exported. Applying the attribute to an `out` parameter also causes an error. diff --git a/xml/System.Runtime.InteropServices.WindowsRuntime/WriteOnlyArrayAttribute.xml b/xml/System.Runtime.InteropServices.WindowsRuntime/WriteOnlyArrayAttribute.xml index c4f8d1eec25..ea3fc071fdb 100644 --- a/xml/System.Runtime.InteropServices.WindowsRuntime/WriteOnlyArrayAttribute.xml +++ b/xml/System.Runtime.InteropServices.WindowsRuntime/WriteOnlyArrayAttribute.xml @@ -44,9 +44,9 @@ Applying both attributes to a parameter causes an error. For more information, including the standard pattern for making changes to an array, see [Passing arrays to a Windows Runtime component](https://go.microsoft.com/fwlink/?LinkId=251026) in the Windows Dev Center. > [!IMPORTANT] -> Parameters that have the attribute behave differently depending on whether the caller is written in native code or managed code. If the caller is native code (JavaScript or Visual C++ component extensions), the called method can't make any assumptions about the contents of the original array. For example, the array the method receives might not be initialized, or might contain default values. The method is expected to set the values of all the elements in the array. +> Parameters that have the attribute behave differently depending on whether the caller is written in native code or managed code. If the caller is native code (JavaScript or Visual C++ component extensions), the called method can't make any assumptions about the contents of the original array. For example, the array the method receives might not be initialized, or might contain default values. The method is expected to set the values of all the elements in the array. > -> If the caller is managed code, the caller's original array is passed to the called method, as it would be in any method call in the .NET Framework. Array contents are mutable in managed code, so the method can selectively read and change those values. This is important to remember because it affects unit tests written for a Windows Runtime component. If the tests are written in managed code, the contents of an array will appear to be mutable during testing, and the results are likely to be different if the method is called from native code later. +> If the caller is managed code, the caller's original array is passed to the called method, as it would be in any method call in the .NET Framework. Array contents are mutable in managed code, so the method can selectively read and change those values. This is important to remember because it affects unit tests written for a Windows Runtime component. If the tests are written in managed code, the contents of an array will appear to be mutable during testing, and the results are likely to be different if the method is called from native code later. Applying this attribute to an `out` parameter or to a parameter that has the attribute causes an error when the module is exported. Applying the attribute to a parameter that has the attribute causes an error unless the parameter also has the Visual Basic `ByRef` modifier. In that case, the attribute is redundant but allowed. diff --git a/xml/System.Runtime.InteropServices/DefaultCharSetAttribute.xml b/xml/System.Runtime.InteropServices/DefaultCharSetAttribute.xml index 18a41354620..e90bdfacc50 100644 --- a/xml/System.Runtime.InteropServices/DefaultCharSetAttribute.xml +++ b/xml/System.Runtime.InteropServices/DefaultCharSetAttribute.xml @@ -60,27 +60,25 @@ Specifies the value of the enumeration. This class cannot be inherited. - attribute at the assembly level or module level to set the value for any call to that does not include a named argument specified by the user. - - A named argument specified by the user overrides the setting of . - + attribute at the assembly level or module level to set the value for any call to that does not include a named argument specified by the user. + + A named argument specified by the user overrides the setting of . + > [!NOTE] -> Only the C# and Visual Basic compilers recognize this attribute; it is not used by the C++ compiler. - - - -## Examples - The following code example changes the default value from to . - - `using System.Runtime.InteropServices;` - - `[module: DefaultCharSet(CharSet.Auto)]` - - `// …` - +> Only the C# and Visual Basic compilers recognize this attribute; it is not used by the C++ compiler. + +## Examples + The following code example changes the default value from to . + + `using System.Runtime.InteropServices;` + + `[module: DefaultCharSet(CharSet.Auto)]` + + `// …` + ]]> diff --git a/xml/System.Runtime.InteropServices/DllImportAttribute.xml b/xml/System.Runtime.InteropServices/DllImportAttribute.xml index a487b3c3886..00120e19732 100644 --- a/xml/System.Runtime.InteropServices/DllImportAttribute.xml +++ b/xml/System.Runtime.InteropServices/DllImportAttribute.xml @@ -65,30 +65,29 @@ Indicates that the attributed method is exposed by an unmanaged dynamic-link library (DLL) as a static entry point. - attribute provides the information needed to call a function exported from an unmanaged DLL. As a minimum requirement, you must supply the name of the DLL containing the entry point. - - You apply this attribute directly to C# and C++ method definitions; however, the Visual Basic compiler emits this attribute when you use the `Declare` statement. For complex method definitions that include , , , , , or fields, you apply this attribute directly to Visual Basic method definitions. - - **Note** JScript does not support this attribute. You can use C# or Visual Basic wrapper classes to access unmanaged API methods from JScript programs. - - For additional information about using the platform invoke service to access functions in unmanaged DLLs, see [Consuming Unmanaged DLL Functions](/dotnet/framework/interop/consuming-unmanaged-dll-functions). - + attribute provides the information needed to call a function exported from an unmanaged DLL. As a minimum requirement, you must supply the name of the DLL containing the entry point. + + You apply this attribute directly to C# method definitions; however, the Visual Basic compiler emits this attribute when you use the `Declare` statement. For complex method definitions that include , , , , , or fields, you apply this attribute directly to Visual Basic method definitions. + > [!NOTE] -> The does not support marshaling of generic types. - - - -## Examples - The following code example shows how to use the attribute to import the Win32 `MessageBox` function. The code example then calls the imported method. - +> JScript does not support this attribute. You can use C# or Visual Basic wrapper classes to access unmanaged API methods from JScript programs. + +For additional information about using the platform invoke service to access functions in unmanaged DLLs, see [Consuming Unmanaged DLL Functions](/dotnet/framework/interop/consuming-unmanaged-dll-functions). + +> [!NOTE] +> The does not support marshaling of generic types. + +## Examples + The following code example shows how to use the attribute to import the Win32 `MessageBox` function. The code example then calls the imported method. + :::code language="csharp" source="~/snippets/csharp/System.Runtime.InteropServices/DllImportAttribute/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Runtime.InteropServices.DllImport.Canonical/vb/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Runtime.InteropServices.DllImport.Canonical/vb/sample.vb" id="Snippet1"::: + ]]> @@ -141,23 +140,23 @@ The name of the DLL that contains the unmanaged method. In .NET Framework, this can include an assembly display name, if the DLL is included in an assembly. Initializes a new instance of the class with the name of the DLL containing the method to import. - attribute to import the Win32 `MessageBox` function. The code example then calls the imported method. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.runtime.interopservices.dllimportattribute/vb/source.vb" id="Snippet2"::: + + + +## Examples + The following code example shows how to use the attribute to import the Win32 `MessageBox` function. The code example then calls the imported method. + :::code language="csharp" source="~/snippets/csharp/System.Runtime.InteropServices/DllImportAttribute/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Runtime.InteropServices.DllImport.Canonical/vb/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Runtime.InteropServices.DllImport.Canonical/vb/sample.vb" id="Snippet1"::: + ]]> @@ -205,26 +204,26 @@ Enables or disables best-fit mapping behavior when converting Unicode characters to ANSI characters. - field is `true` by default. Settings for this field override the any level settings for the attribute. - + > [!CAUTION] -> Certain Unicode characters are converted to dangerous characters, such as the backslash '\\' character, which can inadvertently change a path. By setting the field to `true`, you can signal the presence of an unmappable character to the caller by throwing an exception. - +> Certain Unicode characters are converted to dangerous characters, such as the backslash '\\' character, which can inadvertently change a path. By setting the field to `true`, you can signal the presence of an unmappable character to the caller by throwing an exception. + > [!CAUTION] -> You cannot change the default values provided by the and fields when passing a managed array whose elements are ANSI Chars or LPSTRs to an unmanaged safe array. Best-fit mapping is always enabled and no exception is thrown. Be aware that this combination can compromise your security model. - - - -## Examples - In some cases, Visual Basic developers use the , instead of the `Declare` statement, to define a DLL function in managed code. Setting the field is one of those cases. The following example shows how to apply the strictest character mapping security to a platform invoke method definitions by specifying the ANSI character set, disabling best fit mapping behavior, and throwing an exception on unmapped Unicode characters. - +> You cannot change the default values provided by the and fields when passing a managed array whose elements are ANSI Chars or LPSTRs to an unmanaged safe array. Best-fit mapping is always enabled and no exception is thrown. Be aware that this combination can compromise your security model. + + + +## Examples + In some cases, Visual Basic developers use the , instead of the `Declare` statement, to define a DLL function in managed code. Setting the field is one of those cases. The following example shows how to apply the strictest character mapping security to a platform invoke method definitions by specifying the ANSI character set, disabling best fit mapping behavior, and throwing an exception on unmapped Unicode characters. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.runtime.interopservices.dllimportattribute/cpp/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Runtime.InteropServices/DllImportAttribute/.ctor/source.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.runtime.interopservices.dllimportattribute/vb/source.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.runtime.interopservices.dllimportattribute/vb/source.vb" id="Snippet3"::: + ]]> @@ -275,20 +274,20 @@ Indicates the calling convention of an entry point. - enumeration members. The default value for the field is , which in turn defaults to convention on Windows, and on all other platforms. - - - -## Examples - In some cases, Visual Basic developers use the , instead of the `Declare` statement, to define a DLL function in managed code. Setting the field is one of those cases. - + + + +## Examples + In some cases, Visual Basic developers use the , instead of the `Declare` statement, to define a DLL function in managed code. Setting the field is one of those cases. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.runtime.interopservices.dllimportattribute/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Runtime.InteropServices/DllImportAttribute/.ctor/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.runtime.interopservices.dllimportattribute/vb/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.runtime.interopservices.dllimportattribute/vb/source.vb" id="Snippet1"::: + ]]> @@ -337,21 +336,19 @@ Indicates how to marshal string parameters to the method and controls name mangling. - enumeration to specify the marshaling behavior of string parameters and to specify which entry-point name to invoke (the exact name given or a name ending with "A" or "W"). The default enumeration member for C# and Visual Basic is `CharSet.Ansi` and the default enumeration member for C++ is `CharSet.None`, which is equivalent to `CharSet.Ansi`. In Visual Basic, you use the `Declare` statement to specify the `CharSet` field. - - The field influences the behavior of the `CharSet` field in determining which entry-point name to invoke. For a detailed description and examples of the string marshaling and name matching behavior associated with the `CharSet` field, see [Specifying a Character Set](/dotnet/framework/interop/specifying-a-character-set). - - - -## Examples - The following code example shows how to use the attribute to import the Win32 `MessageBox` function. The code example then calls the imported method. - + enumeration to specify the marshaling behavior of string parameters and to specify which entry-point name to invoke (the exact name given or a name ending with "A" or "W"). The default enumeration member for C# and Visual Basic is `CharSet.Ansi` and the default enumeration member for C++ is `CharSet.None`, which is equivalent to `CharSet.Ansi`. In Visual Basic, you use the `Declare` statement to specify the `CharSet` field. + + The field influences the behavior of the `CharSet` field in determining which entry-point name to invoke. For a detailed description and examples of the string marshaling and name matching behavior associated with the `CharSet` field, see [Specifying a Character Set](/dotnet/framework/interop/specifying-a-character-set). + +## Examples + The following code example shows how to use the attribute to import the Win32 `MessageBox` function. The code example then calls the imported method. + :::code language="csharp" source="~/snippets/csharp/System.Runtime.InteropServices/DllImportAttribute/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Runtime.InteropServices.DllImport.Canonical/vb/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Runtime.InteropServices.DllImport.Canonical/vb/sample.vb" id="Snippet1"::: + ]]> @@ -407,21 +404,21 @@ Indicates the name or ordinal of the DLL entry point to be called. - . - - For additional information, see [Identifying Functions in DLLs](/dotnet/framework/interop/identifying-functions-in-dlls). For examples showing how to use the field, see [Specifying an Entry Point](/dotnet/framework/interop/specifying-an-entry-point). - - - -## Examples - The following code example shows how to use the attribute to import the Win32 `MessageBox` function. The code example uses the property to specify the function to import and then changes the name to `MyNewMessageBoxMethod`. - + . + + For additional information, see [Identifying Functions in DLLs](/dotnet/framework/interop/identifying-functions-in-dlls). For examples showing how to use the field, see [Specifying an Entry Point](/dotnet/framework/interop/specifying-an-entry-point). + + + +## Examples + The following code example shows how to use the attribute to import the Win32 `MessageBox` function. The code example uses the property to specify the function to import and then changes the name to `MyNewMessageBoxMethod`. + :::code language="csharp" source="~/snippets/csharp/System.Runtime.InteropServices/DllImportAttribute/EntryPoint/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Runtime.InteropServices.DllImport.EntryPoint/vb/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Runtime.InteropServices.DllImport.EntryPoint/vb/sample.vb" id="Snippet1"::: + ]]> @@ -470,28 +467,28 @@ Controls whether the field causes the common language runtime to search an unmanaged DLL for entry-point names other than the one specified. - field is set to `CharSet.Ansi`, and the entry-point name appended with the letter W is invoked when the field is set to the `CharSet.Unicode`. Typically, managed compilers set this field. - - The following table shows the relationship between the and fields, based on default values imposed by the programming language. You can override the default setting, but do so with caution. - -|Language|ANSI|Unicode|Auto| -|--------------|----------|-------------|----------| -|Visual Basic|ExactSpelling:=True|ExactSpelling:=True|ExactSpelling:=False| -|C#|ExactSpelling=false|ExactSpelling=false|ExactSpelling=false| -|C++|ExactSpelling=false|ExactSpelling=false|ExactSpelling=false| - - - -## Examples - In some cases, Visual Basic developers use the , instead of using the `Declare` statement, to define a DLL function in managed code. Setting the field is one of those cases. - + field is set to `CharSet.Ansi`, and the entry-point name appended with the letter W is invoked when the field is set to the `CharSet.Unicode`. Typically, managed compilers set this field. + + The following table shows the relationship between the and fields, based on default values imposed by the programming language. You can override the default setting, but do so with caution. + +|Language|ANSI|Unicode|Auto| +|--------------|----------|-------------|----------| +|Visual Basic|ExactSpelling:=True|ExactSpelling:=True|ExactSpelling:=False| +|C#|ExactSpelling=false|ExactSpelling=false|ExactSpelling=false| +|C++|ExactSpelling=false|ExactSpelling=false|ExactSpelling=false| + + + +## Examples + In some cases, Visual Basic developers use the , instead of using the `Declare` statement, to define a DLL function in managed code. Setting the field is one of those cases. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.runtime.interopservices.dllimportattribute/cpp/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Runtime.InteropServices/DllImportAttribute/.ctor/source.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.runtime.interopservices.dllimportattribute/vb/source.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.runtime.interopservices.dllimportattribute/vb/source.vb" id="Snippet4"::: + ]]> @@ -539,29 +536,29 @@ Indicates whether unmanaged methods that have return values are directly translated or whether return values are automatically converted to exceptions. - field to `true` to translate unmanaged signatures with `HRESULT` values directly; set it to `false` to automatically convert `HRESULT` return values to exceptions. By default, the field is `true`. - - When `true`, the managed method signature returns an integer value that contains the `HRESULT` value. In this case, you must manually inspect the return value and respond accordingly in your application. - + field to `true` to translate unmanaged signatures with `HRESULT` values directly; set it to `false` to automatically convert `HRESULT` return values to exceptions. By default, the field is `true`. + + When `true`, the managed method signature returns an integer value that contains the `HRESULT` value. In this case, you must manually inspect the return value and respond accordingly in your application. + When you set the field to `false`, the managed method signature has a void return type or the type of the last unmanaged [out, retval] parameter. When the unmanaged method produces an `HRESULT`, the runtime automatically ignores a return value of `S_OK` (or 0) and does not throw an exception. For `HRESULT`s other than `S_OK`, the runtime automatically throws an exception that corresponds to the `HRESULT`. - - You might decide to change the default error reporting behavior from `HRESULT`s to exceptions in cases where exceptions better fit the error reporting structure of your application. - - This field is similar to the ; however, in contrast to the field, the default value for the attribute is `false`. - - In some cases, Visual Basic developers use the , instead of using the `Declare` statement, to define a DLL function in managed code. Setting the field is one of those cases. - - - -## Examples - The following code example uses the to import the unmanaged `SHAutoComplete` function once with the field set to `true` and again with the field set to `false`. This code example causes the `SHAutoComplete` function to generate any errors with an exception one time and an `HRESULT` the next. - + + You might decide to change the default error reporting behavior from `HRESULT`s to exceptions in cases where exceptions better fit the error reporting structure of your application. + + This field is similar to the ; however, in contrast to the field, the default value for the attribute is `false`. + + In some cases, Visual Basic developers use the , instead of using the `Declare` statement, to define a DLL function in managed code. Setting the field is one of those cases. + + + +## Examples + The following code example uses the to import the unmanaged `SHAutoComplete` function once with the field set to `true` and again with the field set to `false`. This code example causes the `SHAutoComplete` function to generate any errors with an exception one time and an `HRESULT` the next. + :::code language="csharp" source="~/snippets/csharp/System.Runtime.InteropServices/DllImportAttribute/PreserveSig/example.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Runtime.InteropServices.PreserveSigAttribute/vb/example.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Runtime.InteropServices.PreserveSigAttribute/vb/example.vb" id="Snippet1"::: + ]]> @@ -610,27 +607,27 @@ Indicates whether the callee sets an error ( on Windows or on other platforms) before returning from the attributed method. - on .NET 6.0 and above or on .NET 5 and below or .NET Framework. - + On .NET, the error information is cleared (set to `0`) before invoking the callee when this field is set to `true`. On .NET Framework, the error information is not cleared. This means that error information returned by and on .NET represents only the error information from the last p/invoke with set to `true`. On .NET Framework, the error information can persist from one p/invoke to the next. - -## Examples - In some cases, Visual Basic developers use the , instead of using the `Declare` statement, to define a DLL function in managed code. Setting the field is one of those cases. - + +## Examples + In some cases, Visual Basic developers use the , instead of using the `Declare` statement, to define a DLL function in managed code. Setting the field is one of those cases. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.runtime.interopservices.dllimportattribute/cpp/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Runtime.InteropServices/DllImportAttribute/.ctor/source.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.runtime.interopservices.dllimportattribute/vb/source.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.runtime.interopservices.dllimportattribute/vb/source.vb" id="Snippet5"::: + ]]> @@ -680,26 +677,26 @@ Enables or disables the throwing of an exception on an unmappable Unicode character that is converted to an ANSI "?" character. - field is disabled. This field is `false` by default. - + > [!CAUTION] -> Certain Unicode characters are converted to dangerous characters, such as the backslash '\\' character, which can inadvertently change a path. By setting the field to `true`, you can signal the presence of an unmappable character to the caller by throwing an exception. - +> Certain Unicode characters are converted to dangerous characters, such as the backslash '\\' character, which can inadvertently change a path. By setting the field to `true`, you can signal the presence of an unmappable character to the caller by throwing an exception. + > [!CAUTION] -> You cannot change the default values provided by the and fields when passing a managed array whose elements are ANSI Chars or LPSTRs to an unmanaged safe array. Best-fit mapping is always enabled and no exception is thrown. Be aware that this combination can compromise your security model. - - - -## Examples - In some cases, Visual Basic developers use the to define a DLL function in managed code, instead of using the `Declare` statement. Setting the field is one of those cases. The following example shows how to apply the strictest character mapping security to a platform invoke method definitions by specifying the ANSI character set, disabling best fit mapping behavior, and throwing an exception on unmapped Unicode characters. - +> You cannot change the default values provided by the and fields when passing a managed array whose elements are ANSI Chars or LPSTRs to an unmanaged safe array. Best-fit mapping is always enabled and no exception is thrown. Be aware that this combination can compromise your security model. + + + +## Examples + In some cases, Visual Basic developers use the to define a DLL function in managed code, instead of using the `Declare` statement. Setting the field is one of those cases. The following example shows how to apply the strictest character mapping security to a platform invoke method definitions by specifying the ANSI character set, disabling best fit mapping behavior, and throwing an exception on unmapped Unicode characters. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.runtime.interopservices.dllimportattribute/cpp/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Runtime.InteropServices/DllImportAttribute/.ctor/source.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.runtime.interopservices.dllimportattribute/vb/source.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.runtime.interopservices.dllimportattribute/vb/source.vb" id="Snippet3"::: + ]]> @@ -751,11 +748,11 @@ Gets the name of the DLL file that contains the entry point. The name of the DLL file that contains the entry point. - diff --git a/xml/System.Runtime.InteropServices/LayoutKind.xml b/xml/System.Runtime.InteropServices/LayoutKind.xml index 977cf8be126..411ff825f76 100644 --- a/xml/System.Runtime.InteropServices/LayoutKind.xml +++ b/xml/System.Runtime.InteropServices/LayoutKind.xml @@ -60,23 +60,23 @@ Controls the layout of an object when exported to unmanaged code. - . The common language runtime uses the `Auto` layout value by default. To reduce layout-related problems associated with the `Auto` value, C#, Visual Basic, and C++ compilers specify `Sequential` layout for value types. - + . The common language runtime uses the `Auto` layout value by default. To reduce layout-related problems associated with the `Auto` value, C#, Visual Basic, and C++ compilers specify `Sequential` layout for value types. + > [!IMPORTANT] -> The field controls the alignment of data fields, and thus affects the layout regardless of the value you specify. By default, the value of is 0, which indicates the default packing size for the current platform. For example, when you use the `Explicit` layout value and specify field alignments on byte boundaries, you must set to 1 to get the desired result. - - - -## Examples - The following example shows the managed declaration of the `PtInRect` function, which checks whether a point lies within a rectangle, and defines a `Point` structure with Sequential layout and a `Rect` structure with Explicit layout. - +> The field controls the alignment of data fields, and thus affects the layout regardless of the value you specify. By default, the value of is 0, which indicates the default packing size for the current platform. For example, when you use the `Explicit` layout value and specify field alignments on byte boundaries, you must set to 1 to get the desired result. + + + +## Examples + The following example shows the managed declaration of the `PtInRect` function, which checks whether a point lies within a rectangle, and defines a `Point` structure with Sequential layout and a `Rect` structure with Explicit layout. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/LayoutKind/CPP/layoutkind.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Runtime.InteropServices/LayoutKind/Overview/layoutkind.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/LayoutKind/VB/layoutkind.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/LayoutKind/VB/layoutkind.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Runtime.InteropServices/Marshal.xml b/xml/System.Runtime.InteropServices/Marshal.xml index 0b202c48b83..549fa4ef240 100644 --- a/xml/System.Runtime.InteropServices/Marshal.xml +++ b/xml/System.Runtime.InteropServices/Marshal.xml @@ -3475,17 +3475,15 @@ The code retrieves a reference to an instance of Microsoft Word successfully. Ho and methods to marshal delegates in both directions. With , `ptr` is imported as a . A can be obtained for a managed delegate by calling and passed as a parameter; it can then be called from inside the unmanaged method. Note that the parameter marshaler can also marshal function pointers to delegates in the .NET Framework 2.0 and later versions. + You can use the and methods to marshal delegates in both directions. With , `ptr` is imported as a . A can be obtained for a managed delegate by calling and passed as a parameter; it can then be called from inside the unmanaged method. Note that the parameter marshaler can also marshal function pointers to delegates. `ptr` is converted to a delegate that invokes the unmanaged method using [the default platform calling convention](/dotnet/standard/native-interop/calling-conventions#platform-default-calling-convention). You can set the calling convention by applying the to the delegate. The method has the following restrictions: -- Generics are not supported in interop scenarios. - -- You can use this method only for pure unmanaged function pointers. - -- You cannot use this method with function pointers obtained through C++. +- Generics are not supported in interop scenarios. +- You can use this method only for pure unmanaged function pointers. +- You cannot use this method with function pointers obtained through C++. ]]> @@ -3570,11 +3568,9 @@ The code retrieves a reference to an instance of Microsoft Word successfully. Ho The method has the following restrictions: -- Generics are not supported in interop scenarios. - -- You can use this method only for pure unmanaged function pointers. - -- You cannot use this method with function pointers obtained through C++. +- Generics are not supported in interop scenarios. +- You can use this method only for pure unmanaged function pointers. +- You cannot use this method with function pointers obtained through C++. ]]> @@ -4258,8 +4254,6 @@ The code retrieves a reference to an instance of Microsoft Word successfully. Ho ## Remarks The target function must have had the `setLastError` metadata flag set. For example, the `SetLastError` field of the must be `true`. The process for setting this flag depends on the source language used: C# and C++ are `false` by default, but the `Declare` statement in Visual Basic is `true`. - - ## Examples The following example demonstrates how to retrieve an HRESULT corresponding to a Win32 error code using the method. @@ -5142,9 +5136,9 @@ On .NET 6 and later versions, this method is functionally equivalent to method. @@ -6931,13 +6925,13 @@ On .NET 6 and later versions, this method is functionally equivalent to on a method outside of platform invoke has no effect. To execute setup tasks on all platform invoke methods in a type, use . diff --git a/xml/System.Runtime.InteropServices/MarshalAsAttribute.xml b/xml/System.Runtime.InteropServices/MarshalAsAttribute.xml index 75f75cb77f1..948dcc7732f 100644 --- a/xml/System.Runtime.InteropServices/MarshalAsAttribute.xml +++ b/xml/System.Runtime.InteropServices/MarshalAsAttribute.xml @@ -65,40 +65,40 @@ Indicates how to marshal the data between managed and unmanaged code. - , a , a , or a . By default, the common language runtime marshals a string parameter as a to COM methods. You can apply the attribute to an individual field or parameter to cause that particular string to be marshaled as a instead of a . The [Tlbexp.exe (Type Library Exporter)](/dotnet/framework/tools/tlbexp-exe-type-library-exporter) passes your marshaling preferences to the common language runtime. - - Some parameters and return values have different default marshaling behavior when used with COM interop or platform invoke. By default, the runtime marshals a string parameter (and fields in a value type) as a to a platform invoke method or function. For additional information, see [Default Marshaling Behavior](/dotnet/framework/interop/default-marshaling-behavior). - - In most cases, the attribute simply identifies the format of the unmanaged data using the enumeration, as shown in the following C# signature: - + , a , a , or a . By default, the common language runtime marshals a string parameter as a to COM methods. You can apply the attribute to an individual field or parameter to cause that particular string to be marshaled as a instead of a . The [Tlbexp.exe (Type Library Exporter)](/dotnet/framework/tools/tlbexp-exe-type-library-exporter) passes your marshaling preferences to the common language runtime. + + Some parameters and return values have different default marshaling behavior when used with COM interop or platform invoke. By default, the runtime marshals a string parameter (and fields in a value type) as a to a platform invoke method or function. For additional information, see [Default Marshaling Behavior](/dotnet/framework/interop/default-marshaling-behavior). + + In most cases, the attribute simply identifies the format of the unmanaged data using the enumeration, as shown in the following C# signature: + :::code language="csharp" source="~/snippets/csharp/System.Runtime.InteropServices/MarshalAsAttribute/Overview/Signature1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.runtime.interopservices.MarshalAsAttribute/vb/Signature1.vb" id="Snippet2"::: - - Some enumeration members require additional information. For example, additional information is needed when the is . For a complete description of how to use this attribute with arrays, see [Default Marshaling for Arrays](/dotnet/framework/interop/default-marshaling-for-arrays). - - The [Tlbimp.exe (Type Library Importer)](/dotnet/framework/tools/tlbimp-exe-type-library-importer) also applies this attribute to parameters, fields, and return values to indicate that the data type in the input type library is not the default type for the corresponding managed data type. Tlbimp.exe always applies the to and types for clarity, regardless of the type specified in the input type library. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.runtime.interopservices.MarshalAsAttribute/vb/Signature1.vb" id="Snippet2"::: + + Some enumeration members require additional information. For example, additional information is needed when the is . For a complete description of how to use this attribute with arrays, see [Default Marshaling for Arrays](/dotnet/framework/interop/default-marshaling-for-arrays). + + The [Tlbimp.exe (Type Library Importer)](/dotnet/framework/tools/tlbimp-exe-type-library-importer) also applies this attribute to parameters, fields, and return values to indicate that the data type in the input type library is not the default type for the corresponding managed data type. Tlbimp.exe always applies the to and types for clarity, regardless of the type specified in the input type library. + > [!NOTE] -> The does not support marshaling of generic types. - - - -## Examples - The following example applies the to a field, a method parameter, and a method return value in a managed type. - +> The does not support marshaling of generic types. + + + +## Examples + The following example applies the to a field, a method parameter, and a method return value in a managed type. + :::code language="csharp" source="~/snippets/csharp/System.Runtime.InteropServices/MarshalAsAttribute/Overview/marshalasattribute.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.runtime.interopservices.MarshalAsAttribute/vb/marshalasattribute.vb" id="Snippet1"::: - - The following example applies the attribute to a property: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.runtime.interopservices.MarshalAsAttribute/vb/marshalasattribute.vb" id="Snippet1"::: + + The following example applies the attribute to a property: + :::code language="csharp" source="~/snippets/csharp/System.Runtime.InteropServices/MarshalAsAttribute/Overview/Signature1.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.runtime.interopservices.MarshalAsAttribute/vb/Signature1.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.runtime.interopservices.MarshalAsAttribute/vb/Signature1.vb" id="Snippet3"::: + ]]> @@ -164,11 +164,11 @@ The value the data is to be marshaled as. Initializes a new instance of the class with the specified value. - enumeration member. The [Tlbimp.exe (Type Library Importer)](/dotnet/framework/tools/tlbimp-exe-type-library-importer) uses this constructor. - + enumeration member. The [Tlbimp.exe (Type Library Importer)](/dotnet/framework/tools/tlbimp-exe-type-library-importer) uses this constructor. + ]]> @@ -219,11 +219,11 @@ The value the data is to be marshaled as. Initializes a new instance of the class with the specified enumeration member. - @@ -272,11 +272,11 @@ Specifies the element type of the unmanaged or . - enumeration to specify the type of the array's elements. If a type is not specified, the default unmanaged type corresponding to the managed array's element type is used. For example, the `ArraySubType` for a `LPWStr` array in COM is . For additional information, see [Default Marshaling for Arrays](/dotnet/framework/interop/default-marshaling-for-arrays). - + enumeration to specify the type of the array's elements. If a type is not specified, the default unmanaged type corresponding to the managed array's element type is used. For example, the `ArraySubType` for a `LPWStr` array in COM is . For additional information, see [Default Marshaling for Arrays](/dotnet/framework/interop/default-marshaling-for-arrays). + ]]> @@ -370,13 +370,13 @@ Provides additional information to a custom marshaler. - @@ -431,11 +431,11 @@ Specifies the fully qualified name of a custom marshaler. - or field specify a custom marshaler type for the attributed parameter, field, or return type. The field enables you to specify a string representing the fully qualified name of a custom marshaler. It is useful for late-bound references, but is less preferred than for specifying a custom marshaler. For additional information about creating and using custom marshalers, see [Custom Marshaling](https://msdn.microsoft.com/library/49f9ac47-1619-4d6e-9da6-bf06bba12079). - + or field specify a custom marshaler type for the attributed parameter, field, or return type. The field enables you to specify a string representing the fully qualified name of a custom marshaler. It is useful for late-bound references, but is less preferred than for specifying a custom marshaler. For additional information about creating and using custom marshalers, see [Custom Marshaling](https://msdn.microsoft.com/library/49f9ac47-1619-4d6e-9da6-bf06bba12079). + ]]> @@ -491,21 +491,21 @@ Implements as a type. - or field to specify a custom marshaler type for the attributed parameter, field, or return type. The field allows easier usage of by shortening the syntax. In the following example, the first line represents syntax using and the second line represents syntax using . - -``` -[MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Assembly, NameSpace.TypeName")] -``` - -``` -[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(NameSpace.TypeName))] -``` - - You can set a object using `typeof` in C#, `GetType` in Visual Basic, or `typeid` in C++. For additional information about creating and using custom marshalers, see [Custom Marshaling](https://msdn.microsoft.com/library/49f9ac47-1619-4d6e-9da6-bf06bba12079). - + or field to specify a custom marshaler type for the attributed parameter, field, or return type. The field allows easier usage of by shortening the syntax. In the following example, the first line represents syntax using and the second line represents syntax using . + +``` +[MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "Assembly, NameSpace.TypeName")] +``` + +``` +[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(NameSpace.TypeName))] +``` + + You can set a object using `typeof` in C#, `GetType` in Visual Basic, or `typeid` in C++. For additional information about creating and using custom marshalers, see [Custom Marshaling](/previous-versions/dotnet/netframework-4.0/w22x2hw6(v=vs.100)). + ]]> @@ -554,11 +554,11 @@ Indicates the element type of the . - enumeration to specify the type of the safe array's elements. If a type is not specified, the managed element type's default type (if passed as a VARIANT) is used. For example, the `SafeArraySubType` for an `int` array in COM is . For additional information, see [Default Marshaling for Arrays](/dotnet/framework/interop/default-marshaling-for-arrays). - + enumeration to specify the type of the safe array's elements. If a type is not specified, the managed element type's default type (if passed as a VARIANT) is used. For example, the `SafeArraySubType` for an `int` array in COM is . For additional information, see [Default Marshaling for Arrays](/dotnet/framework/interop/default-marshaling-for-arrays). + ]]> @@ -609,11 +609,11 @@ Indicates the user-defined element type of the . - is either , , or . For additional information, see [Default Marshaling for Arrays](/dotnet/framework/interop/default-marshaling-for-arrays). - + is either , , or . For additional information, see [Default Marshaling for Arrays](/dotnet/framework/interop/default-marshaling-for-arrays). + ]]> @@ -663,13 +663,13 @@ Indicates the number of elements in the fixed-length array or the number of characters (not bytes) in a string to import. - and members of the enumeration. Because the compressed format of the metadata is limited to 0x1FFFFFFF, the range of allowed values for are (>= 0 and <= 0x1FFFFFFF). - - For additional information, see [Default Marshaling for Arrays](/dotnet/framework/interop/default-marshaling-for-arrays). - + and members of the enumeration. Because the compressed format of the metadata is limited to 0x1FFFFFFF, the range of allowed values for are (>= 0 and <= 0x1FFFFFFF). + + For additional information, see [Default Marshaling for Arrays](/dotnet/framework/interop/default-marshaling-for-arrays). + ]]> @@ -718,32 +718,32 @@ Indicates the zero-based parameter that contains the count of array elements, similar to in COM. - field supports managed-to-unmanaged and unmanaged-to-managed calls. It does not have any effect on managed code that calls COM objects. - - Depending on the managed type and the attributes applied to it, the array can be passed as a safe array or C-style array. - - When arrays are passed as C-style arrays, the marshaler cannot determine the size of the array. Therefore, to pass an managed array to an unmanaged function or method, you must provide two arguments: - -- The array, defined by reference or value. - -- The array size, defined by reference or value. - - The zero-based index of the array size parameter is defined by using the field. - - If you specify both and with a field, the sum of the fields' values produces a size total. - - For more information, see [Default Marshaling for Arrays](/dotnet/framework/interop/default-marshaling-for-arrays). - - - -## Examples + field supports managed-to-unmanaged and unmanaged-to-managed calls. It does not have any effect on managed code that calls COM objects. + + Depending on the managed type and the attributes applied to it, the array can be passed as a safe array or C-style array. + + When arrays are passed as C-style arrays, the marshaler cannot determine the size of the array. Therefore, to pass an managed array to an unmanaged function or method, you must provide two arguments: + +- The array, defined by reference or value. + +- The array size, defined by reference or value. + + The zero-based index of the array size parameter is defined by using the field. + + If you specify both and with a field, the sum of the fields' values produces a size total. + + For more information, see [Default Marshaling for Arrays](/dotnet/framework/interop/default-marshaling-for-arrays). + + + +## Examples :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Runtime.InteropServices.MarshalAsAttribute.SizeParamIndex/CPP/marshalas.sizeparamindex.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Runtime.InteropServices/MarshalAsAttribute/SizeParamIndex/marshalas.sizeparamindex.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Runtime.InteropServices.MarshalAsAttribute.SizeParamIndex/VB/marshalas.sizeparamindex.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Runtime.InteropServices.MarshalAsAttribute.SizeParamIndex/VB/marshalas.sizeparamindex.vb" id="Snippet1"::: + ]]> @@ -794,11 +794,11 @@ Gets the value the data is to be marshaled as. The value the data is to be marshaled as. - to indicate how types should be marshaled between managed and unmanaged code. In some cases, you can use this field with certain `UnmanagedType` enumeration members. For and , you must use additional named parameters. - + to indicate how types should be marshaled between managed and unmanaged code. In some cases, you can use this field with certain `UnmanagedType` enumeration members. For and , you must use additional named parameters. + ]]> diff --git a/xml/System.Security.Cryptography/CryptographicOperations.xml b/xml/System.Security.Cryptography/CryptographicOperations.xml index aad06fc657c..a976ec218c7 100644 --- a/xml/System.Security.Cryptography/CryptographicOperations.xml +++ b/xml/System.Security.Cryptography/CryptographicOperations.xml @@ -1180,7 +1180,7 @@ Fixed-time behavior is guaranteed in all other cases, including when `left` and ## Remarks This method exists to future-proof against potential optimizations in the .NET runtime that could eliminate memory writes that aren't followed by memory reads. -While the C and C++ compilers have similar optimizations, no such optimizations are planned at this time for .NET. +While the C and C++ compilers have similar optimizations, no such optimizations are planned for .NET. ]]> diff --git a/xml/System.ServiceModel.Channels/Message.xml b/xml/System.ServiceModel.Channels/Message.xml index 12b95689329..0a0cca6eef0 100644 --- a/xml/System.ServiceModel.Channels/Message.xml +++ b/xml/System.ServiceModel.Channels/Message.xml @@ -72,15 +72,10 @@ Special note for Managed C++ users deriving from this class: -- Put your cleanup code in (On)(Begin)Close (and/or OnAbort), not in a destructor. - -- Avoid destructors: they cause the compiler to auto-generate . - -- Avoid non-reference members: they can cause the compiler to auto-generate . - -- Avoid finalizers; but if you include one, suppress the build warning and call and the finalizer itself from (On)(Begin)Close (and/or OnAbort) to emulate what would have been the auto-generated behavior. - - +- Put your cleanup code in (On)(Begin)Close (and/or OnAbort), not in a destructor. +- Avoid destructors: they cause the compiler to auto-generate . +- Avoid non-reference members: they can cause the compiler to auto-generate . +- Avoid finalizers; but if you include one, suppress the build warning and call and the finalizer itself from (On)(Begin)Close (and/or OnAbort) to emulate what would have been the auto-generated behavior. ## Examples The following code example shows a client that uses the channel factory to send a message and read the reply. diff --git a/xml/System.ServiceModel.Channels/MessageBuffer.xml b/xml/System.ServiceModel.Channels/MessageBuffer.xml index ef38638992d..44318d4a818 100644 --- a/xml/System.ServiceModel.Channels/MessageBuffer.xml +++ b/xml/System.ServiceModel.Channels/MessageBuffer.xml @@ -57,29 +57,26 @@ Represents a memory buffer that stores an entire message for future consumption. - instance can only be consumed or written once. If you wish to consume a instance more than once, you should use the class to completely store an entire instance into memory. - - A instance is constructed by calling of a instance. A new is then created and returned, which assumes ownership of the and reads the entire content into memory. - - In order to retrieve a copy of a from the , you must call the method of the . This returns an identical copy of the original instance you provided. - - You can control the maximum size of the buffer by setting to the maximum number of bytes desired. This number does not necessarily cover any transient allocations related to building the buffer, or properties attached to the message. - - You should always close a instance by calling when finished working with it. This allows system resources to potentially be freed sooner. - - Special note for Managed C++ users deriving from this class: - -- Put your cleanup code in (On)(Begin)Close (and/or OnAbort), not in a destructor. - -- Avoid destructors: they cause the compiler to auto-generate - -- Avoid non-reference members: they can cause the compiler to auto-generate - -- Avoid finalizers; but if you include one, you should suppress the build warning and call and the finalizer itself from (On)(Begin)Close (and/or OnAbort) in order to emulate what would have been the auto-generated behavior. - + instance can only be consumed or written once. If you wish to consume a instance more than once, you should use the class to completely store an entire instance into memory. + + A instance is constructed by calling of a instance. A new is then created and returned, which assumes ownership of the and reads the entire content into memory. + + In order to retrieve a copy of a from the , you must call the method of the . This returns an identical copy of the original instance you provided. + + You can control the maximum size of the buffer by setting to the maximum number of bytes desired. This number does not necessarily cover any transient allocations related to building the buffer, or properties attached to the message. + + You should always close a instance by calling when finished working with it. This allows system resources to potentially be freed sooner. + + Special note for Managed C++ users deriving from this class: + +- Put your cleanup code in (On)(Begin)Close (and/or OnAbort), not in a destructor. +- Avoid destructors: they cause the compiler to auto-generate . +- Avoid non-reference members: they can cause the compiler to auto-generate . +- Avoid finalizers; but if you include one, you should suppress the build warning and call and the finalizer itself from (On)(Begin)Close (and/or OnAbort) in order to emulate what would have been the auto-generated behavior. + ]]> @@ -152,11 +149,11 @@ Gets the approximate number of bytes consumed by this . The approximate number of bytes consumed by this . - to the maximum number of bytes desired. This number does not necessarily cover any transient allocations related to building the buffer, or properties attached to the message. It is not related to the actual size of the message when serialized. - + to the maximum number of bytes desired. This number does not necessarily cover any transient allocations related to building the buffer, or properties attached to the message. It is not related to the actual size of the message when serialized. + ]]> @@ -193,38 +190,38 @@ Finishes working with the buffer. - instance by calling when finished working with it. This allows system resources to potentially be freed sooner. - - If you have called to create a message buffer of a message, and inspected the message using , you will get a when you attempt to close the buffer using this method. To avoid this problem, you need to recreate the message from the buffer before closing. See the code sample in the Example section for a demonstration of the previous scenario and a way to resolve this problem. - - - -## Examples - The following example demonstrates how to properly close a message buffer. - + instance by calling when finished working with it. This allows system resources to potentially be freed sooner. + + If you have called to create a message buffer of a message, and inspected the message using , you will get a when you attempt to close the buffer using this method. To avoid this problem, you need to recreate the message from the buffer before closing. See the code sample in the Example section for a demonstration of the previous scenario and a way to resolve this problem. + + + +## Examples + The following example demonstrates how to properly close a message buffer. + ```csharp -public void AfterReceiveReply(ref Message reply, object correlationState) -{ +public void AfterReceiveReply(ref Message reply, object correlationState) +{ // Create the buffer. - MessageBuffer buffer = reply.CreateBufferedCopy(13000); + MessageBuffer buffer = reply.CreateBufferedCopy(13000); // Inspect the response (for example, extract the body contents). Message thisReply = buffer.CreateMessage(); XmlDictionaryReader reader = thisReply.GetReaderAtBodyContents(); var info = new StringBuilder(); - XmlWriter writer = XmlWriter.Create(info); - writer.WriteNode(reader, true); - writer.Close(); - // Resolution: Re-create the message from the buffer before - // closing. - reply = buffer.CreateMessage(); - // You can close the buffer after the message has been recreated. + XmlWriter writer = XmlWriter.Create(info); + writer.WriteNode(reader, true); + writer.Close(); + // Resolution: Re-create the message from the buffer before + // closing. + reply = buffer.CreateMessage(); + // You can close the buffer after the message has been recreated. buffer.Close(); } -``` - +``` + ]]> @@ -262,11 +259,11 @@ public void AfterReceiveReply(ref Message reply, object correlationState) Returns a copy of the original message. An identical copy of the original instance you previously provided to the method of a instance. - instance you previously provided to the method of a instance. You can then save the message to a durable storage. - + instance you previously provided to the method of a instance. You can then save the message to a durable storage. + ]]> @@ -279,11 +276,11 @@ public void AfterReceiveReply(ref Message reply, object correlationState) Creates a new object for navigating this object. - @@ -321,11 +318,11 @@ public void AfterReceiveReply(ref Message reply, object correlationState) Creates a new object for navigating this object. This method cannot be inherited. An object for navigating this object. - @@ -363,11 +360,11 @@ public void AfterReceiveReply(ref Message reply, object correlationState) Creates a new object for navigating this object, with the navigator positioned on the node specified. An object for navigating this object. - @@ -405,11 +402,11 @@ public void AfterReceiveReply(ref Message reply, object correlationState) Creates a new object for navigating this object, with the specified scope. An object for navigating this object. - @@ -443,11 +440,11 @@ public void AfterReceiveReply(ref Message reply, object correlationState) Creates a new object for navigating this object, with the navigator positioned on the specified node and scope. An object for navigating this object. - @@ -527,14 +524,14 @@ public void AfterReceiveReply(ref Message reply, object correlationState) Releases the unmanaged resources used by the and optionally releases the managed resources. This method cannot be inherited. - . This method leaves the in an unusable state. After calling this method, you must release all references to the so the garbage collector can reclaim the memory that the was occupying. - + . This method leaves the in an unusable state. After calling this method, you must release all references to the so the garbage collector can reclaim the memory that the was occupying. + > [!NOTE] -> Always call this method before you release your last reference to the . Otherwise, the resources it is using are not freed until the garbage collector calls the object's `Finalize` method. - +> Always call this method before you release your last reference to the . Otherwise, the resources it is using are not freed until the garbage collector calls the object's `Finalize` method. + ]]> @@ -574,42 +571,42 @@ public void AfterReceiveReply(ref Message reply, object correlationState) An IO stream that the entire content of this buffer is written to. Writes the entire content of this buffer to the specified IO stream. - to a . The code in the example section shows how to work around this problem. - - - -## Examples - + to a . The code in the example section shows how to work around this problem. + + + +## Examples + ```csharp -private byte[] ConvertMessageToByteArray(ref Message message) -{ +private byte[] ConvertMessageToByteArray(ref Message message) +{ // Memory stream that contains the message. - var stream = new MemoryStream(); + var stream = new MemoryStream(); // Create an XmlWriter to serialize the message into a byte array. var settings = new XmlWriterSettings(); settings.Encoding = System.Text.Encoding.UTF8; XmlWriter writer = XmlWriter.Create(stream, settings); // Copy the message into a buffer. // Note: This call changes the original message's state. - MessageBuffer buffer = message.CreateBufferedCopy(int.MaxValue); + MessageBuffer buffer = message.CreateBufferedCopy(int.MaxValue); // Create a copy of the message. - message = buffer.CreateMessage(); + message = buffer.CreateMessage(); // Serialize the message to the XmlWriter. - message.WriteMessage(writer); + message.WriteMessage(writer); // Recreate the message. message = buffer.CreateMessage(); // Flush the contents of the writer so that the stream gets updated. - writer.Flush(); - stream.Flush(); + writer.Flush(); + stream.Flush(); // Convert the stream to an array. byte[] retval = stream.ToArray(); return retval; -} -``` - +} +``` + ]]> diff --git a/xml/System.ServiceModel.Channels/RequestContext.xml b/xml/System.ServiceModel.Channels/RequestContext.xml index e39ec7aa756..239fdc31389 100644 --- a/xml/System.ServiceModel.Channels/RequestContext.xml +++ b/xml/System.ServiceModel.Channels/RequestContext.xml @@ -49,25 +49,22 @@ Provides a reply that is correlated to an incoming request. - . Each encapsulates the information required to reply to the request, so that you do not have to block on the channel when waiting for each request message to receive a reply. - - In the request/reply model, the object is the link between the request that comes in and the reply that goes out. When the server receives a request, it provides a instance that represents the request to the channel. The request context contains the original request message among other useful properties. This request context is then stashed inside the for retrieval by your service. You typically use the property to access the request of the current operation. - - The value of the can be `null`. Because the role of the request context is to link requests to replies, it does not make sense to have a request context when you do not have a reply, and so in this case the context is set to `null`. For a one-way operation on top of the request/reply model, the server receives requests but does not send back a response to the client. So if the is `null` unexpectedly, check first whether the operation contract is IsOneWay. - - Special note for Managed C++ users deriving from this class: - -- Put your cleanup code in (On)(Begin)Close (and/or OnAbort), not in a destructor. - -- Avoid destructors: they cause the compiler to auto-generate . - -- Avoid non-reference members: they can cause the compiler to auto-generate . - -- Avoid finalizers; but if you include one, you should suppress the build warning and call and the finalizer itself from (On)(Begin)Close (and/or OnAbort) to emulate what would have been the auto-generated behavior. - + . Each encapsulates the information required to reply to the request, so that you do not have to block on the channel when waiting for each request message to receive a reply. + + In the request/reply model, the object is the link between the request that comes in and the reply that goes out. When the server receives a request, it provides a instance that represents the request to the channel. The request context contains the original request message among other useful properties. This request context is then stashed inside the for retrieval by your service. You typically use the property to access the request of the current operation. + + The value of the can be `null`. Because the role of the request context is to link requests to replies, it does not make sense to have a request context when you do not have a reply, and so in this case the context is set to `null`. For a one-way operation on top of the request/reply model, the server receives requests but does not send back a response to the client. So if the is `null` unexpectedly, check first whether the operation contract is IsOneWay. + + Special note for Managed C++ users deriving from this class: + +- Put your cleanup code in (On)(Begin)Close (and/or OnAbort), not in a destructor. +- Avoid destructors: they cause the compiler to auto-generate . +- Avoid non-reference members: they can cause the compiler to auto-generate . +- Avoid finalizers; but if you include one, you should suppress the build warning and call and the finalizer itself from (On)(Begin)Close (and/or OnAbort) to emulate what would have been the auto-generated behavior. + ]]> @@ -151,11 +148,11 @@ Begins an asynchronous operation to reply to the request associated with the current context. - @@ -200,13 +197,13 @@ When overridden in a derived class, begins an asynchronous operation to reply to the request associated with the current context. The that references the asynchronous reply operation. - method when the application processing must continue without waiting. Use one of the synchronous methods when it is acceptable for the current thread to be blocked while it replies to the request message or until the time-out interval is exceeded. - - This method receives notification, through a callback, of the identity of the event handler for the operation. The operation is not complete until either the reply is sent or the time-out occurs. - + method when the application processing must continue without waiting. Use one of the synchronous methods when it is acceptable for the current thread to be blocked while it replies to the request message or until the time-out interval is exceeded. + + This method receives notification, through a callback, of the identity of the event handler for the operation. The operation is not complete until either the reply is sent or the time-out occurs. + ]]> @@ -256,13 +253,13 @@ When overridden in a derived class, begins an asynchronous operation to reply to the request associated with the current context within a specified interval of time. The that references the asynchronous reply operation. - method to allow the application processing to continue without waiting for the request to complete. - - Use one of the synchronous methods when it is acceptable for the current thread to be blocked while it replies to the request message or until the time-out interval is exceeded. This method receives notification, through a callback, of the identity of the event handler for the operation. The operation is not complete until either the reply is sent or the time-out occurs. - + method to allow the application processing to continue without waiting for the request to complete. + + Use one of the synchronous methods when it is acceptable for the current thread to be blocked while it replies to the request message or until the time-out interval is exceeded. This method receives notification, through a callback, of the identity of the event handler for the operation. The operation is not complete until either the reply is sent or the time-out occurs. + ]]> @@ -474,13 +471,13 @@ The incoming that contains the request. When overridden in a derived class, replies to a request message. - when it is acceptable for the current thread to be blocked while it replies to the request message. The thread is blocked up to the specified `timeout`. - - If the application processing must continue without waiting for the reply to complete, use the asynchronous method. This method receives notification, through a callback, of the identity of the event handler for the operation. The operation is not complete until either a message becomes available in the channel or the time-out occurs. - + when it is acceptable for the current thread to be blocked while it replies to the request message. The thread is blocked up to the specified `timeout`. + + If the application processing must continue without waiting for the reply to complete, use the asynchronous method. This method receives notification, through a callback, of the identity of the event handler for the operation. The operation is not complete until either a message becomes available in the channel or the time-out occurs. + ]]> @@ -522,13 +519,13 @@ The that specifies the interval of time to wait for the reply to a request. When overridden in a derived class, replies to a request message within a specified interval of time. - when it is acceptable for the current thread to be blocked while it replies to the request message. The thread is blocked up to the specified `timeout`. - - If the application processing must continue without waiting for the reply to complete, use the asynchronous method. This method receives notification, through a callback, of the identity of the event handler for the operation. The operation is not complete until either a message becomes available in the channel or the time-out occurs. - + when it is acceptable for the current thread to be blocked while it replies to the request message. The thread is blocked up to the specified `timeout`. + + If the application processing must continue without waiting for the reply to complete, use the asynchronous method. This method receives notification, through a callback, of the identity of the event handler for the operation. The operation is not complete until either a message becomes available in the channel or the time-out occurs. + ]]> diff --git a/xml/System.ServiceModel.MsmqIntegration/MsmqIntegrationBinding.xml b/xml/System.ServiceModel.MsmqIntegration/MsmqIntegrationBinding.xml index daa8a74188a..132e34e46aa 100644 --- a/xml/System.ServiceModel.MsmqIntegration/MsmqIntegrationBinding.xml +++ b/xml/System.ServiceModel.MsmqIntegration/MsmqIntegrationBinding.xml @@ -17,36 +17,32 @@ The class maps Microsoft Message Queuing (MSMQ) messages to Windows Communication Foundation (WCF) messages. - namespace. - - - -## Examples - The following configuration file snippet illustrates how to configure the binding on the client: - - - - The following configuration file snippet illustrates how to configure the binding on the service: - + This binding can be used to enable WCF applications to send and receive messages to and from existing MSMQ applications that use COM, native C++ APIs, or the types defined in the namespace. + +## Examples + The following configuration file snippet illustrates how to configure the binding on the client: + + The following configuration file snippet illustrates how to configure the binding on the service: + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/s_msmqtowcf/cs/service.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/s_msmqtowcf/vb/service.vb" id="Snippet1"::: - - The following code illustrates how to use the binding on the service programmatically: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/s_msmqtowcf/vb/service.vb" id="Snippet1"::: + + The following code illustrates how to use the binding on the service programmatically: + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/s_msmqtowcf/cs/service.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/s_msmqtowcf/vb/service.vb" id="Snippet2"::: - - The following code illustrates how to use the binding on the client programmatically: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/s_msmqtowcf/vb/service.vb" id="Snippet2"::: + + The following code illustrates how to use the binding on the client programmatically: + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/s_wcftomsmq/cs/snippets.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/s_wcftomsmq/vb/snippets.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/s_wcftomsmq/vb/snippets.vb" id="Snippet2"::: + ]]> @@ -98,19 +94,19 @@ The security mode supported by the Message Queuing (MSMQ) integration channel. Initializes a new instance of the class by using the specified . - and pass in a security mode. - - - -## Examples - The following code illustrates how to instantiate an instance of the binding, specifying the : - + and pass in a security mode. + + + +## Examples + The following code illustrates how to instantiate an instance of the binding, specifying the : + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/s_wcftomsmq/cs/snippets.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/s_wcftomsmq/vb/snippets.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/s_wcftomsmq/vb/snippets.vb" id="Snippet5"::: + ]]> The value is not within the range of values. @@ -136,19 +132,19 @@ The value of the attribute that identifies the element whose settings are used to initialize the binding. Initializes a new instance of the class from the settings of a specified configuration binding element. - binding and initialize it by passing in the name of the binding element: - + binding and initialize it by passing in the name of the binding element: + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/s_wcftomsmq/cs/snippets.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/s_wcftomsmq/vb/snippets.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/s_wcftomsmq/vb/snippets.vb" id="Snippet3"::: + ]]> @@ -210,11 +206,11 @@ Gets the that is associated with this binding. The that is associated with this binding. - encapsulates Message Queuing (MSMQ) transport security settings. - + encapsulates Message Queuing (MSMQ) transport security settings. + ]]> @@ -245,18 +241,18 @@ Gets or sets the serialization format to be used to serialize or deserialize the message. A object that represents the type of serialization to use. - . - - - -## Examples - The following code illustrates how to set the serialization format on an instance of the class: - - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/s_wcftomsmq/cs/client.cs" id="Snippet4"::: - + . + + + +## Examples + The following code illustrates how to set the serialization format on an instance of the class: + + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/s_wcftomsmq/cs/client.cs" id="Snippet4"::: + ]]> diff --git a/xml/System.ServiceModel/ChannelFactory.xml b/xml/System.ServiceModel/ChannelFactory.xml index cb4ef286262..648fe15a4ad 100644 --- a/xml/System.ServiceModel/ChannelFactory.xml +++ b/xml/System.ServiceModel/ChannelFactory.xml @@ -64,36 +64,31 @@ Creates and manages the channels that are used by clients to send messages to service endpoints. - interface and their associated channels are generally used by the initiators of a communication pattern. Listener factories that implement the interface and their associated listeners provide the mechanisms with which channels are accepted for communications. - - This class is not part of the channel model, but of the service model. The method provides the means to create an for a service endpoint. Use it to construct a client that hooks up to an interface contract on the service without using metadata or policy. - + interface and their associated channels are generally used by the initiators of a communication pattern. Listener factories that implement the interface and their associated listeners provide the mechanisms with which channels are accepted for communications. + + This class is not part of the channel model, but of the service model. The method provides the means to create an for a service endpoint. Use it to construct a client that hooks up to an interface contract on the service without using metadata or policy. + > [!NOTE] -> Setting `ChannelFactory.Credentials.Windows.AllowedImpersonationLevel` to `TokenImpersonationLevel.Anonymous` always results in an anonymous logon regardless of impersonation level. - - Special note for Managed C++ users deriving from this class: - -- Put your cleanup code in (On)(Begin)Close (and/or OnAbort), not in a destructor. - -- Avoid destructors; they cause the compiler to auto-generate . - -- Avoid non-reference members; they can cause the compiler to auto-generate . - -- Avoid using a finalizer; but if you include one, you should suppress the build warning and call and the finalizer itself from (On)(Begin)Close (and/or OnAbort) to emulate what would have been the auto-generated behavior. - - When adding behaviors programmatically, the behavior is added to the appropriate `Behaviors` property on the prior to the creation of any channel. See the example section for a code sample. - - - -## Examples - The following code example shows how to insert programmatically a client behavior prior to the creation of the channel object by the factory. - +> Setting `ChannelFactory.Credentials.Windows.AllowedImpersonationLevel` to `TokenImpersonationLevel.Anonymous` always results in an anonymous logon regardless of impersonation level. + + Special note for Managed C++ users deriving from this class: + +- Put your cleanup code in (On)(Begin)Close (and/or OnAbort), not in a destructor. +- Avoid destructors; they cause the compiler to auto-generate . +- Avoid non-reference members; they can cause the compiler to auto-generate . +- Avoid using a finalizer; but if you include one, you should suppress the build warning and call and the finalizer itself from (On)(Begin)Close (and/or OnAbort) to emulate what would have been the auto-generated behavior. + + When adding behaviors programmatically, the behavior is added to the appropriate `Behaviors` property on the prior to the creation of any channel. See the example section for a code sample. + +## Examples + The following code example shows how to insert programmatically a client behavior prior to the creation of the channel object by the factory. + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/channelfactorybehaviors/cs/client.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/channelfactorybehaviors/vb/client.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/channelfactorybehaviors/vb/client.vb" id="Snippet10"::: + ]]> @@ -168,11 +163,11 @@ The name of the configuration file. Initializes the channel factory with the behaviors provided by a specified configuration file and with those in the service endpoint of the channel factory. - The service endpoint of the channel factory is . @@ -281,18 +276,18 @@ Gets the credentials used by clients to communicate a service endpoint over the channels produced by the factory. The used by clients if they are configured for the factory or if the endpoint is non- and is in either the created or opening communication state; otherwise . - object is stored as a type of endpoint behavior and can be accessed through the property. - - The method initializes a read-only copy of the object for the factory. - - The object is used by the class (or a class that derives from this class) to create the proxy objects that can call services. The object is also accessible through the property. - + object is stored as a type of endpoint behavior and can be accessed through the property. + + The method initializes a read-only copy of the object for the factory. + + The object is used by the class (or a class that derives from this class) to create the proxy objects that can call services. The object is also accessible through the property. + > [!NOTE] -> Setting `ChannelFactory.Credentials.Windows.AllowedImpersonationLevel` to `TokenImpersonationLevel.Anonymous` always results in an anonymous logon regardless of impersonation level. - +> Setting `ChannelFactory.Credentials.Windows.AllowedImpersonationLevel` to `TokenImpersonationLevel.Anonymous` always results in an anonymous logon regardless of impersonation level. + ]]> @@ -329,11 +324,11 @@ Gets the default interval of time provided for a close operation to complete. The default that specifies how long the close operation has to complete before timing out. - and are `null`. The default value for the service model close time-out is 1 minute. Otherwise, the value is set to the value associated with the . - + and are `null`. The default value for the service model close time-out is 1 minute. Otherwise, the value is set to the value associated with the . + ]]> @@ -370,11 +365,11 @@ Gets the default interval of time provided for an open operation to complete. The default that specifies how long the open operation has to complete before timing out. - and are `null`. The default value for the service model open time-out is 1 minute. Otherwise, the value is set to the value associated with the . - + and are `null`. The default value for the service model open time-out is 1 minute. Otherwise, the value is set to the value associated with the . + ]]> @@ -455,11 +450,11 @@ Opens the current channel factory if it is not yet opened. - , , or . - + , , or . + ]]> The current factory is either closing or closed and so cannot be opened. @@ -509,13 +504,13 @@ Returns the typed object requested, if present, from the appropriate layer in the channel stack, or if not present. The typed object requested if it is present or if it is not. - ` is called on a duplex channel factory, it returns the underlying listener. - + ` is called on a duplex channel factory, it returns the underlying listener. + ]]> @@ -529,11 +524,11 @@ Initializes the service endpoint of the channel factory. - @@ -573,11 +568,11 @@ The to initialize the channel factory with. Initializes the service endpoint of the channel factory with a specified endpoint. - if you have just the binding. Use if you have the configuration. - + if you have just the binding. Use if you have the configuration. + ]]> @@ -621,11 +616,11 @@ The with which to initialize the channel factory. Initializes the service endpoint of the channel factory with a specified binding and address. - if you have the configuration. - + if you have the configuration. + ]]> @@ -666,11 +661,11 @@ The with which to initialize the channel factory. Initializes the service endpoint of the channel factory with a specified address and configuration. - if you have just the binding. - + if you have just the binding. + ]]> @@ -707,11 +702,11 @@ Terminates the inner channel factory of the current channel factory. - method is called on a factory after it transitions to the closing state if the method is invoked. - + method is called on a factory after it transitions to the closing state if the method is invoked. + ]]> @@ -756,11 +751,11 @@ Begins an asynchronous close operation on the inner channel factory of the current channel factory that has a state object associated with it. The that references the asynchronous operation. - @@ -805,11 +800,11 @@ Begins an asynchronous open operation on the inner channel factory of the current channel factory that has a state object associated with it. The that references the asynchronous operation. - @@ -995,11 +990,11 @@ Initializes a read-only copy of the object for the channel factory. - method, which is called during the transition of an object into the opened state. The object is stored as a type of endpoint behavior and can be accessed through the property. - + method, which is called during the transition of an object into the opened state. The object is stored as a type of endpoint behavior and can be accessed through the property. + ]]> diff --git a/xml/System.ServiceModel/ClientBase`1.xml b/xml/System.ServiceModel/ClientBase`1.xml index ccb40267419..71ac9c06de5 100644 --- a/xml/System.ServiceModel/ClientBase`1.xml +++ b/xml/System.ServiceModel/ClientBase`1.xml @@ -85,15 +85,10 @@ Special note for Managed C++ users deriving from this class: -- Put your clean-up code in (On)(Begin)Close (and/or OnAbort), not in a destructor. - -- Avoid destructors: they cause the compiler to auto-generate . - -- Avoid non-reference members: they can cause the compiler to auto-generate . - -- Avoid finalizers; but if you include one, you should suppress the build warning and call and the finalizer itself from (On)(Begin)Close (and/or OnAbort) to emulate what would have been the auto-generated behavior. - - +- Put your clean-up code in (On)(Begin)Close (and/or OnAbort), not in a destructor. +- Avoid destructors: they cause the compiler to auto-generate . +- Avoid non-reference members: they can cause the compiler to auto-generate . +- Avoid finalizers; but if you include one, you should suppress the build warning and call and the finalizer itself from (On)(Begin)Close (and/or OnAbort) to emulate what would have been the auto-generated behavior. ## Examples The following code example shows how the [ServiceModel Metadata Utility Tool (Svcutil.exe)](/dotnet/framework/wcf/servicemodel-metadata-utility-tool-svcutil-exe) extends the class to create a WCF client class. diff --git a/xml/System.ServiceModel/DuplexClientBase`1.xml b/xml/System.ServiceModel/DuplexClientBase`1.xml index 2fc73c54fe6..32693f91375 100644 --- a/xml/System.ServiceModel/DuplexClientBase`1.xml +++ b/xml/System.ServiceModel/DuplexClientBase`1.xml @@ -69,15 +69,10 @@ Special note for Managed C++ users deriving from this class: -- Put your cleanup code in (On)(Begin)Close (and/or OnAbort), not in a destructor. - -- Avoid destructors: they cause the compiler to auto-generate - -- Avoid non-reference members: they can cause the compiler to auto-generate - -- Avoid finalizers; but if you include one, you should suppress the build warning and call and the finalizer itself from (On)(Begin)Close (and/or OnAbort) in order to emulate what would have been the auto-generated behavior. - - +- Put your cleanup code in (On)(Begin)Close (and/or OnAbort), not in a destructor. +- Avoid destructors: they cause the compiler to auto-generate . +- Avoid non-reference members: they can cause the compiler to auto-generate . +- Avoid finalizers; but if you include one, you should suppress the build warning and call and the finalizer itself from (On)(Begin)Close (and/or OnAbort) in order to emulate what would have been the auto-generated behavior. ## Examples The following example shows the use in the client of a duplex WCF client type, the `SampleDuplexHelloClient`, to pass a new object with the callback object to listen for callbacks. diff --git a/xml/System.ServiceModel/ServiceHostBase.xml b/xml/System.ServiceModel/ServiceHostBase.xml index 570d1e78f0d..26ef2bfdf29 100644 --- a/xml/System.ServiceModel/ServiceHostBase.xml +++ b/xml/System.ServiceModel/ServiceHostBase.xml @@ -24,29 +24,24 @@ Extends the class to implement hosts that expose custom programming models. - class to create hosts that provide a custom programming model. The Windows Communication Foundation (WCF) service programming model uses the class. - - Special note for Managed C++ users deriving from this class: - -- Put your cleanup code in (On)(Begin)Close (and/or OnAbort), not in a destructor. - -- Avoid destructors; they cause the compiler to auto-generate . - -- Avoid non-reference members; they can cause the compiler to auto-generate . - -- Avoid finalizers; but if you include one, you should suppress the build warning and call and the finalizer itself from (On)(Begin)Close (and/or OnAbort) to emulate what would have been the auto-generated behavior. - - - -## Examples - This sample uses the class, which is derived from . - + class to create hosts that provide a custom programming model. The Windows Communication Foundation (WCF) service programming model uses the class. + + Special note for Managed C++ users deriving from this class: + +- Put your cleanup code in (On)(Begin)Close (and/or OnAbort), not in a destructor. +- Avoid destructors; they cause the compiler to auto-generate . +- Avoid non-reference members; they can cause the compiler to auto-generate . +- Avoid finalizers; but if you include one, you should suppress the build warning and call and the finalizer itself from (On)(Begin)Close (and/or OnAbort) to emulate what would have been the auto-generated behavior. + +## Examples + This sample uses the class, which is derived from . + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/s_selfhost/cs/wholeenchilada.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/s_selfhost/vb/wholeenchilada.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/s_selfhost/vb/wholeenchilada.vb" id="Snippet1"::: + ]]> @@ -67,11 +62,11 @@ Initializes a new instance of the class. - @@ -99,11 +94,11 @@ A that contains the base address for services hosted on the current host. Adds a base address to the service host. - to provide the base address after the host is constructed. can be used to add base addresses to an existing host, but throws an exception if the description is already initialized. - + to provide the base address after the host is constructed. can be used to add base addresses to an existing host, but throws an exception if the description is already initialized. + ]]> The cannot be called. @@ -162,15 +157,15 @@ The service endpoint. Adds the specified service endpoint to the hosted service. - exists in the list of configuration names of the service contracts implemented by the service. If the validation passes, the description in the is used as it is, even if the reflected from the service is different. - - As an example, assume that the description in the ServiceEndpoint and the contract description reflected from the service have the same name, but different operation behaviors. The implication of only "by-configuration-name" validation is that there is no validation that the behaviors are the same and there are one updates to one description because of another description. - - If the `address` is a relative URI, one of the base addresses of the (depending on the binding protocol) is used as the endpoint's base address. - + exists in the list of configuration names of the service contracts implemented by the service. If the validation passes, the description in the is used as it is, even if the reflected from the service is different. + + As an example, assume that the description in the ServiceEndpoint and the contract description reflected from the service have the same name, but different operation behaviors. The implication of only "by-configuration-name" validation is that there is no validation that the behaviors are the same and there are one updates to one description because of another description. + + If the `address` is a relative URI, one of the base addresses of the (depending on the binding protocol) is used as the endpoint's base address. + ]]> @@ -213,11 +208,11 @@ Adds a service endpoint to the hosted service with a specified contract, binding, and endpoint address. The added to the hosted service. - @@ -294,11 +289,11 @@ Adds a service endpoint to the hosted service with a specified contract, binding, endpoint address and URI that contains the address at which it listens. The added to the hosted service. - (depending on the binding protocol) is used as the endpoint's base address. - + (depending on the binding protocol) is used as the endpoint's base address. + ]]> @@ -405,11 +400,11 @@ Gets the authorization behavior for the service hosted. The for the service hosted. - @@ -490,11 +485,11 @@ Gets or sets the interval of time allowed for the service host to close. The that specifies the interval of time allowed for the service host to close. - The value, in milliseconds, is less than zero or is larger than Int32.MaxValue (2,147,483,647 or, in hexadecimal notation, 0X7FFFFFFF). @@ -527,11 +522,11 @@ When implemented in a derived class, creates the description of the hosted service. The for the hosted service. - @@ -556,11 +551,11 @@ Gets the credential for the service hosted. The for the service hosted. - @@ -619,11 +614,11 @@ Gets the default interval of time allowed for the service host to open. The that specifies the default interval of time allowed for the service host to open. - @@ -654,11 +649,11 @@ Gets the description of the service hosted. The for the hosted service. - @@ -749,16 +744,16 @@ Increases the limit on the flow rate of messages to the hosted service by a specified increment. The new limit after the increment is added. - property. - - - -## Examples - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/s_selfhost/cs/wholeenchilada.cs" id="Snippet42"::: - + property. + + + +## Examples + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/s_selfhost/cs/wholeenchilada.cs" id="Snippet42"::: + ]]> The value is less than zero. @@ -860,16 +855,16 @@ Gets or sets the flow control limit for messages received by the service hosted. The flow control limit for messages received by the service hosted. - method. - - - -## Examples - :::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/s_selfhost/cs/wholeenchilada.cs" id="Snippet39"::: - + method. + + + +## Examples + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/s_selfhost/cs/wholeenchilada.cs" id="Snippet39"::: + ]]> The value is less than zero. @@ -986,19 +981,19 @@ The that specifies how long the on-close operation has to complete before timing out. Closes down the hosted service, including their channel dispatchers and associated instance contexts and listeners. - does the following: - -- Closes all input to , which also closes their associated instances. This stops any new channels from being accepting. - -- Calls on all objects, which mean they stop accepting new messages. - -- Waits for all objects to close down, which happens when their associated channels finish sending all pending messages. - -- Closes the objects associated with the host. - + does the following: + +- Closes all input to , which also closes their associated instances. This stops any new channels from being accepting. + +- Calls on all objects, which mean they stop accepting new messages. + +- Waits for all objects to close down, which happens when their associated channels finish sending all pending messages. + +- Closes the objects associated with the host. + ]]> @@ -1123,11 +1118,11 @@ Gets the service credentials,service authentication and authorization behavior for the hosted service. - @@ -1184,13 +1179,13 @@ Releases the service and channel dispatcher performance counters for the hosted service. - and - - . - + and + + . + ]]> @@ -1274,13 +1269,13 @@ This member is an explicit interface member implementation. It can be used only Occurs when an unknown message is received. - [!WARNING] -> When using , exposing a hosting endpoint, and a exception is thrown, the host passes the message to the event handler. If an attempt is made to read this message an is thrown. The description of the exception will say "This message cannot support the operation because it has been read." The WCF infrastructure reads the message while extracting the message parameters. This message is then passed to the event handler and any attempt to read it causes an exception. If you need to access message parameters in your handler from a hosting endpoint, define the hosting endpoint contract using MessageContract and place the needed data into a message header. For more information about hosting endpoints, see [Workflow Service Host Extensibility](/dotnet/framework/wcf/feature-details/workflow-service-host-extensibility) - +> When using , exposing a hosting endpoint, and a exception is thrown, the host passes the message to the event handler. If an attempt is made to read this message an is thrown. The description of the exception will say "This message cannot support the operation because it has been read." The WCF infrastructure reads the message while extracting the message parameters. This message is then passed to the event handler and any attempt to read it causes an exception. If you need to access message parameters in your handler from a hosting endpoint, define the hosting endpoint contract using MessageContract and place the needed data into a message header. For more information about hosting endpoints, see [Workflow Service Host Extensibility](/dotnet/framework/wcf/feature-details/workflow-service-host-extensibility) + ]]> diff --git a/xml/System.Text/SpanRuneEnumerator.xml b/xml/System.Text/SpanRuneEnumerator.xml index e45e9b64629..29f48783705 100644 --- a/xml/System.Text/SpanRuneEnumerator.xml +++ b/xml/System.Text/SpanRuneEnumerator.xml @@ -33,14 +33,14 @@ Provides an enumerator for the values represented by a span containing UTF-16 text. - method along with language-specific enumeration constructs to enumerate values within spans. -The `foreach` statement of the C# language (`for each` in C++, `For Each` in Visual Basic) hides the complexity of enumerators. Therefore, using `foreach` is recommended, instead of directly manipulating the enumerator. - +The `foreach` statement of the C# language (`For Each` in Visual Basic) hides the complexity of enumerators. Therefore, using `foreach` is recommended, instead of directly manipulating the enumerator. + ]]> diff --git a/xml/System.Text/StringRuneEnumerator.xml b/xml/System.Text/StringRuneEnumerator.xml index 2f1b848c07c..e232b7de589 100644 --- a/xml/System.Text/StringRuneEnumerator.xml +++ b/xml/System.Text/StringRuneEnumerator.xml @@ -39,14 +39,14 @@ Provides an enumerator for the values represented by a string. - method along with language-specific enumeration constructs to enumerate values within strings. -The `foreach` statement of the C# language (`for each` in C++, `For Each` in Visual Basic) hides the complexity of enumerators. Therefore, using `foreach` is recommended, instead of directly manipulating the enumerator. - +The `foreach` statement of the C# language (`For Each` in Visual Basic) hides the complexity of enumerators. Therefore, using `foreach` is recommended, instead of directly manipulating the enumerator. + ]]> @@ -174,13 +174,13 @@ The `foreach` statement of the C# language (`for each` in C++, `For Each` in Vis Returns the current enumerator instance. The current enumerator instance. - instance is cast to an interface. -This member is an explicit interface member implementation. -It can be used only when the instance is cast to an interface. - ]]> @@ -215,13 +215,13 @@ It can be used only when the instance is Returns the current enumerator instance. The current enumerator instance. - instance is cast to an interface. - + ]]> @@ -261,13 +261,13 @@ It can be used only when the instance is Gets the at the current position of the enumerator. The at the current position of the enumerator. - instance is cast to an interface. - + ]]> @@ -301,13 +301,13 @@ It can be used only when the instance is Resets the current instance to the beginning of the string. - instance is cast to an interface. - + ]]> diff --git a/xml/System.Threading/ParameterizedThreadStart.xml b/xml/System.Threading/ParameterizedThreadStart.xml index 4e0e5d84210..f821ca9a38d 100644 --- a/xml/System.Threading/ParameterizedThreadStart.xml +++ b/xml/System.Threading/ParameterizedThreadStart.xml @@ -57,45 +57,41 @@ An object that contains data for the thread procedure. Represents the method that executes on a . - delegate that is passed to the constructor. Any method that has no parameters and that returns `void` in C# or is a `Sub` procedure in Visual Basic can represent the delegate. - -- A delegate that is passed to the constructor. Any method that has a single parameter of type and that returns void in C# or is a Sub procedure in Visual Basic can represent the delegate. - - The thread does not begin executing until the method is called. The or delegate is invoked on the thread, and execution begins at the first line of the method represented by the delegate. In the case of the delegate, the object that is passed to the method is passed to the delegate. - + delegate that is passed to the constructor. Any method that has no parameters and that returns `void` in C# or is a `Sub` procedure in Visual Basic can represent the delegate. + +- A delegate that is passed to the constructor. Any method that has a single parameter of type and that returns void in C# or is a Sub procedure in Visual Basic can represent the delegate. + + The thread does not begin executing until the method is called. The or delegate is invoked on the thread, and execution begins at the first line of the method represented by the delegate. In the case of the delegate, the object that is passed to the method is passed to the delegate. + > [!NOTE] -> Visual Basic and C# users can omit the or delegate constructor when creating a thread. In Visual Basic, use the `AddressOf` operator when passing your method to the constructor; for example, `Dim t As New Thread(AddressOf ThreadProc)`. In C#, simply specify the name of the thread procedure. The compiler selects the correct delegate constructor. - +> Visual Basic and C# users can omit the or delegate constructor when creating a thread. In Visual Basic, use the `AddressOf` operator when passing your method to the constructor; for example, `Dim t As New Thread(AddressOf ThreadProc)`. In C#, simply specify the name of the thread procedure. The compiler selects the correct delegate constructor. + > [!NOTE] -> When you create a delegate for an instance method in C++, the first parameter of the constructor is the instance variable. For a static method, the first parameter of the constructor is zero. For a static method, the delegate constructor requires only one parameter: the address of the callback method, qualified by the class name. - - The delegate and the method overload make it easy to pass data to a thread procedure, but this technique is not type safe because any object can be passed to . A more robust way to pass data to a thread procedure is to put both the thread procedure and the data fields into a worker object. For more information, see [Creating Threads and Passing Data at Start Time](/dotnet/standard/threading/creating-threads-and-passing-data-at-start-time). - - The delegate supports only a single parameter. You can pass multiple data items to the by making that parameter one of the following: - -- An array. - -- A collection type, if all of the data items are of the same type. - -- A tuple type, such as or . - - - -## Examples - The following code example uses a delegate to execute a static method and an instance method. The first delegate is represented by the static `DoWork` method and the second is represented by the instance `DoMoreWork` method. Both methods match the delegate signature; that is, they have a single parameter of type and don't return a value. - +> When you create a delegate for an instance method in C++, the first parameter of the constructor is the instance variable. For a static method, the first parameter of the constructor is zero. For a static method, the delegate constructor requires only one parameter: the address of the callback method, qualified by the class name. + + The delegate and the method overload make it easy to pass data to a thread procedure, but this technique is not type safe because any object can be passed to . A more robust way to pass data to a thread procedure is to put both the thread procedure and the data fields into a worker object. For more information, see [Creating Threads and Passing Data at Start Time](/dotnet/standard/threading/creating-threads-and-passing-data-at-start-time). + + The delegate supports only a single parameter. You can pass multiple data items to the by making that parameter one of the following: + +- An array. +- A collection type, if all of the data items are of the same type. +- A tuple type, such as or . + +## Examples + The following code example uses a delegate to execute a static method and an instance method. The first delegate is represented by the static `DoWork` method and the second is represented by the instance `DoMoreWork` method. Both methods match the delegate signature; that is, they have a single parameter of type and don't return a value. + > [!NOTE] -> The Visual Basic and C# compilers infer the delegate from the signatures of the `DoWork` and `DoMoreWork` methods, and call the correct constructor. Thus, there is no explicit constructor call in the code. - +> The Visual Basic and C# compilers infer the delegate from the signatures of the `DoWork` and `DoMoreWork` methods, and call the correct constructor. Thus, there is no explicit constructor call in the code. + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ParameterizedThreadStart/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ParameterizedThreadStart/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ParameterizedThreadStart/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ParameterizedThreadStart/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Threading/Thread.xml b/xml/System.Threading/Thread.xml index 35e0dbcad5b..bfdf373abc4 100644 --- a/xml/System.Threading/Thread.xml +++ b/xml/System.Threading/Thread.xml @@ -847,16 +847,12 @@ This method is obsolete. On .NET 5 and later versions, calling this method produ property is obsolete.** The non-obsolete alternatives are the method to retrieve the apartment state and the method to set the apartment state. - - In .NET Framework versions 1.0 and 1.1, the `ApartmentState` property marks a thread to indicate that it will execute in a single-threaded or multithreaded apartment. This property can be set when the thread is in the `Unstarted` or `Running` thread state; however, it can be set only once for a thread. If the property has not been set, it returns `Unknown`. - - An attempt to use the property to set the apartment state of a thread whose apartment state has already been set is ignored. However, the method throws a in this case. + **The property is obsolete.** The non-obsolete alternatives are the method to retrieve the apartment state and the method to set the apartment state. > [!IMPORTANT] -> In .NET Framework version 2.0, new threads are initialized as if their apartment state has not been set before they are started. The main application thread is initialized to by default. You can no longer set the main application thread to by setting the property on the first line of code. Use the instead. +> New threads are initialized as if their apartment state has not been set before they're started. The main application thread is initialized to by default. - In .NET Framework version 2.0, you can specify the COM threading model for a C++ application using the [/CLRTHREADATTRIBUTE (Set CLR Thread Attribute)](/cpp/build/reference/clrthreadattribute-set-clr-thread-attribute) linker option. +You can specify the COM threading model for a C++ application using the [/CLRTHREADATTRIBUTE (Set CLR Thread Attribute)](/cpp/build/reference/clrthreadattribute-set-clr-thread-attribute) linker option. ## Examples The following code example demonstrates how to set the apartment state of a thread. diff --git a/xml/System.Threading/ThreadStart.xml b/xml/System.Threading/ThreadStart.xml index b49b5d0e59b..368c6388176 100644 --- a/xml/System.Threading/ThreadStart.xml +++ b/xml/System.Threading/ThreadStart.xml @@ -54,27 +54,23 @@ Represents the method that executes on a . - delegate or a delegate that is passed to the constructor. The thread does not begin executing until the method is called. Execution begins at the first line of the method represented by the or delegate. - + delegate or a delegate that is passed to the constructor. The thread does not begin executing until the method is called. Execution begins at the first line of the method represented by the or delegate. + > [!NOTE] -> Visual Basic and C# users can omit the or delegate constructor when creating a thread. In Visual Basic, use the `AddressOf` operator when passing your method to the constructor; for example, `Dim t As New Thread(AddressOf ThreadProc)`. In C#, simply specify the name of the thread procedure. The compiler selects the correct delegate constructor. -> -> For C++, starting with .NET Framework 2.0, creating a delegate for a static method requires only one parameter: the address of the callback method, qualified by the class name. In earlier versions two parameters were required when creating a delegate for a static method: zero (null) and the method address. For an instance method, all versions require two parameters: the instance variable and the method address. - - - -## Examples - The following code example shows the syntax for creating and using a delegate with an instance method and with a static method. - - For another simple example that demonstrates how to create a delegate, see the method overload. For more information about thread creation, see [Creating Threads and Passing Data at Start Time](/dotnet/standard/threading/creating-threads-and-passing-data-at-start-time). - +> Visual Basic and C# users can omit the or delegate constructor when creating a thread. In Visual Basic, use the `AddressOf` operator when passing your method to the constructor; for example, `Dim t As New Thread(AddressOf ThreadProc)`. In C#, simply specify the name of the thread procedure. The compiler selects the correct delegate constructor. + +## Examples + The following code example shows the syntax for creating and using a delegate with an instance method and with a static method. + + For another simple example that demonstrates how to create a delegate, see the method overload. For more information about thread creation, see [Creating Threads and Passing Data at Start Time](/dotnet/standard/threading/creating-threads-and-passing-data-at-start-time). + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Threading.ThreadStart2/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Threading/ThreadStart/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadStart2/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Threading.ThreadStart2/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Windows.Forms/Control.xml b/xml/System.Windows.Forms/Control.xml index 85b21b56a24..76b850351fd 100644 --- a/xml/System.Windows.Forms/Control.xml +++ b/xml/System.Windows.Forms/Control.xml @@ -11292,9 +11292,7 @@ MyControl.Font = New Font(MyControl.Font, _ property can be used at run time to evaluate the object by name rather than type and programmatic name. Because the property returns a type, it can be evaluated in case-style logic statements (`Select` statement in Visual Basic, `switch` statement in Visual C# and Visual C++). - - + The property can be used at run time to evaluate the object by name rather than type and programmatic name. Because the property returns a type, it can be evaluated in case-style logic statements (`Select` statement in Visual Basic, `switch` statement in C#). ## Examples The following code example displays the of a control in a when the control is added or removed from a form. diff --git a/xml/System.Workflow.ComponentModel/ActivityCollection.xml b/xml/System.Workflow.ComponentModel/ActivityCollection.xml index f5c5e0f7ffe..1be440f31ad 100644 --- a/xml/System.Workflow.ComponentModel/ActivityCollection.xml +++ b/xml/System.Workflow.ComponentModel/ActivityCollection.xml @@ -56,26 +56,26 @@ Models a strongly typed of type . - [!NOTE] -> [!INCLUDE[DeprecatedContent](~/includes/deprecatedcontent-md.md)] - - This class is used to represent the list of child activities for a . - +> [!INCLUDE[DeprecatedContent](~/includes/deprecatedcontent-md.md)] + + This class is used to represent the list of child activities for a . + > [!NOTE] -> Only call methods derived from and not , such as using to add activities instead of . Calling methods derived from will have unexpected consequences. - - - -## Examples - The following example shows access of the which is the member of a composite activity class containing all child activities. This code example is part of the Using Throw SDK Sample and is from the ThrowWorkflow.cs file. For more information, see [Using the ThrowActivity Activity](https://msdn.microsoft.com/library/82bc0fef-d78a-4750-82b4-e4cb397a10f1). - +> Only call methods derived from and not , such as using to add activities instead of . Calling methods derived from will have unexpected consequences. + + + +## Examples + The following example shows access of the which is the member of a composite activity class containing all child activities. This code example is part of the Using Throw SDK Sample and is from the ThrowWorkflow.cs file. For more information, see [Using the ThrowActivity Activity](https://msdn.microsoft.com/library/82bc0fef-d78a-4750-82b4-e4cb397a10f1). + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/wf_samples/cs/snippets11.cs" id="Snippet179"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/wf_samples/vb/snippets11.vb" id="Snippet179"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/wf_samples/vb/snippets11.vb" id="Snippet179"::: + ]]> @@ -100,11 +100,11 @@ The designated as owning this instance. Initializes a new instance of the class, initializing an owner . - @@ -139,14 +139,14 @@ The to be added to the . Adds the to the . - which is the member of a composite activity class containing all child activities. This example illustrates the use of . This code example is part of the Throw SDK sample and is from the ThrowWorkflow.cs file. For more information, see [Using the ThrowActivity Activity](https://msdn.microsoft.com/library/82bc0fef-d78a-4750-82b4-e4cb397a10f1). - + which is the member of a composite activity class containing all child activities. This example illustrates the use of . This code example is part of the Throw SDK sample and is from the ThrowWorkflow.cs file. For more information, see [Using the ThrowActivity Activity](https://msdn.microsoft.com/library/82bc0fef-d78a-4750-82b4-e4cb397a10f1). + :::code language="csharp" source="~/snippets/csharp/VS_Snippets_CFX/wf_samples/cs/snippets11.cs" id="Snippet179"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/wf_samples/vb/snippets11.vb" id="Snippet179"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CFX/wf_samples/vb/snippets11.vb" id="Snippet179"::: + ]]> @@ -204,11 +204,11 @@ if the belongs to the ; otherwise, . - is type-safe. A run-time exception is raised if the item is not of type . - + is type-safe. A run-time exception is raised if the item is not of type . + ]]> @@ -262,23 +262,23 @@ Implements an enumeration interface to the . An enumerator that can iterate through the instance. - also brings the enumerator back to this position. At this position, calling raises an exception. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . - - returns the same object until either or is called. sets to the next element. - - After the end of the collection is passed, the enumerator is positioned after the last element in the collection, and calling returns `false`. If the last call to returned `false`, calling raises an exception. - - To set `Current` to the first element of the collection again, you can call `Reset` 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 irreversibly invalidated and the next call to or `Reset` raises an . If the collection is modified between and , will return 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 could still modify the collection. This causes the enumerator to raise 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. - + also brings the enumerator back to this position. At this position, calling raises an exception. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . + + returns the same object until either or is called. sets to the next element. + + After the end of the collection is passed, the enumerator is positioned after the last element in the collection, and calling returns `false`. If the last call to returned `false`, calling raises an exception. + + To set `Current` to the first element of the collection again, you can call `Reset` 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 irreversibly invalidated and the next call to or `Reset` raises an . If the collection is modified between and , will return 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 could still modify the collection. This causes the enumerator to raise 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. + ]]> @@ -310,11 +310,11 @@ Gets the index of the in the . The index of the in the . Otherwise -1 (if is not in the ). - . - + . + ]]> @@ -347,11 +347,11 @@ The to be inserted into the collection. Inserts the item at the index in the . - is type safe. A run-time exception is raised if an item is not of type . - + is type safe. A run-time exception is raised if an item is not of type . + ]]> @@ -422,11 +422,11 @@ Gets the activity in the based on the string which is a unique key. A member of the ; the key in the which was specified in the call. - in the with specified key, an exception is raised. - + in the with specified key, an exception is raised. + ]]> @@ -451,13 +451,13 @@ Raised whenever a change is made to the contents of this . - 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/). - + 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/). + ]]> @@ -490,11 +490,11 @@ if the operation succeeded; otherwise, . - is type safe. A run-time exception is raised if an item is not of type . - + is type safe. A run-time exception is raised if an item is not of type . + ]]> @@ -526,11 +526,11 @@ Position in a zero-based index to remove the activity from the collection. Removes the in the at the specified . - @@ -561,11 +561,11 @@ The to add to the . Adds an object to the at the end of the . - is not of type . - + is not of type . + ]]> @@ -593,11 +593,11 @@ Clears all activities from the . - property is zero after this operation is finished. - + property is zero after this operation is finished. + ]]> @@ -630,11 +630,11 @@ if value is in the collection; otherwise, . - is not of type . - + is not of type . + ]]> @@ -672,10 +672,10 @@ is less than zero. - is multidimensional. - - is equal to or greater than the length of . - + is multidimensional. + + is equal to or greater than the length of . + The number of elements in the source is greater than the available space from to the end of the destination array. The type cannot be cast automatically to the type of the destination . @@ -729,11 +729,11 @@ if the is read-only; otherwise, . - @@ -766,13 +766,13 @@ if was successfully removed from the ; otherwise, . This method also returns if is not found in the original . - uses , whereas, allows the user to specify the implementation to use for comparing keys. - - 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. - + uses , whereas, allows the user to specify the implementation to use for comparing keys. + + 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. + ]]> The is read-only. @@ -802,25 +802,25 @@ Returns an enumerator that iterates through the collection. An that can be used to iterate through the collection. - 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 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. You cannot set to the first element of the collection again; you must create a new enumerator instance instead. - - 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. - - Default implementations of collections in the namespace are not synchronized. - + 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 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. You cannot set to the first element of the collection again; you must create a new enumerator instance instead. + + 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. + + Default implementations of collections in the namespace are not synchronized. + ]]> @@ -852,11 +852,11 @@ Determines the index of a specific item in the . The index of if found in the list; otherwise, -1. - @@ -889,11 +889,11 @@ The object to insert. It must be of type . Inserts an into the at the zero-based index specified. - cannot be cast to an , a custom is raised. - + cannot be cast to an , a custom is raised. + ]]> @@ -925,13 +925,13 @@ Gets or sets the element at the specified index. The at the specified index. - @@ -965,11 +965,11 @@ The zero-based index of the item to remove. Removes the item at the specified index. - @@ -1031,15 +1031,15 @@ if access to the is synchronized, that is, 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. - + 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. + ]]> @@ -1067,13 +1067,13 @@ Gets an object that can be used to synchronize access to the . An object that can be used to synchronize access to the . - property. - - Most collection classes in 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. - + property. + + Most collection classes in 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. + ]]> @@ -1102,11 +1102,11 @@ Returns an that iterates through the underlying . An that can be used to iterate through the collection. - only allows for reading the data in the collection. You cannot use an to modify the underlying collection. - + only allows for reading the data in the collection. You cannot use an to modify the underlying collection. + ]]> @@ -1287,11 +1287,11 @@ This member is an explicit interface member implementation. It can be used only if the has a fixed size; otherwise, . - @@ -1385,15 +1385,15 @@ This member is an explicit interface member implementation. It can be used only The to remove from the . Removes the first occurrence of a specific object from the . - - The is read-only. - + The is read-only. + has a fixed size. diff --git a/xml/System/Action.xml b/xml/System/Action.xml index 196e7270286..2b434879fa9 100644 --- a/xml/System/Action.xml +++ b/xml/System/Action.xml @@ -63,38 +63,36 @@ Encapsulates a method that has no parameters and does not return a value. - [!NOTE] -> To reference a method that has no parameters and returns a value, use the generic delegate instead. - - When you use the delegate, you do not have to explicitly define a delegate that encapsulates a parameterless procedure. For example, the following code explicitly declares a delegate named `ShowValue` and assigns a reference to the `Name.DisplayToWindow` instance method to its delegate instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.action.delegate/cpp/delegate.cpp" id="Snippet1"::: +> To reference a method that has no parameters and returns a value, use the generic delegate instead. + + When you use the delegate, you do not have to explicitly define a delegate that encapsulates a parameterless procedure. For example, the following code explicitly declares a delegate named `ShowValue` and assigns a reference to the `Name.DisplayToWindow` instance method to its delegate instance. + :::code language="csharp" source="~/snippets/csharp/System/Action/Overview/delegate1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Action/fs/Delegate.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.action.delegate/vb/delegate.vb" id="Snippet1"::: - - The following example simplifies this code by instantiating the delegate instead of explicitly defining a new delegate and assigning a named method to it. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Action/cpp/action.cpp" id="Snippet2"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.action.delegate/vb/delegate.vb" id="Snippet1"::: + + The following example simplifies this code by instantiating the delegate instead of explicitly defining a new delegate and assigning a named method to it. + :::code language="csharp" source="~/snippets/csharp/System/Action/Overview/Action.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Action/fs/Action.fs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Action/vb/Action.vb" id="Snippet2"::: - - You can also use the delegate with anonymous methods in C#, as the following example illustrates. (For an introduction to anonymous methods, see [Anonymous Methods](/dotnet/csharp/programming-guide/statements-expressions-operators/anonymous-methods).) - - :::code language="csharp" source="~/snippets/csharp/System/Action/Overview/Anon.cs" id="Snippet3"::: - - You can also assign a lambda expression to an delegate instance, as the following example illustrates. (For an introduction to lambda expressions, see [Lambda Expressions (C#)](/dotnet/csharp/programming-guide/statements-expressions-operators/lambda-expressions) or [Lambda Expressions (F#)](/dotnet/fsharp/language-reference/functions/lambda-expressions-the-fun-keyword).) - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Action/vb/Action.vb" id="Snippet2"::: + + You can also use the delegate with anonymous methods in C#, as the following example illustrates. (For an introduction to anonymous methods, see [Anonymous Methods](/dotnet/csharp/programming-guide/statements-expressions-operators/anonymous-methods).) + + :::code language="csharp" source="~/snippets/csharp/System/Action/Overview/Anon.cs" id="Snippet3"::: + + You can also assign a lambda expression to an delegate instance, as the following example illustrates. (For an introduction to lambda expressions, see [Lambda Expressions (C#)](/dotnet/csharp/programming-guide/statements-expressions-operators/lambda-expressions) or [Lambda Expressions (F#)](/dotnet/fsharp/language-reference/functions/lambda-expressions-the-fun-keyword).) + :::code language="csharp" source="~/snippets/csharp/System/Action/Overview/Lambda.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Action/fs/Lambda.fs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Action/vb/lambda.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Action/vb/lambda.vb" id="Snippet4"::: + ]]> diff --git a/xml/System/Action`1.xml b/xml/System/Action`1.xml index fbd0eeffa3c..bbaf1e77c32 100644 --- a/xml/System/Action`1.xml +++ b/xml/System/Action`1.xml @@ -73,49 +73,47 @@ The parameter of the method that this delegate encapsulates. Encapsulates a method that has a single parameter and does not return a value. - delegate to pass a method as a parameter without explicitly declaring a custom delegate. The encapsulated method must correspond to the method signature that is defined by this delegate. This means that the encapsulated method must have one parameter that is passed to it by value, and it must not return a value. (In C#, the method must return `void`. In Visual Basic, it must be defined by the `Sub`…`End Sub` construct. It can also be a method that returns a value that is ignored.) Typically, such a method is used to perform an operation. - + delegate to pass a method as a parameter without explicitly declaring a custom delegate. The encapsulated method must correspond to the method signature that is defined by this delegate. This means that the encapsulated method must have one parameter that is passed to it by value, and it must not return a value. (In C#, the method must return `void`. In Visual Basic, it must be defined by the `Sub`…`End Sub` construct. It can also be a method that returns a value that is ignored.) Typically, such a method is used to perform an operation. + > [!NOTE] -> To reference a method that has one parameter and returns a value, use the generic delegate instead. - - When you use the delegate, you do not have to explicitly define a delegate that encapsulates a method with a single parameter. For example, the following code explicitly declares a delegate named `DisplayMessage` and assigns a reference to either the method or the `ShowWindowsMessage` method to its delegate instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Action~1/cpp/delegate.cpp" id="Snippet1"::: +> To reference a method that has one parameter and returns a value, use the generic delegate instead. + + When you use the delegate, you do not have to explicitly define a delegate that encapsulates a method with a single parameter. For example, the following code explicitly declares a delegate named `DisplayMessage` and assigns a reference to either the method or the `ShowWindowsMessage` method to its delegate instance. + :::code language="csharp" source="~/snippets/csharp/System/ActionT/Overview/Delegate.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Action~1/fs/Delegate.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Action~1/vb/Delegate.vb" id="Snippet1"::: - - The following example simplifies this code by instantiating the delegate instead of explicitly defining a new delegate and assigning a named method to it. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Action~1/cpp/action`1.cpp" id="Snippet2"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Action~1/vb/Delegate.vb" id="Snippet1"::: + + The following example simplifies this code by instantiating the delegate instead of explicitly defining a new delegate and assigning a named method to it. + :::code language="csharp" source="~/snippets/csharp/System/ActionT/Overview/Action1.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Action~1/fs/Action1.fs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Action~1/vb/Action1.vb" id="Snippet2"::: - - You can also use the delegate with anonymous methods in C#, as the following example illustrates. (For an introduction to anonymous methods, see [Anonymous Methods](/dotnet/csharp/programming-guide/statements-expressions-operators/anonymous-methods).) - - :::code language="csharp" source="~/snippets/csharp/System/ActionT/Overview/Anon.cs" id="Snippet3"::: - - You can also assign a lambda expression to an delegate instance, as the following example illustrates. (For an introduction to lambda expressions, see [Lambda Expressions](/dotnet/csharp/programming-guide/statements-expressions-operators/lambda-expressions).) - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Action~1/vb/Action1.vb" id="Snippet2"::: + + You can also use the delegate with anonymous methods in C#, as the following example illustrates. (For an introduction to anonymous methods, see [Anonymous Methods](/dotnet/csharp/programming-guide/statements-expressions-operators/anonymous-methods).) + + :::code language="csharp" source="~/snippets/csharp/System/ActionT/Overview/Anon.cs" id="Snippet3"::: + + You can also assign a lambda expression to an delegate instance, as the following example illustrates. (For an introduction to lambda expressions, see [Lambda Expressions](/dotnet/csharp/programming-guide/statements-expressions-operators/lambda-expressions).) + :::code language="csharp" source="~/snippets/csharp/System/ActionT/Overview/Lambda.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Action~1/fs/Lambda.fs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Action~1/vb/lambda.vb" id="Snippet4"::: - - The and methods each take an delegate as a parameter. The method encapsulated by the delegate allows you to perform an action on each element in the array or list. The example uses the method to provide an illustration. - - - -## Examples - The following example demonstrates the use of the delegate to print the contents of a object. In this example, the `Print` method is used to display the contents of the list to the console. In addition, the C# example also demonstrates the use of anonymous methods to display the contents to the console. Note that the example does not explicitly declare an variable. Instead, it passes a reference to a method that takes a single parameter and that does not return a value to the method, whose single parameter is an delegate. Similarly, in the C# example, an delegate is not explicitly instantiated because the signature of the anonymous method matches the signature of the delegate that is expected by the method. + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Action~1/vb/lambda.vb" id="Snippet4"::: + + The and methods each take an delegate as a parameter. The method encapsulated by the delegate allows you to perform an action on each element in the array or list. The example uses the method to provide an illustration. + + + +## Examples + The following example demonstrates the use of the delegate to print the contents of a object. In this example, the `Print` method is used to display the contents of the list to the console. In addition, the C# example also demonstrates the use of anonymous methods to display the contents to the console. Note that the example does not explicitly declare an variable. Instead, it passes a reference to a method that takes a single parameter and that does not return a value to the method, whose single parameter is an delegate. Similarly, in the C# example, an delegate is not explicitly instantiated because the signature of the anonymous method matches the signature of the delegate that is expected by the method. :::code language="csharp" source="~/snippets/csharp/System/ActionT/Overview/action.cs" interactive="try-dotnet-method" id="Snippet01"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Action_PrintExample/fs/action.fs" id="Snippet01"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Action_PrintExample/vb/action.vb" id="Snippet01"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Action_PrintExample/vb/action.vb" id="Snippet01"::: + ]]> diff --git a/xml/System/Activator.xml b/xml/System/Activator.xml index c53417e1b0b..5b8abcd0978 100644 --- a/xml/System/Activator.xml +++ b/xml/System/Activator.xml @@ -96,12 +96,9 @@ Assemblies contain type definitions. The method creates an instance of a type from a currently running assembly. The method creates an instance from a file that contains an assembly. The method creates an instance of a COM object from a file that contains an assembly. - - ## Examples The following example shows how to use the class to dynamically construct objects at run time. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ActivatorX/cpp/ActivatorX.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Activator/Overview/ActivatorX.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/ActivatorX/fs/ActivatorX.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ActivatorX/VB/ActivatorX.vb" id="Snippet1"::: @@ -409,12 +406,9 @@ > [!NOTE] > Starting with .NET Framework 2.0, this method can be used to access nonpublic types if the caller has been granted with the flag and if the grant set of the assembly that contains the nonpublic types is restricted to the caller's grant set or to a subset thereof. (See [Security Considerations for Reflection](/dotnet/framework/reflection-and-codedom/security-considerations-for-reflection).) To use this functionality, your application should target .NET Framework 3.5 or later. - - ## Examples The following code example demonstrates how to call the method. Instances of several different types are created and their default values are displayed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ActivatorX/cpp/source2.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Activator/Overview/source2.cs" interactive="try-dotnet" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/ActivatorX/fs/source2.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ActivatorX/VB/source2.vb" id="Snippet4"::: @@ -1905,14 +1899,13 @@ An error occurred when attempting remote activation in a target specified in generic method is used by compilers to implement the instantiation of types specified by type parameters. For example, in the following generic method, the implementation of `new T()` (`gcnew T()` in C++) uses the generic method. + The generic method is used by compilers to implement the instantiation of types specified by type parameters. For example, in the following generic method, the implementation of `new T()` uses the generic method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.activation.createinstance~~1/cpp/remarks.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Activator/CreateInstanceT/remarks.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.activation.createinstance~~1/fs/remarks.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.activation.createinstance~~1/vb/remarks.vb" id="Snippet1"::: - In general, there is no use for the generic method in application code, because the type must be known at compile time. If the type is known at compile time, normal instantiation syntax can be used (`new` operator in C#, `New` in Visual Basic, `gcnew` in C++). If the type is not known at compile time, you can call a non-generic overload of . + In general, there is no use for the generic method in application code, because the type must be known at compile time. If the type is known at compile time, normal instantiation syntax can be used (`new` operator in C#, `New` in Visual Basic). If the type is not known at compile time, you can call a non-generic overload of . There are no overloads of the generic method that take argument lists, because the non-generic overloads of already provide late-bound constructor resolution. @@ -2000,12 +1993,9 @@ Note: In .NET for Win For information about other exceptions that can be thrown by invoked methods, see the Exceptions section of the and methods. - - ## Examples The following code example demonstrates how to call the method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ActivatorX/cpp/ActivatorX.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Activator/Overview/ActivatorX.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/ActivatorX/fs/ActivatorX.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ActivatorX/VB/ActivatorX.vb" id="Snippet3"::: diff --git a/xml/System/ArgumentException.xml b/xml/System/ArgumentException.xml index a4b87cbb0ca..3fae15c7c2d 100644 --- a/xml/System/ArgumentException.xml +++ b/xml/System/ArgumentException.xml @@ -102,7 +102,6 @@ In F#, you can use the [invalidArg](/dotnet/fsharp/language-reference/exception- The following example demonstrates how to throw and catch an . It uses the [ArgumentException.GetType().Name](xref:System.Type.Name%2A) property to display the name of the exception object, and also uses the property to display the text of the exception message. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ArgumentException/cpp/argumentexception2.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/ArgumentException/Overview/argumentexception2.cs" interactive="try-dotnet" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/ArgumentException/FS/argumentexception2.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ArgumentException/vb/program2.vb" id="Snippet3"::: @@ -432,12 +431,9 @@ The following example demonstrates how to throw and catch an |The error message string.| ||The parameter name string.| - - ## Examples The following code example demonstrates how to call the constructor. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ArgumentException/cpp/ArgumentException.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/ArgumentException/Overview/argumentexception.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/ArgumentException/FS/argumentexception.fs" id="Snippet2"::: diff --git a/xml/System/Array.xml b/xml/System/Array.xml index 1918ee348d9..bbfb1b46648 100644 --- a/xml/System/Array.xml +++ b/xml/System/Array.xml @@ -129,14 +129,12 @@ The following code example shows how copies elements between an array of type integer and an array of type . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Array Example/CPP/source.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_Classic/classic Array Example/FS/source.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/Overview/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array Example/VB/source.vb" id="Snippet1"::: The following code example creates and initializes an and displays its properties and its elements. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Array Example/CPP/source3.cpp" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_Classic/classic Array Example/FS/source3.fs" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Array/Overview/source3.cs" interactive="try-dotnet-method" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array Example/VB/source3.vb" id="Snippet2"::: @@ -218,12 +216,9 @@ This method is an O(1) operation. - - ## Examples The following example wraps an array in a read-only . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Array.AsReadOnly/CPP/arrayasreadonly.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/AsReadOnlyT/arrayasreadonly.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Array.AsReadOnly/FS/arrayasreadonly.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Array.AsReadOnly/VB/arrayasreadonly.vb" id="Snippet1"::: @@ -320,14 +315,14 @@ Either `value` or every element of `array` must implement the interface, which is used for comparisons. The elements of `array` must already be sorted in increasing value according to the sort order defined by the implementation; otherwise, the result might be incorrect. > [!NOTE] -> If`value` does not implement the interface, the elements of `array` are not tested for before the search begins. An exception is thrown if the search encounters an element that does not implement . +> If`value` does not implement the interface, the elements of `array` are not tested for before the search begins. An exception is thrown if the search encounters an element that does not implement . Duplicate elements are allowed. If the contains more than one element equal to `value`, the method returns the index of only one of the occurrences, and not necessarily the first one. `null` can always be compared with any other reference type; therefore, comparisons with `null` do not generate an exception. > [!NOTE] -> For every element tested, `value` is passed to the appropriate implementation, even if `value` is `null`. That is, the implementation determines how a given element compares to `null`. +> For every element tested, `value` is passed to the appropriate implementation, even if `value` is `null`. That is, the implementation determines how a given element compares to `null`. This method is an O(log `n`) operation, where `n` is the of `array`. @@ -337,9 +332,8 @@ The following code example shows how to use to locate a specific object in an . > [!NOTE] -> The array is created with its elements in ascending sort order. The method requires the array to be sorted in ascending order. +> The array is created with its elements in ascending sort order. The method requires the array to be sorted in ascending order. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.BinarySearch Example/CPP/source.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_Classic/classic Array.BinarySearch Example/FS/source.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/BinarySearch/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.BinarySearch Example/VB/source.vb" id="Snippet1"::: @@ -442,14 +436,14 @@ If`comparer` is `null`, the comparison is done using the implementation provided by the element itself or by the specified value. The elements of `array` must already be sorted in increasing value according to the sort order defined by the implementation; otherwise, the result might be incorrect. > [!NOTE] -> If `comparer` is `null` and `value` does not implement the interface, the elements of `array` are not tested for before the search begins. An exception is thrown if the search encounters an element that does not implement . +> If `comparer` is `null` and `value` does not implement the interface, the elements of `array` are not tested for before the search begins. An exception is thrown if the search encounters an element that does not implement . Duplicate elements are allowed. If the contains more than one element equal to `value`, the method returns the index of only one of the occurrences, and not necessarily the first one. `null` can always be compared with any other reference type; therefore, comparisons with `null` do not generate an exception. > [!NOTE] -> For every element tested, `value` is passed to the appropriate implementation, even if `value` is `null`. That is, the implementation determines how a given element compares to `null`. +> For every element tested, `value` is passed to the appropriate implementation, even if `value` is `null`. That is, the implementation determines how a given element compares to `null`. This method is an O(log `n`) operation, where `n` is the of `array`. @@ -546,14 +540,14 @@ Either `value` or every element of `array` must implement the interface, which is used for comparisons. The elements of `array` must already be sorted in increasing value according to the sort order defined by the implementation; otherwise, the result might be incorrect. > [!NOTE] -> If `value` does not implement the interface, the elements of `array` are not tested for before the search begins. An exception is thrown if the search encounters an element that does not implement . +> If `value` does not implement the interface, the elements of `array` are not tested for before the search begins. An exception is thrown if the search encounters an element that does not implement . Duplicate elements are allowed. If the contains more than one element equal to `value`, the method returns the index of only one of the occurrences, and not necessarily the first one. `null` can always be compared with any other reference type; therefore, comparisons with `null` do not generate an exception. > [!NOTE] -> For every element tested, `value` is passed to the appropriate implementation, even if `value` is `null`. That is, the implementation determines how a given element compares to `null`. +> For every element tested, `value` is passed to the appropriate implementation, even if `value` is `null`. That is, the implementation determines how a given element compares to `null`. This method is an O(log `n`) operation, where `n` is `length`. @@ -673,14 +667,14 @@ If `comparer` is `null`, the comparison is done using the implementation provided by the element itself or by the specified value. The elements of `array` must already be sorted in increasing value according to the sort order defined by the implementation; otherwise, the result might be incorrect. > [!NOTE] -> If `comparer` is `null` and `value` does not implement the interface, the elements of `array` are not tested for before the search begins. An exception is thrown if the search encounters an element that does not implement . +> If `comparer` is `null` and `value` does not implement the interface, the elements of `array` are not tested for before the search begins. An exception is thrown if the search encounters an element that does not implement . Duplicate elements are allowed. If the contains more than one element equal to `value`, the method returns the index of only one of the occurrences, and not necessarily the first one. `null` can always be compared with any other reference type; therefore, comparisons with `null` do not generate an exception when using . > [!NOTE] -> For every element tested, `value` is passed to the appropriate implementation, even if `value` is `null`. That is, the implementation determines how a given element compares to `null`. +> For every element tested, `value` is passed to the appropriate implementation, even if `value` is `null`. That is, the implementation determines how a given element compares to `null`. This method is an O(log `n`) operation, where `n` is `length`. @@ -789,7 +783,7 @@ `null` can always be compared with any other reference type; therefore, comparisons with `null` do not generate an exception. > [!NOTE] -> For every element tested, `value` is passed to the appropriate implementation, even if `value` is `null`. That is, the implementation determines how a given element compares to `null`. +> For every element tested, `value` is passed to the appropriate implementation, even if `value` is `null`. That is, the implementation determines how a given element compares to `null`. This method is an O(log `n`) operation, where `n` is the of `array`. @@ -801,11 +795,10 @@ The array is displayed, sorted, and displayed again. Arrays must be sorted in order to use the method. > [!NOTE] -> The calls to the and generic methods do not look any different from calls to their nongeneric counterparts, because Visual Basic, F#, C#, and C++ infer the type of the generic type parameter from the type of the first argument. If you use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to examine the Microsoft intermediate language (MSIL), you can see that the generic methods are being called. +> The calls to the and generic methods do not look any different from calls to their nongeneric counterparts, because Visual Basic, F#, C#, and C++ infer the type of the generic type parameter from the type of the first argument. If you use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to examine the Microsoft intermediate language (MSIL), you can see that the generic methods are being called. - The generic method overload is then used to search for two strings, one that is not in the array and one that is. The array and the return value of the method are passed to the `ShowWhere` generic method (the `showWhere` function in the F# example), which displays the index value if the string is found, and otherwise the elements the search string would fall between if it were in the array. The index is negative if the string is not in the array, so the `ShowWhere` method takes the bitwise complement (the ~ operator in C# and Visual C++, the ~~~ operator in F#, `Xor`-1 in Visual Basic) to obtain the index of the first element in the list that is larger than the search string. + The generic method overload is then used to search for two strings, one that is not in the array and one that is. The array and the return value of the method are passed to the `ShowWhere` generic method (the `showWhere` function in the F# example), which displays the index value if the string is found, and otherwise the elements the search string would fall between if it were in the array. The index is negative if the string is not in the array, so the `ShowWhere` method takes the bitwise complement (the ~ operator in C#, the ~~~ operator in F#, `Xor`-1 in Visual Basic) to obtain the index of the first element in the list that is larger than the search string. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Array_SortSearch/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/BinarySearchT/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Array_SortSearch/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Array_SortSearch/vb/source.vb" id="Snippet1"::: @@ -914,32 +907,29 @@ If `comparer` is `null`, the comparison is done using the generic interface implementation provided by `T`. The elements of `array` must already be sorted in increasing value according to the sort order defined by the implementation; otherwise, the result might be incorrect. > [!NOTE] -> If `comparer` is `null` and `value` does not implement the generic interface, the elements of `array` are not tested for before the search begins. An exception is thrown if the search encounters an element that does not implement . +> If `comparer` is `null` and `value` does not implement the generic interface, the elements of `array` are not tested for before the search begins. An exception is thrown if the search encounters an element that does not implement . Duplicate elements are allowed. If the contains more than one element equal to `value`, the method returns the index of only one of the occurrences, and not necessarily the first one. `null` can always be compared with any other reference type; therefore, comparisons with `null` do not generate an exception. > [!NOTE] -> For every element tested, `value` is passed to the appropriate implementation, even if `value` is `null`. That is, the implementation determines how a given element compares to `null`. +> For every element tested, `value` is passed to the appropriate implementation, even if `value` is `null`. That is, the implementation determines how a given element compares to `null`. This method is an O(log `n`) operation, where `n` is the of `array`. - - ## Examples The following example demonstrates the generic method overload and the generic method overload. - The code example defines an alternative comparer for strings, named `ReverseCompare`, which implements the `IComparer` (`IComparer(Of String)` in Visual Basic, `IComparer` in Visual C++) generic interface. The comparer calls the method, reversing the order of the comparands so that the strings sort high-to-low instead of low-to-high. + The code example defines an alternative comparer for strings, named `ReverseCompare`, which implements the `IComparer` (`IComparer(Of String)` in Visual Basic) generic interface. The comparer calls the method, reversing the order of the comparands so that the strings sort high-to-low instead of low-to-high. The array is displayed, sorted, and displayed again. Arrays must be sorted in order to use the method. > [!NOTE] -> The calls to the and generic methods do not look any different from calls to their nongeneric counterparts, because Visual Basic, C#, and C++ infer the type of the generic type parameter from the type of the first argument. If you use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to examine the Microsoft intermediate language (MSIL), you can see that the generic methods are being called. +> The calls to the and generic methods do not look any different from calls to their nongeneric counterparts, because Visual Basic, C#, and C++ infer the type of the generic type parameter from the type of the first argument. If you use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to examine the Microsoft intermediate language (MSIL), you can see that the generic methods are being called. - The generic method overload is then used to search for two strings, one that is not in the array and one that is. The array and the return value of the method are passed to the `ShowWhere` generic method (the `showWhere` function in the F# example), which displays the index value if the string is found, and otherwise the elements the search string would fall between if it were in the array. The index is negative if the string is not n the array, so the `ShowWhere` method takes the bitwise complement (the ~ operator in C# and Visual C++, the ~~~ operator in F#, `Xor` -1 in Visual Basic) to obtain the index of the first element in the list that is larger than the search string. + The generic method overload is then used to search for two strings, one that is not in the array and one that is. The array and the return value of the method are passed to the `ShowWhere` generic method (the `showWhere` function in the F# example), which displays the index value if the string is found, and otherwise the elements the search string would fall between if it were in the array. The index is negative if the string is not n the array, so the `ShowWhere` method takes the bitwise complement (the ~ operator in C#, the ~~~ operator in F#, `Xor` -1 in Visual Basic) to obtain the index of the first element in the list that is larger than the search string. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Array_SortSearchComparer/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/BinarySearchT/source1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Array_SortSearchComparer/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Array_SortSearchComparer/vb/source.vb" id="Snippet1"::: @@ -1041,7 +1031,7 @@ `null` can always be compared with any other reference type; therefore, comparisons with `null` do not generate an exception. > [!NOTE] -> For every element tested, `value` is passed to the appropriate implementation, even if `value` is `null`. That is, the implementation determines how a given element compares to `null`. +> For every element tested, `value` is passed to the appropriate implementation, even if `value` is `null`. That is, the implementation determines how a given element compares to `null`. This method is an O(log `n`) operation, where `n` is `length`. @@ -1173,7 +1163,7 @@ `null` can always be compared with any other reference type; therefore, comparisons with `null` do not generate an exception when using . > [!NOTE] -> For every element tested, `value` is passed to the appropriate implementation, even if `value` is `null`. That is, the implementation determines how a given element compares to `null`. +> For every element tested, `value` is passed to the appropriate implementation, even if `value` is `null`. That is, the implementation determines how a given element compares to `null`. This method is an O(log `n`) operation, where `n` is `length`. @@ -1418,7 +1408,6 @@ ## Examples The following code example clones a array and demonstrates the behavior of a shallow copy. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Array.Clone/CPP/arrayclone.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/Clone/arrayclone.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Array.Clone/FS/arrayclone.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Array.Clone/VB/arrayclone.vb" id="Snippet1"::: @@ -1624,7 +1613,6 @@ ## Examples The following code example defines a method named `PointFToPoint` that converts a structure to a structure. The example then creates an array 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. In the F# example, the `pointFToPoint` function is implicitly casted to the `Converter` delegate. Both lists are displayed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Array_ConvertAll/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/ConvertAllTInput,TOutput/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Array_ConvertAll/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Array_ConvertAll/vb/source.vb" id="Snippet1"::: @@ -1657,7 +1645,6 @@ ## Examples The following code example shows how to copy from one of type to another of type integer. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Copy1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_Classic/classic Array.Copy1 Example/FS/source.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/Copy/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.Copy1 Example/VB/source.vb" id="Snippet1"::: @@ -1741,23 +1728,23 @@ The arrays can be reference-type arrays or value-type arrays. Type downcasting is performed, as required. -- When copying from a reference-type array to a value-type array, each element is unboxed and then copied. When copying from a value-type array to a reference-type array, each element is boxed and then copied. +- When copying from a reference-type array to a value-type array, each element is unboxed and then copied. When copying from a value-type array to a reference-type array, each element is boxed and then copied. -- When copying from a reference-type or value-type array to an array, an is created to hold each value or reference and then copied. When copying from an array to a reference-type or value-type array and the assignment is not possible, an is thrown. +- When copying from a reference-type or value-type array to an array, an is created to hold each value or reference and then copied. When copying from an array to a reference-type or value-type array and the assignment is not possible, an is thrown. -- If `sourceArray` and `destinationArray` are both reference-type arrays or are both arrays of type , a shallow copy is performed. A shallow copy of an is a new containing references to the same elements as the original . The elements themselves or anything referenced by the elements are not copied. In contrast, a deep copy of an copies the elements and everything directly or indirectly referenced by the elements. +- If `sourceArray` and `destinationArray` are both reference-type arrays or are both arrays of type , a shallow copy is performed. A shallow copy of an is a new containing references to the same elements as the original . The elements themselves or anything referenced by the elements are not copied. In contrast, a deep copy of an copies the elements and everything directly or indirectly referenced by the elements. An is thrown if the arrays are of incompatible types. Type compatibility is defined as follows: -- A type is compatible with itself. +- A type is compatible with itself. -- A value type is compatible with and with an interface type implemented by that value type. A value type is considered connected to an interface only if it implements that interface directly. Disconnected types are not compatible. +- A value type is compatible with and with an interface type implemented by that value type. A value type is considered connected to an interface only if it implements that interface directly. Disconnected types are not compatible. -- Two intrinsic (predefined) value types are compatible if copying from the source type to the destination type is a widening conversion. A widening conversion never loses information, whereas a narrowing conversion can lose information. For example, converting a 32-bit signed integer to a 64-bit signed integer is a widening conversion, and converting a 64-bit signed integer to a 32-bit signed integer is a narrowing conversion. For more information about conversions, see . +- Two intrinsic (predefined) value types are compatible if copying from the source type to the destination type is a widening conversion. A widening conversion never loses information, whereas a narrowing conversion can lose information. For example, converting a 32-bit signed integer to a 64-bit signed integer is a widening conversion, and converting a 64-bit signed integer to a 32-bit signed integer is a narrowing conversion. For more information about conversions, see . -- A nonintrinsic (user-defined) value type is compatible only with itself. +- A nonintrinsic (user-defined) value type is compatible only with itself. -- Enumerations have an implicit conversion to and to their underlying type. +- Enumerations have an implicit conversion to and to their underlying type. If every element in `sourceArray` requires a downcast (for example, from a base class to a derived class or from an interface to an object) and one or more elements cannot be cast to the corresponding type in `destinationArray`, an is thrown. @@ -1857,23 +1844,23 @@ The arrays can be reference-type arrays or value-type arrays. Type downcasting is performed, as required. -- When copying from a reference-type array to a value-type array, each element is unboxed and then copied. When copying from a value-type array to a reference-type array, each element is boxed and then copied. +- When copying from a reference-type array to a value-type array, each element is unboxed and then copied. When copying from a value-type array to a reference-type array, each element is boxed and then copied. -- When copying from a reference-type or value-type array to an array, an is created to hold each value or reference and then copied. When copying from an array to a reference-type or value-type array and the assignment is not possible, an is thrown. +- When copying from a reference-type or value-type array to an array, an is created to hold each value or reference and then copied. When copying from an array to a reference-type or value-type array and the assignment is not possible, an is thrown. -- If `sourceArray` and `destinationArray` are both reference-type arrays or are both arrays of type , a shallow copy is performed. A shallow copy of an is a new containing references to the same elements as the original . The elements themselves or anything referenced by the elements are not copied. In contrast, a deep copy of an copies the elements and everything directly or indirectly referenced by the elements. +- If `sourceArray` and `destinationArray` are both reference-type arrays or are both arrays of type , a shallow copy is performed. A shallow copy of an is a new containing references to the same elements as the original . The elements themselves or anything referenced by the elements are not copied. In contrast, a deep copy of an copies the elements and everything directly or indirectly referenced by the elements. An is thrown if the arrays are of incompatible types. Type compatibility is defined as follows: -- A type is compatible with itself. +- A type is compatible with itself. -- A value type is compatible with and with an interface type implemented by that value type. A value type is considered connected to an interface only if it implements that interface directly. Disconnected types are not compatible. +- A value type is compatible with and with an interface type implemented by that value type. A value type is considered connected to an interface only if it implements that interface directly. Disconnected types are not compatible. -- Two intrinsic (predefined) value types are compatible if copying from the source type to the destination type is a widening conversion. A widening conversion never loses information, whereas a narrowing conversion can lose information. For example, converting a 32-bit signed integer to a 64-bit signed integer is a widening conversion, and converting a 64-bit signed integer to a 32-bit signed integer is a narrowing conversion. For more information about conversions, see . +- Two intrinsic (predefined) value types are compatible if copying from the source type to the destination type is a widening conversion. A widening conversion never loses information, whereas a narrowing conversion can lose information. For example, converting a 32-bit signed integer to a 64-bit signed integer is a widening conversion, and converting a 64-bit signed integer to a 32-bit signed integer is a narrowing conversion. For more information about conversions, see . -- A nonintrinsic (user-defined) value type is compatible only with itself. +- A nonintrinsic (user-defined) value type is compatible only with itself. -- Enumerations have an implicit conversion to and to their underlying type. +- Enumerations have an implicit conversion to and to their underlying type. If every element in `sourceArray` requires a downcast (for example, from a base class to a derived class or from an interface to an object) and one or more elements cannot be cast to the corresponding type in `destinationArray`, an is thrown. @@ -1985,23 +1972,23 @@ The arrays can be reference-type arrays or value-type arrays. Type downcasting is performed, as required. -- When copying from a reference-type array to a value-type array, each element is unboxed and then copied. When copying from a value-type array to a reference-type array, each element is boxed and then copied. +- When copying from a reference-type array to a value-type array, each element is unboxed and then copied. When copying from a value-type array to a reference-type array, each element is boxed and then copied. -- When copying from a reference-type or value-type array to an array, an is created to hold each value or reference and then copied. When copying from an array to a reference-type or value-type array and the assignment is not possible, an is thrown. +- When copying from a reference-type or value-type array to an array, an is created to hold each value or reference and then copied. When copying from an array to a reference-type or value-type array and the assignment is not possible, an is thrown. -- If `sourceArray` and `destinationArray` are both reference-type arrays or are both arrays of type , a shallow copy is performed. A shallow copy of an is a new containing references to the same elements as the original . The elements themselves or anything referenced by the elements are not copied. In contrast, a deep copy of an copies the elements and everything directly or indirectly referenced by the elements. +- If `sourceArray` and `destinationArray` are both reference-type arrays or are both arrays of type , a shallow copy is performed. A shallow copy of an is a new containing references to the same elements as the original . The elements themselves or anything referenced by the elements are not copied. In contrast, a deep copy of an copies the elements and everything directly or indirectly referenced by the elements. An is thrown if the arrays are of incompatible types. Type compatibility is defined as follows: -- A type is compatible with itself. +- A type is compatible with itself. -- A value type is compatible with and with an interface type implemented by that value type. A value type is considered connected to an interface only if it implements that interface directly. Disconnected types are not compatible. +- A value type is compatible with and with an interface type implemented by that value type. A value type is considered connected to an interface only if it implements that interface directly. Disconnected types are not compatible. -- Two intrinsic (predefined) value types are compatible if copying from the source type to the destination type is a widening conversion. A widening conversion never loses information, whereas a narrowing conversion can lose information. For example, converting a 32-bit signed integer to a 64-bit signed integer is a widening conversion, and converting a 64-bit signed integer to a 32-bit signed integer is a narrowing conversion. For more information about conversions, see . +- Two intrinsic (predefined) value types are compatible if copying from the source type to the destination type is a widening conversion. A widening conversion never loses information, whereas a narrowing conversion can lose information. For example, converting a 32-bit signed integer to a 64-bit signed integer is a widening conversion, and converting a 64-bit signed integer to a 32-bit signed integer is a narrowing conversion. For more information about conversions, see . -- A nonintrinsic (user-defined) value type is compatible only with itself. +- A nonintrinsic (user-defined) value type is compatible only with itself. -- Enumerations have an implicit conversion to and to their underlying type. +- Enumerations have an implicit conversion to and to their underlying type. If every element in `sourceArray` requires a downcast (for example, from a base class to a derived class or from an interface to an object) and one or more elements cannot be cast to the corresponding type in `destinationArray`, an is thrown. @@ -2113,23 +2100,23 @@ The arrays can be reference-type arrays or value-type arrays. Type downcasting is performed, as required. -- When copying from a reference-type array to a value-type array, each element is unboxed and then copied. When copying from a value-type array to a reference-type array, each element is boxed and then copied. +- When copying from a reference-type array to a value-type array, each element is unboxed and then copied. When copying from a value-type array to a reference-type array, each element is boxed and then copied. -- When copying from a reference-type or value-type array to an array, an is created to hold each value or reference and then copied. When copying from an array to a reference-type or value-type array and the assignment is not possible, an is thrown. +- When copying from a reference-type or value-type array to an array, an is created to hold each value or reference and then copied. When copying from an array to a reference-type or value-type array and the assignment is not possible, an is thrown. -- If `sourceArray` and `destinationArray` are both reference-type arrays or are both arrays of type , a shallow copy is performed. A shallow copy of an is a new containing references to the same elements as the original . The elements themselves or anything referenced by the elements are not copied. In contrast, a deep copy of an copies the elements and everything directly or indirectly referenced by the elements. +- If `sourceArray` and `destinationArray` are both reference-type arrays or are both arrays of type , a shallow copy is performed. A shallow copy of an is a new containing references to the same elements as the original . The elements themselves or anything referenced by the elements are not copied. In contrast, a deep copy of an copies the elements and everything directly or indirectly referenced by the elements. An is thrown if the arrays are of incompatible types. Type compatibility is defined as follows: -- A type is compatible with itself. +- A type is compatible with itself. -- A value type is compatible with and with an interface type implemented by that value type. A value type is considered connected to an interface only if it implements that interface directly. Disconnected types are not compatible. +- A value type is compatible with and with an interface type implemented by that value type. A value type is considered connected to an interface only if it implements that interface directly. Disconnected types are not compatible. -- Two intrinsic (predefined) value types are compatible if copying from the source type to the destination type is a widening conversion. A widening conversion never loses information, whereas a narrowing conversion can lose information. For example, converting a 32-bit signed integer to a 64-bit signed integer is a widening conversion, and converting a 64-bit signed integer to a 32-bit signed integer is a narrowing conversion. For more information about conversions, see . +- Two intrinsic (predefined) value types are compatible if copying from the source type to the destination type is a widening conversion. A widening conversion never loses information, whereas a narrowing conversion can lose information. For example, converting a 32-bit signed integer to a 64-bit signed integer is a widening conversion, and converting a 64-bit signed integer to a 32-bit signed integer is a narrowing conversion. For more information about conversions, see . -- A nonintrinsic (user-defined) value type is compatible only with itself. +- A nonintrinsic (user-defined) value type is compatible only with itself. -- Enumerations have an implicit conversion to and to their underlying type. +- Enumerations have an implicit conversion to and to their underlying type. If every element in `sourceArray` requires a downcast (for example, from a base class to a derived class or from an interface to an object) and one or more elements cannot be cast to the corresponding type in `destinationArray`, an is thrown. @@ -2187,14 +2174,12 @@ ## Examples The following code example shows how to copy an to another . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/FS/source.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/CopyTo/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/VB/source.vb" id="Snippet1"::: The following code example shows how to copy an to another with a nonzero lower bound. Note that the entire source is copied, including empty elements that overwrite existing elements in the target . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source2.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/FS/source2.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/CopyTo/source2.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/VB/source2.vb" id="Snippet1"::: @@ -2453,7 +2438,6 @@ ## Examples The following code example shows how to create and initialize a one-dimensional . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance Example/CPP/source.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_Classic/classic Array.CreateInstance Example/FS/source.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/CreateInstance/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.CreateInstance Example/VB/source.vb" id="Snippet1"::: @@ -2556,7 +2540,6 @@ ## Examples The following code example shows how to create and initialize a multidimensional . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance3 Example/CPP/source.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_Classic/classic Array.CreateInstance3 Example/FS/source.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/CreateInstance/source3.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.CreateInstance3 Example/VB/source.vb" id="Snippet1"::: @@ -2658,7 +2641,6 @@ ## Examples The following code example shows how to create and initialize a multidimensional . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance3 Example/CPP/source.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_Classic/classic Array.CreateInstance3 Example/FS/source.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/CreateInstance/source3.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.CreateInstance3 Example/VB/source.vb" id="Snippet1"::: @@ -2753,7 +2735,6 @@ ## Examples The following code example shows how to create and initialize a two-dimensional . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_Classic/classic Array.CreateInstance1 Example/FS/source.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/CreateInstance/source1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.CreateInstance1 Example/VB/source.vb" id="Snippet1"::: @@ -2860,7 +2841,6 @@ ## Examples The following code example shows how to create and initialize a multidimensional with specified lower bounds. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance4 Example/CPP/source.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_Classic/classic Array.CreateInstance4 Example/FS/source.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/CreateInstance/source4.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/csharp/System/Array/CreateInstance/source4.cs" id="Snippet1"::: @@ -2969,7 +2949,6 @@ ## Examples The following code example shows how to create and initialize a three-dimensional . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance2 Example/CPP/source.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_Classic/classic Array.CreateInstance2 Example/FS/source.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/CreateInstance/source2.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.CreateInstance2 Example/VB/source.vb" id="Snippet1"::: @@ -3285,7 +3264,7 @@ The is a delegate to a method that returns `true` if the object passed to it matches the conditions defined in the delegate. The elements of `array` are individually passed to the , and processing is stopped when a match is found. > [!NOTE] -> In C# and Visual Basic, it is not necessary to create the delegate explicitly. These languages infer the correct delegate from context and create it automatically. In F#, functions and lambda expressions are implicitly converted. +> In C# and Visual Basic, it is not necessary to create the delegate explicitly. These languages infer the correct delegate from context and create it automatically. In F#, functions and lambda expressions are implicitly converted. This method is an O(`n`) operation, where `n` is the of `array`. @@ -3512,7 +3491,7 @@ The following example uses a delegate with the generic method to search an array of structures. The method the delegate represents, `ProductGT10`, returns `true` if the product of the X and Y fields is greater than 100,000. The method calls the delegate for each element of the array, returning the first point that meets the test condition. > [!NOTE] -> Visual Basic, C#, and F# users do not have to create the delegate explicitly or specify the type argument of the generic method. The compilers determine the necessary types from the method arguments you supply. +> Visual Basic, C#, and F# users do not have to create the delegate explicitly or specify the type argument of the generic method. The compilers determine the necessary types from the method arguments you supply. :::code language="csharp" source="~/snippets/csharp/System/Array/FindT/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.array.find/fs/source.fs" id="Snippet1"::: @@ -3623,13 +3602,12 @@ The generic method traverses the array from the beginning, passing each element in turn to the `EndsWithSaurus` method. The search stops when the `EndsWithSaurus` method returns `true` for the element "Amargasaurus". > [!NOTE] -> In C#, F#, 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. +> In C#, F#, 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. The generic method is used to search the array backward from the end. It finds the element "Dilophosaurus" at position 5. The generic method is used to return an array containing all the elements that end in "saurus". The elements are displayed. The code example also demonstrates the and generic methods. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Array_FindEtAl/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/FindAllT/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Array_FindEtAl/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Array_FindEtAl/vb/source.vb" id="Snippet1"::: @@ -3671,11 +3649,10 @@ The method overload traverses the array from the beginning, passing each element in turn to the `EndsWithSaurus` method. The search stops when the `EndsWithSaurus` method returns `true` for the element at position 1. > [!NOTE] -> In C#, F#, 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. +> In C#, F#, 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. The method overload is used to search the array beginning at position 2 and continuing to the end of the array. It finds the element at position 5. Finally, the method overload is used to search the range of three elements beginning at position 2. It returns -1 because there are no dinosaur names in that range that end with "saurus". - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Array_FindIndex/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/FindIndexT/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Array_FindIndex/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Array_FindIndex/vb/source.vb" id="Snippet1"::: @@ -4035,13 +4012,12 @@ The generic method traverses the array from the beginning, passing each element in turn to the `EndsWithSaurus` method. The search stops when the `EndsWithSaurus` method returns `true` for the element "Amargasaurus". > [!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. +> 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. The generic method is used to search the array backward from the end. It finds the element "Dilophosaurus" at position 5. The generic method is used to return an array containing all the elements that end in "saurus". The elements are displayed. The code example also demonstrates the and generic methods. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Array_FindEtAl/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/FindAllT/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Array_FindEtAl/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Array_FindEtAl/vb/source.vb" id="Snippet1"::: @@ -4083,11 +4059,10 @@ The method overload traverses the array backward from the end, passing each element in turn to the `EndsWithSaurus` method. The search stops when the `EndsWithSaurus` method returns `true` for the element at position 5. > [!NOTE] -> In C#, F# 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. +> In C#, F# 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. The method overload is used to search the array beginning at position 4 and continuing backward to the beginning of the array. It finds the element at position 1. Finally, the method overload is used to search the range of three elements beginning at position 4 and working backward (that is, elements 4, 3, and 2). It returns -1 because there are no dinosaur names in that range that end with "saurus". - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Array_FindLastIndex/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/FindLastIndexT/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Array_FindLastIndex/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Array_FindLastIndex/vb/source.vb" id="Snippet1"::: @@ -4438,7 +4413,6 @@ ## Examples The following example shows how to use to display the squares of each element in an integer array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.array.foreach/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/ForEachT/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.array.foreach/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.array.foreach/vb/source.vb" id="Snippet1"::: @@ -4507,7 +4481,7 @@ ## Remarks - The `foreach` statement of the C# language (`for each` in C++, `For Each` in Visual Basic) hides the complexity of the enumerators. Therefore, using `foreach` is recommended, instead of directly manipulating the enumerator. + 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. @@ -4528,7 +4502,6 @@ ## Examples The following code example shows how to use to list the elements of an array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Array_GetEnumerator/CPP/array_getenumerator.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/GetEnumerator/array_getenumerator.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Array_GetEnumerator/FS/array_getenumerator.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Array_GetEnumerator/VB/array_getenumerator.vb" id="Snippet1"::: @@ -4602,7 +4575,6 @@ ## Examples The following example shows how to use to display the dimensions of two arrays with different ranks. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.array.getlength/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/GetLength/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.array.getlength/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.array.getlength/vb/source.vb" id="Snippet1"::: @@ -4762,7 +4734,6 @@ ## Examples The following example uses the and methods to display the bounds of a one-dimensional and two-dimensional array and to display the values of their array elements. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.array.getupperbound/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/GetLowerBound/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.array.getupperbound/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.array.getupperbound/vb/source.vb" id="Snippet1"::: @@ -4848,7 +4819,6 @@ ## Examples The following example uses the and methods to display the bounds of a one-dimensional and two-dimensional array and to display the values of their array elements. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.array.getupperbound/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/GetLowerBound/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.array.getupperbound/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.array.getupperbound/vb/source.vb" id="Snippet1"::: @@ -4880,7 +4850,6 @@ ## Examples The following code example demonstrates how to set and get a specific value in a one-dimensional or multidimensional array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Array_GetSetValue/CPP/array_getsetvalue.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/GetValue/array_getsetvalue.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Array_GetSetValue/FS/array_getsetvalue.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Array_GetSetValue/VB/array_getsetvalue.vb" id="Snippet1"::: @@ -5558,13 +5527,12 @@ ## Examples The example calls the following three overloads of the method to find the index of a string in a string array: -- , to determine the first occurrence of the string "the" in a string array. +- , to determine the first occurrence of the string "the" in a string array. -- , to determine the first occurrence of the string "the" in the fourth to the last elements of a string array. +- , to determine the first occurrence of the string "the" in the fourth to the last elements of a string array. -- , to determine the first occurrence of the string "the" in a string array from the element that follows the last successful match to the end of the array. +- , to determine the first occurrence of the string "the" in a string array from the element that follows the last successful match to the end of the array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.IndexOf Example/CPP/source.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_Classic/classic Array.IndexOf Example/FS/source.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/IndexOf/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.IndexOf Example/VB/source.vb" id="Snippet1"::: @@ -5659,13 +5627,12 @@ ## Examples The example calls the following three overloads of the method to find the index of a string in a string array: -- , to determine the first occurrence of the string "the" in a string array. +- , to determine the first occurrence of the string "the" in a string array. -- , to determine the first occurrence of the string "the" in the fourth to the last elements of a string array. +- , to determine the first occurrence of the string "the" in the fourth to the last elements of a string array. -- , to determine the first occurrence of the string "the" in a string array from the element that follows the last successful match to the end of the array. +- , to determine the first occurrence of the string "the" in a string array from the element that follows the last successful match to the end of the array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.IndexOf Example/CPP/source.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_Classic/classic Array.IndexOf Example/FS/source.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/IndexOf/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.IndexOf Example/VB/source.vb" id="Snippet1"::: @@ -5769,13 +5736,12 @@ ## Examples The example calls the following three overloads of the method to find the index of a string in a string array: -- , to determine the first occurrence of the string "the" in a string array. +- , to determine the first occurrence of the string "the" in a string array. -- , to determine the first occurrence of the string "the" in the fourth to the last elements of a string array. +- , to determine the first occurrence of the string "the" in the fourth to the last elements of a string array. -- , to determine the first occurrence of the string "the" in a string array from the element that follows the last successful match to the end of the array. To determine the value of the `count` argument, it subtracts the upper bound of the array from the starting index and adds one. +- , to determine the first occurrence of the string "the" in a string array from the element that follows the last successful match to the end of the array. To determine the value of the `count` argument, it subtracts the upper bound of the array from the starting index and adds one. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.IndexOf Example/CPP/source.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_Classic/classic Array.IndexOf Example/FS/source.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/IndexOf/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.IndexOf Example/VB/source.vb" id="Snippet1"::: @@ -5871,7 +5837,6 @@ ## Examples The following example demonstrates all three generic overloads of the method. An array of strings is created, with one entry that appears twice, at index location 0 and index location 5. The method overload searches the array from the beginning, and finds the first occurrence of the string. The method overload is used to search the array beginning with index location 3 and continuing to the end of the array, 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/Array_IndexOf/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/IndexOfT/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Array_IndexOf/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Array_IndexOf/vb/source.vb" id="Snippet1"::: @@ -5959,7 +5924,6 @@ ## Examples The following example demonstrates all three generic overloads of the method. An array of strings is created, with one entry that appears twice, at index location 0 and index location 5. The method overload searches the array from the beginning, and finds the first occurrence of the string. The method overload is used to search the array beginning with index location 3 and continuing to the end of the array, 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/Array_IndexOf/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/IndexOfT/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Array_IndexOf/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Array_IndexOf/vb/source.vb" id="Snippet1"::: @@ -6051,7 +6015,6 @@ ## Examples The following example demonstrates all three generic overloads of the method. An array of strings is created, with one entry that appears twice, at index location 0 and index location 5. The method overload searches the array from the beginning, and finds the first occurrence of the string. The method overload is used to search the array beginning with index location 3 and continuing to the end of the array, 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/Array_IndexOf/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/IndexOfT/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Array_IndexOf/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Array_IndexOf/vb/source.vb" id="Snippet1"::: @@ -6324,7 +6287,6 @@ ## Examples The following code example shows how to lock an array during the entire enumeration by using the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Array.SyncRoot/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/IsSynchronized/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Array.SyncRoot/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Array.SyncRoot/vb/source.vb" id="Snippet1"::: @@ -6430,7 +6392,6 @@ ## Examples The following code example shows how to determine the index of the last occurrence of a specified element in an array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.LastIndexOf Example/CPP/source.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_Classic/classic Array.LastIndexOf Example/FS/source.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/LastIndexOf/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.LastIndexOf Example/VB/source.vb" id="Snippet1"::: @@ -6526,7 +6487,6 @@ ## Examples The following code example shows how to determine the index of the last occurrence of a specified element in an array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.LastIndexOf Example/CPP/source.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_Classic/classic Array.LastIndexOf Example/FS/source.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/LastIndexOf/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.LastIndexOf Example/VB/source.vb" id="Snippet1"::: @@ -6630,7 +6590,6 @@ ## Examples The following code example shows how to determine the index of the last occurrence of a specified element in an array. Note that the method is a backward search; therefore, `count` must be less than or equal to (`startIndex` minus the lower bound of the array plus 1). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.LastIndexOf Example/CPP/source.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_Classic/classic Array.LastIndexOf Example/FS/source.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/LastIndexOf/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.LastIndexOf Example/VB/source.vb" id="Snippet1"::: @@ -6728,7 +6687,6 @@ ## Examples The following code example demonstrates all three generic overloads of the method. An array of strings is created, with one entry that appears twice, at index location 0 and index location 5. The method overload searches the entire array from the end, and finds the second occurrence of the string. The method overload is used to search the array backward beginning with index location 3 and continuing to the beginning of the array, and finds the first occurrence of the string. 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/Array_LastIndexOf/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/LastIndexOfT/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Array_LastIndexOf/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Array_LastIndexOf/vb/source.vb" id="Snippet1"::: @@ -6816,7 +6774,6 @@ ## Examples The following code example demonstrates all three generic overloads of the method. An array of strings is created, with one entry that appears twice, at index location 0 and index location 5. The method overload searches the entire array from the end, and finds the second occurrence of the string. The method overload is used to search the array backward beginning with index location 3 and continuing to the beginning of the array, and finds the first occurrence of the string. 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/Array_LastIndexOf/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/LastIndexOfT/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Array_LastIndexOf/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Array_LastIndexOf/vb/source.vb" id="Snippet1"::: @@ -6908,7 +6865,6 @@ ## Examples The following code example demonstrates all three generic overloads of the method. An array of strings is created, with one entry that appears twice, at index location 0 and index location 5. The method overload searches the entire array from the end, and finds the second occurrence of the string. The method overload is used to search the array backward beginning with index location 3 and continuing to the beginning of the array, and finds the first occurrence of the string. 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/Array_LastIndexOf/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/LastIndexOfT/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Array_LastIndexOf/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Array_LastIndexOf/vb/source.vb" id="Snippet1"::: @@ -7299,7 +7255,6 @@ int[,,] TDArray = new int[1,1,1]; ## Examples The following example shows how resizing affects the array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Array.Resize/CPP/System.Array.Resize.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/ResizeT/arrayresize.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Array.Resize/FS/arrayresize.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Array.Resize/VB/arrayresize.vb" id="Snippet1"::: @@ -7395,7 +7350,6 @@ int[,,] TDArray = new int[1,1,1]; ## Examples The following code example shows how to reverse the sort of the values in an . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Reverse Example/CPP/source.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_Classic/classic Array.Reverse Example/FS/source.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/Reverse/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.Reverse Example/VB/source.vb" id="Snippet1"::: @@ -7482,7 +7436,6 @@ int[,,] TDArray = new int[1,1,1]; ## Examples The following code example shows how to reverse the sort of the values in a range of elements in an . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Reverse1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_Classic/classic Array.Reverse1 Example/FS/source.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/Reverse/source1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Array.Reverse1 Example/VB/source.vb" id="Snippet1"::: @@ -7637,7 +7590,6 @@ int[,,] TDArray = new int[1,1,1]; ## Examples The following code example demonstrates how to set and get a specific value in a one-dimensional or multidimensional array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Array_GetSetValue/CPP/array_getsetvalue.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/GetValue/array_getsetvalue.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Array_GetSetValue/FS/array_getsetvalue.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Array_GetSetValue/VB/array_getsetvalue.vb" id="Snippet1"::: @@ -7709,7 +7661,7 @@ int[,,] TDArray = new int[1,1,1]; This method is an O(1) operation. > [!NOTE] -> If is used to assign `null` to an element of an array of value types, all fields of the element are initialized to zero. The value of the element is not a null reference, and cannot be found by searching for a null reference. +> If is used to assign `null` to an element of an array of value types, all fields of the element are initialized to zero. The value of the element is not a null reference, and cannot be found by searching for a null reference. @@ -7806,7 +7758,7 @@ int[,,] TDArray = new int[1,1,1]; This method is an O(1) operation. > [!NOTE] -> If is used to assign `null` to an element of an array of value types, all fields of the element are initialized to zero. The value of the element is not a null reference, and cannot be found by searching for a null reference. +> If is used to assign `null` to an element of an array of value types, all fields of the element are initialized to zero. The value of the element is not a null reference, and cannot be found by searching for a null reference. @@ -7884,7 +7836,7 @@ int[,,] TDArray = new int[1,1,1]; This method is an O(1) operation. > [!NOTE] -> If is used to assign `null` to an element of an array of value types, all fields of the element are initialized to zero. The value of the element is not a null reference, and cannot be found by searching for a null reference. +> If is used to assign `null` to an element of an array of value types, all fields of the element are initialized to zero. The value of the element is not a null reference, and cannot be found by searching for a null reference. @@ -7977,7 +7929,7 @@ int[,,] TDArray = new int[1,1,1]; This method is an O(1) operation. > [!NOTE] -> If is used to assign `null` to an element of an array of value types, all fields of the element are initialized to zero. The value of the element is not a null reference, and cannot be found by searching for a null reference. +> If is used to assign `null` to an element of an array of value types, all fields of the element are initialized to zero. The value of the element is not a null reference, and cannot be found by searching for a null reference. @@ -8057,7 +8009,7 @@ int[,,] TDArray = new int[1,1,1]; This method is an O(1) operation. > [!NOTE] -> If is used to assign `null` to an element of an array of value types, all fields of the element are initialized to zero. The value of the element is not a null reference, and cannot be found by searching for a null reference. +> If is used to assign `null` to an element of an array of value types, all fields of the element are initialized to zero. The value of the element is not a null reference, and cannot be found by searching for a null reference. @@ -8135,7 +8087,7 @@ int[,,] TDArray = new int[1,1,1]; This method is an O(1) operation. > [!NOTE] -> If is used to assign `null` to an element of an array of value types, all fields of the element are initialized to zero. The value of the element is not a null reference, and cannot be found by searching for a null reference. +> If is used to assign `null` to an element of an array of value types, all fields of the element are initialized to zero. The value of the element is not a null reference, and cannot be found by searching for a null reference. @@ -8215,7 +8167,7 @@ int[,,] TDArray = new int[1,1,1]; This method is an O(1) operation. > [!NOTE] -> If is used to assign `null` to an element of an array of value types, all fields of the element are initialized to zero. The value of the element is not a null reference, and cannot be found by searching for a null reference. +> If is used to assign `null` to an element of an array of value types, all fields of the element are initialized to zero. The value of the element is not a null reference, and cannot be found by searching for a null reference. ]]> @@ -8295,7 +8247,7 @@ int[,,] TDArray = new int[1,1,1]; This method is an O(1) operation. > [!NOTE] -> If is used to assign `null` to an element of an array of value types, all fields of the element are initialized to zero. The value of the element is not a null reference, and cannot be found by searching for a null reference. +> If is used to assign `null` to an element of an array of value types, all fields of the element are initialized to zero. The value of the element is not a null reference, and cannot be found by searching for a null reference. @@ -8385,11 +8337,11 @@ int[,,] TDArray = new int[1,1,1]; This method uses the introspective sort ([introsort](https://en.wikipedia.org/wiki/Introsort)) algorithm as follows: -- If the partition size is less than or equal to 16 elements, it uses an [insertion sort](https://en.wikipedia.org/wiki/Insertion_sort) algorithm. +- If the partition size is less than or equal to 16 elements, it uses an [insertion sort](https://en.wikipedia.org/wiki/Insertion_sort) algorithm. -- If the number of partitions exceeds 2 * LogN, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. +- If the number of partitions exceeds 2 * LogN, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. -- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. +- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal. @@ -8400,7 +8352,6 @@ int[,,] TDArray = new int[1,1,1]; ## 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. Note that the result might vary depending on the current . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Array.Sort/CPP/arraysort.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/Sort/arraysort.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Array.Sort/FS/arraysort.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Array.Sort/VB/arraysort.vb" id="Snippet1"::: @@ -8494,11 +8445,11 @@ int[,,] TDArray = new int[1,1,1]; This method uses the introspective sort ([introsort](https://en.wikipedia.org/wiki/Introsort)) algorithm as follows: -- If the partition size is less than or equal to 16 elements, it uses an [insertion sort](https://en.wikipedia.org/wiki/Insertion_sort) algorithm. +- If the partition size is less than or equal to 16 elements, it uses an [insertion sort](https://en.wikipedia.org/wiki/Insertion_sort) algorithm. -- If the number of partitions exceeds 2 * LogN, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. +- If the number of partitions exceeds 2 * LogN, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. -- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. +- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal. @@ -8509,7 +8460,6 @@ int[,,] TDArray = new int[1,1,1]; ## Examples The following example shows how to sort two associated arrays where the first array contains the keys and the second array contains the values. Sorts are done using the default comparer and a custom comparer that reverses the sort order. Note that the result might vary depending on the current . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Array.Sort2/CPP/arraysort2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/Sort/arraysort2.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Array.Sort2/FS/arraysort2.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Array.Sort2/VB/arraysort2.vb" id="Snippet1"::: @@ -8607,11 +8557,11 @@ int[,,] TDArray = new int[1,1,1]; This method uses the introspective sort ([introsort](https://en.wikipedia.org/wiki/Introsort)) algorithm as follows: -- If the partition size is less than or equal to 16 elements, it uses an [insertion sort](https://en.wikipedia.org/wiki/Insertion_sort) algorithm. +- If the partition size is less than or equal to 16 elements, it uses an [insertion sort](https://en.wikipedia.org/wiki/Insertion_sort) algorithm. -- If the number of partitions exceeds 2 * LogN, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. +- If the number of partitions exceeds 2 * LogN, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. -- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. +- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal. @@ -8633,7 +8583,6 @@ This method is an O(`n` log `n`) operation, where `n` is the implementation named `ReverseComparer` that reverses an object's default sort order while performing a case-insensitive string comparison. Note that the output might vary depending on the current culture. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Array.Sort/CPP/arraysort.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/Sort/arraysort.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Array.Sort/FS/arraysort.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Array.Sort/VB/arraysort.vb" id="Snippet1"::: @@ -8750,11 +8699,11 @@ This method is an O(`n` log `n`) operation, where `n` is the N, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. +- If the number of partitions exceeds 2 * LogN, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. -- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. +- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal. @@ -8765,7 +8714,6 @@ This method is an O(`n` log `n`) operation, where `n` is the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Array.Sort2/CPP/arraysort2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/Sort/arraysort2.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Array.Sort2/FS/arraysort2.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Array.Sort2/VB/arraysort2.vb" id="Snippet1"::: @@ -8861,11 +8809,11 @@ This method is an O(`n` log `n`) operation, where `n` is the N, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. +- If the number of partitions exceeds 2 * LogN, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. -- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. +- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal. @@ -8876,7 +8824,6 @@ This method is an O(`n` log `n`) operation, where `n` is the using the default comparer and a custom comparer that reverses the sort order. Note that the result might vary depending on the current . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Array.Sort/CPP/arraysort.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/Sort/arraysort.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Array.Sort/FS/arraysort.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Array.Sort/VB/arraysort.vb" id="Snippet1"::: @@ -8982,11 +8929,11 @@ This method is an O(`n` log `n`) operation, where `n` is the N, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. +- If the number of partitions exceeds 2 * LogN, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. -- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. +- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal. @@ -8997,7 +8944,6 @@ This method is an O(`n` log `n`) operation, where `n` is the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Array.Sort2/CPP/arraysort2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/Sort/arraysort2.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Array.Sort2/FS/arraysort2.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Array.Sort2/VB/arraysort2.vb" id="Snippet1"::: @@ -9123,11 +9069,11 @@ This method is an O(`n` log `n`) operation, where `n` is the N, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. +- If the number of partitions exceeds 2 * LogN, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. -- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. +- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal. @@ -9138,7 +9084,6 @@ This method is an O(`n` log `n`) operation, where `n` is the using the default comparer and a custom comparer that reverses the sort order. Note that the result might vary depending on the current . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Array.Sort/CPP/arraysort.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/Sort/arraysort.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Array.Sort/FS/arraysort.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Array.Sort/VB/arraysort.vb" id="Snippet1"::: @@ -9274,11 +9219,11 @@ This method is an O(`n` log `n`) operation, where `n` is the N, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. +- If the number of partitions exceeds 2 * LogN, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. -- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. +- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal. @@ -9289,7 +9234,6 @@ This method is an O(`n` log `n`) operation, where `n` is the . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Array.Sort2/CPP/arraysort2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/Sort/arraysort2.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Array.Sort2/FS/arraysort2.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Array.Sort2/VB/arraysort2.vb" id="Snippet1"::: @@ -9409,11 +9353,11 @@ This method is an O(`n` log `n`) operation, where `n` is the N, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. +- If the number of partitions exceeds 2 * LogN, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. -- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. +- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal. @@ -9427,11 +9371,10 @@ This method is an O(`n` log `n`) operation, where `n` is the [!NOTE] -> The calls to the and generic methods do not look any different from calls to their nongeneric counterparts, because Visual Basic, C#, and C++ infer the type of the generic type parameter from the type of the first argument. If you use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to examine the Microsoft intermediate language (MSIL), you can see that the generic methods are being called. +> The calls to the and generic methods do not look any different from calls to their nongeneric counterparts, because Visual Basic, C#, and C++ infer the type of the generic type parameter from the type of the first argument. If you use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to examine the Microsoft intermediate language (MSIL), you can see that the generic methods are being called. - The generic method overload is then used to search for two strings, one that is not in the array and one that is. The array and the return value of the method are passed to the `ShowWhere` generic method, which displays the index value if the string is found, and otherwise the elements the search string would fall between if it were in the array. The index is negative if the string is not n the array, so the `ShowWhere` method takes the bitwise complement (the ~ operator in C# and Visual C++, `Xor` -1 in Visual Basic) to obtain the index of the first element in the list that is larger than the search string. + The generic method overload is then used to search for two strings, one that is not in the array and one that is. The array and the return value of the method are passed to the `ShowWhere` generic method, which displays the index value if the string is found, and otherwise the elements the search string would fall between if it were in the array. The index is negative if the string is not n the array, so the `ShowWhere` method takes the bitwise complement (the ~ operator in C#, `Xor` -1 in Visual Basic) to obtain the index of the first element in the list that is larger than the search string. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Array_SortSearch/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/BinarySearchT/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Array_SortSearch/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Array_SortSearch/vb/source.vb" id="Snippet1"::: @@ -9527,11 +9470,11 @@ This method is an O(`n` log `n`) operation, where `n` is the N, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. +- If the number of partitions exceeds 2 * LogN, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. -- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. +- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal. @@ -9542,16 +9485,15 @@ This method is an O(`n` log `n`) operation, where `n` is the generic method overload and the generic method overload. - The code example defines an alternative comparer for strings, named `ReverseCompare`, which implements the `IComparer` (`IComparer(Of String)` in Visual Basic, `IComparer` in Visual C++) generic interface. The comparer calls the method, reversing the order of the comparands so that the strings sort high-to-low instead of low-to-high. + The code example defines an alternative comparer for strings, named `ReverseCompare`, which implements the `IComparer` (`IComparer(Of String)` in Visual Basic,) generic interface. The comparer calls the method, reversing the order of the comparands so that the strings sort high-to-low instead of low-to-high. The array is displayed, sorted, and displayed again. Arrays must be sorted in order to use the method. > [!NOTE] -> The calls to the and generic methods do not look any different from calls to their nongeneric counterparts, because Visual Basic, C#, and C++ infer the type of the generic type parameter from the type of the first argument. If you use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to examine the Microsoft intermediate language (MSIL), you can see that the generic methods are being called. +> The calls to the and generic methods do not look any different from calls to their nongeneric counterparts, because Visual Basic, C#, and C++ infer the type of the generic type parameter from the type of the first argument. If you use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to examine the Microsoft intermediate language (MSIL), you can see that the generic methods are being called. - The generic method overload is then used to search for two strings, one that is not in the array and one that is. The array and the return value of the method are passed to the `ShowWhere` generic method, which displays the index value if the string is found, and otherwise the elements the search string would fall between if it were in the array. The index is negative if the string is not n the array, so the `ShowWhere` method takes the bitwise complement (the ~ operator in C# and Visual C++, `Xor` -1 in Visual Basic) to obtain the index of the first element in the list that is larger than the search string. + The generic method overload is then used to search for two strings, one that is not in the array and one that is. The array and the return value of the method are passed to the `ShowWhere` generic method, which displays the index value if the string is found, and otherwise the elements the search string would fall between if it were in the array. The index is negative if the string is not n the array, so the `ShowWhere` method takes the bitwise complement (the ~ operator in C#, `Xor` -1 in Visual Basic) to obtain the index of the first element in the list that is larger than the search string. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Array_SortSearchComparer/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/BinarySearchT/source1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Array_SortSearchComparer/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Array_SortSearchComparer/vb/source.vb" id="Snippet1"::: @@ -9637,11 +9579,11 @@ This method is an O(`n` log `n`) operation, where `n` is the N, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. +- If the number of partitions exceeds 2 * LogN, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. -- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. +- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal. @@ -9656,7 +9598,6 @@ This method is an O(`n` log `n`) operation, where `n` is the generic delegate representing the `CompareDinosByLength` method, and displayed again. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Array_SortComparison/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/SortT/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Array_SortComparison/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Array_SortComparison/vb/source.vb" id="Snippet1"::: @@ -9753,11 +9694,11 @@ This method is an O(`n` log `n`) operation, where `n` is the N, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. +- If the number of partitions exceeds 2 * LogN, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. -- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. +- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal. @@ -9768,14 +9709,13 @@ This method is an O(`n` log `n`) operation, where `n` is the generic method overload and the generic method overload for sorting a range in an array. - The code example defines an alternative comparer for strings, named `ReverseCompare`, which implements the `IComparer` (`IComparer(Of String)` in Visual Basic, `IComparer` in Visual C++) generic interface. The comparer calls the method, reversing the order of the comparands so that the strings sort high-to-low instead of low-to-high. + The code example defines an alternative comparer for strings, named `ReverseCompare`, which implements the `IComparer` (`IComparer(Of String)` in Visual Basic) generic interface. The comparer calls the method, reversing the order of the comparands so that the strings sort high-to-low instead of low-to-high. The code example creates and displays an array of dinosaur names, consisting of three herbivores followed by three carnivores (tyrannosaurids, to be precise). The generic method overload is used to sort the last three elements of the array, which is then displayed. The generic method overload is used with `ReverseCompare` to sort the last three elements in reverse order. The thoroughly confused dinosaurs are displayed again. > [!NOTE] -> The calls to the and generic methods do not look any different from calls to their nongeneric counterparts, because Visual Basic, C#, and C++ infer the type of the generic type parameter from the type of the first argument. If you use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to examine the Microsoft intermediate language (MSIL), you can see that the generic methods are being called. +> The calls to the and generic methods do not look any different from calls to their nongeneric counterparts, because Visual Basic, C#, and C++ infer the type of the generic type parameter from the type of the first argument. If you use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to examine the Microsoft intermediate language (MSIL), you can see that the generic methods are being called. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Array_SortIntIntIComparer/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/SortT/source1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Array_SortIntIntIComparer/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Array_SortIntIntIComparer/vb/source.vb" id="Snippet1"::: @@ -9887,11 +9827,11 @@ This method is an O(`n` log `n`) operation, where `n` is the N, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. +- If the number of partitions exceeds 2 * LogN, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. -- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. +- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal. @@ -9902,14 +9842,13 @@ This method is an O(`n` log `n`) operation, where `n` is the generic method overload and the generic method overload for sorting a range in an array. - The code example defines an alternative comparer for strings, named `ReverseCompare`, which implements the `IComparer` (`IComparer(Of String)` in Visual Basic, `IComparer` in Visual C++) generic interface. The comparer calls the method, reversing the order of the comparands so that the strings sort high-to-low instead of low-to-high. + The code example defines an alternative comparer for strings, named `ReverseCompare`, which implements the `IComparer` (`IComparer(Of String)` in Visual Basic) generic interface. The comparer calls the method, reversing the order of the comparands so that the strings sort high-to-low instead of low-to-high. The code example creates and displays an array of dinosaur names, consisting of three herbivores followed by three carnivores (tyrannosaurids, to be precise). The generic method overload is used to sort the last three elements of the array, which is then displayed. The generic method overload is used with `ReverseCompare` to sort the last three elements in reverse order. The thoroughly confused dinosaurs are displayed again. > [!NOTE] -> The calls to the and generic methods do not look any different from calls to their nongeneric counterparts, because Visual Basic, C#, and C++ infer the type of the generic type parameter from the type of the first argument. If you use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to examine the Microsoft intermediate language (MSIL), you can see that the generic methods are being called. +> The calls to the and generic methods do not look any different from calls to their nongeneric counterparts, because Visual Basic, C#, and C++ infer the type of the generic type parameter from the type of the first argument. If you use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to examine the Microsoft intermediate language (MSIL), you can see that the generic methods are being called. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Array_SortIntIntIComparer/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/SortT/source1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Array_SortIntIntIComparer/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Array_SortIntIntIComparer/vb/source.vb" id="Snippet1"::: @@ -10026,11 +9965,11 @@ This method is an O(`n` log `n`) operation, where `n` is the N, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. +- If the number of partitions exceeds 2 * LogN, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. -- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. +- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal. @@ -10041,22 +9980,18 @@ This method is an O(`n` log `n`) operation, where `n` is the , , , and generic method overloads, for sorting pairs of arrays that represent keys and values. - The code example defines an alternative comparer for strings, named `ReverseCompare`, which implements the `IComparer` (`IComparer(Of String)` in Visual Basic, `IComparer` in Visual C++) generic interface. The comparer calls the method, reversing the order of the comparands so that the strings sort high-to-low instead of low-to-high. + The code example defines an alternative comparer for strings, named `ReverseCompare`, which implements the `IComparer` (`IComparer(Of String)` in Visual Basic) generic interface. The comparer calls the method, reversing the order of the comparands so that the strings sort high-to-low instead of low-to-high. The code example creates and displays an array of dinosaur names (the keys) and an array of integers representing the maximum length of each dinosaur in meters (the values). The arrays are then sorted and displayed several times: -- The overload is used to sort both arrays in order of the dinosaur names in the first array. - -- The overload and an instance of `ReverseCompare` are used to reverse the sort order of the paired arrays. - -- The overload is used to sort the last three elements of both arrays. - -- The overload is used to sort the last three elements of both arrays in reverse order. +- The overload is used to sort both arrays in order of the dinosaur names in the first array. +- The overload and an instance of `ReverseCompare` are used to reverse the sort order of the paired arrays. +- The overload is used to sort the last three elements of both arrays. +- The overload is used to sort the last three elements of both arrays in reverse order. > [!NOTE] -> The calls to the generic methods do not look any different from calls to their nongeneric counterparts, because Visual Basic, C#, and C++ infer the type of the generic type parameter from the type of the first two arguments. If you use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to examine the Microsoft intermediate language (MSIL), you can see that the generic methods are being called. +> The calls to the generic methods do not look any different from calls to their nongeneric counterparts, because Visual Basic, C#, and C++ infer the type of the generic type parameter from the type of the first two arguments. If you use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to examine the Microsoft intermediate language (MSIL), you can see that the generic methods are being called. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Array_Sort2IntIntIComparer/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/SortTKey,TValue/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Array_Sort2IntIntIComparer/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Array_Sort2IntIntIComparer/vb/source.vb" id="Snippet1"::: @@ -10172,11 +10107,11 @@ This method is an O(`n` log `n`) operation, where `n` is the N, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. +- If the number of partitions exceeds 2 * LogN, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. -- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. +- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal. @@ -10185,22 +10120,18 @@ This method is an O(`n` log `n`) operation, where `n` is the , [\], , , and generic method overloads, for sorting pairs of arrays that represent keys and values. - The code example defines an alternative comparer for strings, named `ReverseCompare`, which implements the `IComparer` (`IComparer(Of String)` in Visual Basic, `IComparer` in Visual C++) generic interface. The comparer calls the method, reversing the order of the comparands so that the strings sort high-to-low instead of low-to-high. + The code example defines an alternative comparer for strings, named `ReverseCompare`, which implements the `IComparer` (`IComparer(Of String)` in Visual Basic) generic interface. The comparer calls the method, reversing the order of the comparands so that the strings sort high-to-low instead of low-to-high. The code example creates and displays an array of dinosaur names (the keys) and an array of integers representing the maximum length of each dinosaur in meters (the values). The arrays are then sorted and displayed several times: -- The overload is used to sort both arrays in order of the dinosaur names in the first array. - -- The overload and an instance of `ReverseCompare` are used to reverse the sort order of the paired arrays. - -- The overload is used to sort the last three elements of both arrays. - -- The overload is used to sort the last three elements of both arrays in reverse order. +- The overload is used to sort both arrays in order of the dinosaur names in the first array. +- The overload and an instance of `ReverseCompare` are used to reverse the sort order of the paired arrays. +- The overload is used to sort the last three elements of both arrays. +- The overload is used to sort the last three elements of both arrays in reverse order. > [!NOTE] -> The calls to the generic methods do not look any different from calls to their nongeneric counterparts, because Visual Basic, C#, and C++ infer the type of the generic type parameter from the type of the first two arguments. If you use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to examine the Microsoft intermediate language (MSIL), you can see that the generic methods are being called. +> The calls to the generic methods do not look any different from calls to their nongeneric counterparts, because Visual Basic, C#, and C++ infer the type of the generic type parameter from the type of the first two arguments. If you use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to examine the Microsoft intermediate language (MSIL), you can see that the generic methods are being called. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Array_Sort2IntIntIComparer/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/SortTKey,TValue/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Array_Sort2IntIntIComparer/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Array_Sort2IntIntIComparer/vb/source.vb" id="Snippet1"::: @@ -10319,11 +10250,11 @@ This method is an O(`n` log `n`) operation, where `n` is the N, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. +- If the number of partitions exceeds 2 * LogN, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. -- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. +- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal. @@ -10332,22 +10263,18 @@ This method is an O(`n` log `n`) operation, where `n` is the , , , and generic method overloads, for sorting pairs of arrays that represent keys and values. - The code example defines an alternative comparer for strings, named `ReverseCompare`, which implements the `IComparer` (`IComparer(Of String)` in Visual Basic, `IComparer` in Visual C++) generic interface. The comparer calls the method, reversing the order of the comparands so that the strings sort high-to-low instead of low-to-high. + The code example defines an alternative comparer for strings, named `ReverseCompare`, which implements the `IComparer` (`IComparer(Of String)` in Visual Basic) generic interface. The comparer calls the method, reversing the order of the comparands so that the strings sort high-to-low instead of low-to-high. The code example creates and displays an array of dinosaur names (the keys) and an array of integers representing the maximum length of each dinosaur in meters (the values). The arrays are then sorted and displayed several times: -- The overload is used to sort both arrays in order of the dinosaur names in the first array. - -- The overload and an instance of `ReverseCompare` are used to reverse the sort order of the paired arrays. - -- The overload is used to sort the last three elements of both arrays. - -- The overload is used to sort the last three elements of both arrays in reverse order. +- The overload is used to sort both arrays in order of the dinosaur names in the first array. +- The overload and an instance of `ReverseCompare` are used to reverse the sort order of the paired arrays. +- The overload is used to sort the last three elements of both arrays. +- The overload is used to sort the last three elements of both arrays in reverse order. > [!NOTE] > The calls to the generic methods do not look any different from calls to their nongeneric counterparts, because Visual Basic, C#, and C++ infer the type of the generic type parameter from the type of the first two arguments. If you use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to examine the Microsoft intermediate language (MSIL), you can see that the generic methods are being called. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Array_Sort2IntIntIComparer/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/SortTKey,TValue/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Array_Sort2IntIntIComparer/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Array_Sort2IntIntIComparer/vb/source.vb" id="Snippet1"::: @@ -10484,11 +10411,11 @@ This method is an O(`n` log `n`) operation, where `n` is the N, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. +- If the number of partitions exceeds 2 * LogN, where *N* is the range of the input array, it uses a [Heapsort](https://en.wikipedia.org/wiki/Heapsort) algorithm. -- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. +- Otherwise, it uses a [Quicksort](https://en.wikipedia.org/wiki/Quicksort) algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal. @@ -10497,22 +10424,18 @@ This method is an O(`n` log `n`) operation, where `n` is the , , , and generic method overloads, for sorting pairs of arrays that represent keys and values. - The code example defines an alternative comparer for strings, named `ReverseCompare`, which implements the `IComparer`(`IComparer(Of String)` in Visual Basic, `IComparer` in Visual C++) generic interface. The comparer calls the method, reversing the order of the comparands so that the strings sort high-to-low instead of low-to-high. + The code example defines an alternative comparer for strings, named `ReverseCompare`, which implements the `IComparer`(`IComparer(Of String)` in Visual Basic) generic interface. The comparer calls the method, reversing the order of the comparands so that the strings sort high-to-low instead of low-to-high. The code example creates and displays an array of dinosaur names (the keys) and an array of integers representing the maximum length of each dinosaur in meters (the values). The arrays are then sorted and displayed several times: -- The overload is used to sort both arrays in order of the dinosaur names in the first array. - -- The overload and an instance of `ReverseCompare` are used to reverse the sort order of the paired arrays. - -- The overload is used to sort the last three elements of both arrays. - -- The overload is used to sort the last three elements of both arrays in reverse order. +- The overload is used to sort both arrays in order of the dinosaur names in the first array. +- The overload and an instance of `ReverseCompare` are used to reverse the sort order of the paired arrays. +- The overload is used to sort the last three elements of both arrays. +- The overload is used to sort the last three elements of both arrays in reverse order. > [!NOTE] > The calls to the generic methods do not look any different from calls to their nongeneric counterparts, because Visual Basic, C#, and C++ infer the type of the generic type parameter from the type of the first two arguments. If you use the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler) to examine the Microsoft intermediate language (MSIL), you can see that the generic methods are being called. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Array_Sort2IntIntIComparer/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/SortTKey,TValue/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Array_Sort2IntIntIComparer/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Array_Sort2IntIntIComparer/vb/source.vb" id="Snippet1"::: @@ -10615,12 +10538,9 @@ This property implements the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Array.SyncRoot/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/IsSynchronized/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Array.SyncRoot/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Array.SyncRoot/vb/source.vb" id="Snippet1"::: @@ -11634,7 +11554,7 @@ This member is an explicit interface member implementation. It can be used only In both cases, the method returns `false` as soon as it encounters the first array element that does not end in a number. Otherwise, it returns `true` after iterating all the elements in the array. > [!NOTE] -> As both examples show, 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. +> As both examples show, 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. ]]> diff --git a/xml/System/ArraySegment`1.xml b/xml/System/ArraySegment`1.xml index dace550fd2f..4c4bcf6e234 100644 --- a/xml/System/ArraySegment`1.xml +++ b/xml/System/ArraySegment`1.xml @@ -143,7 +143,6 @@ ## Examples The following code example passes an structure to a method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.ArraySegment/CPP/arraysegment.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/ArraySegmentT/Overview/arraysegment.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.ArraySegment/FS/arraysegment.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.ArraySegment/VB/arraysegment.vb" id="Snippet1"::: @@ -170,7 +169,6 @@ ## Examples The following code example passes an structure to a method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.ArraySegment/CPP/arraysegment.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/ArraySegmentT/Overview/arraysegment.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.ArraySegment/FS/arraysegment.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.ArraySegment/VB/arraysegment.vb" id="Snippet1"::: @@ -360,7 +358,6 @@ ## Examples The following code example passes an to a method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.ArraySegment/CPP/arraysegment.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/ArraySegmentT/Overview/arraysegment.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.ArraySegment/FS/arraysegment.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.ArraySegment/VB/arraysegment.vb" id="Snippet1"::: @@ -562,7 +559,6 @@ The underlying array of is structure to a method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.ArraySegment/CPP/arraysegment.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/ArraySegmentT/Overview/arraysegment.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.ArraySegment/FS/arraysegment.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.ArraySegment/VB/arraysegment.vb" id="Snippet1"::: @@ -948,7 +944,6 @@ The underlying array of is structure to a method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.ArraySegment/CPP/arraysegment.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/ArraySegmentT/Overview/arraysegment.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.ArraySegment/FS/arraysegment.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.ArraySegment/VB/arraysegment.vb" id="Snippet1"::: diff --git a/xml/System/ArrayTypeMismatchException.xml b/xml/System/ArrayTypeMismatchException.xml index f7729f63593..4557bf3ec88 100644 --- a/xml/System/ArrayTypeMismatchException.xml +++ b/xml/System/ArrayTypeMismatchException.xml @@ -88,12 +88,9 @@ For a list of initial property values for an instance of , see the constructors. - - ## Examples The following code example demonstrates scenarios where is thrown. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.ArrayTypeMismatch/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/ArrayTypeMismatchException/Overview/class1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.ArrayTypeMismatch/FS/class1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.ArrayTypeMismatch/VB/class1.vb" id="Snippet1"::: @@ -173,7 +170,6 @@ ## Examples The following example demonstrates the ArrayTypeMismatchException() constructor of the class. It contains a function which takes two arrays as arguments and checks whether the two arrays are of the same type. If the arrays are of different types, a new is thrown and then caught in the calling method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ArrayTypeMisMatch_Constructor1/CPP/arraytypemismatch_constructor1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/ArrayTypeMismatchException/.ctor/arraytypemismatch_constructor1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/ArrayTypeMisMatch_Constructor1/FS/arraytypemismatch_constructor1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ArrayTypeMisMatch_Constructor1/VB/arraytypemismatch_constructor1.vb" id="Snippet1"::: @@ -243,7 +239,6 @@ ## Examples The following example demonstrates the ArrayTypeMismatchException(String) constructor of the class. It contains a function which takes two arrays as arguments and checks whether the two arrays are of the same type. If the arrays are of different types, a new is thrown and then caught in the calling method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ArrayTypeMisMatch_Constructor2/CPP/arraytypemismatch_constructor2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/ArrayTypeMismatchException/.ctor/arraytypemismatch_constructor2.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/ArrayTypeMisMatch_Constructor2/FS/arraytypemismatch_constructor2.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ArrayTypeMisMatch_Constructor2/VB/arraytypemismatch_constructor2.vb" id="Snippet1"::: @@ -380,7 +375,6 @@ ## Examples The following code example demonstrates the constructor of the class. It contains a function that takes two arrays as arguments and checks whether the two arrays are of the same type. If the arrays are of different types, a new is thrown and then caught in the calling method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ArrayTypeMisMatch_Constructor3/CPP/arraytypemismatch_constructor3.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/ArrayTypeMismatchException/.ctor/arraytypemismatch_constructor3.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/ArrayTypeMisMatch_Constructor3/FS/arraytypemismatch_constructor3.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ArrayTypeMisMatch_Constructor3/VB/arraytypemismatch_constructor3.vb" id="Snippet1"::: diff --git a/xml/System/Attribute.xml b/xml/System/Attribute.xml index 28fb0b0c425..2431ac01d19 100644 --- a/xml/System/Attribute.xml +++ b/xml/System/Attribute.xml @@ -99,7 +99,6 @@ ## Examples The following code example demonstrates the usage of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AnimalAttributes/CPP/customattribute.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/Overview/customattribute.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/AnimalAttributes/FS/customattribute.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AnimalAttributes/VB/customattribute.vb" id="Snippet1"::: @@ -160,7 +159,6 @@ ## Examples The following code example shows the definition of a custom parameter class with its constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/CPP/getcustattrparam.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/.ctor/getcustattrparam.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/FS/getcustattrparam.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/VB/getcustattrparam.vb" id="Snippet2"::: @@ -242,7 +240,6 @@ When implementing your own class derived from , you can o ## Examples The following example defines two custom parameter classes, then creates several objects of each class and uses the method to compare them. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Attribute.Equals/CPP/equals.cpp"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/Equals/equals.cs" interactive="try-dotnet"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.Equals/FS/equals.fs"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Attribute.Equals/VB/equals.vb"::: @@ -326,7 +323,6 @@ When implementing your own class derived from , you can o ## Examples The following code example illustrates the use of the method taking an as a parameter.   - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttribute/id1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id1.vb" id="Snippet1"::: @@ -405,7 +401,6 @@ When implementing your own class derived from , you can o ## Examples The following code example illustrates the use of the method taking a as a parameter.   - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttribute/id4.cs" interactive="try-dotnet" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id4.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id4.vb" id="Snippet4"::: @@ -479,7 +474,6 @@ When implementing your own class derived from , you can o ## Examples The following code example illustrates the use of the method taking a as a parameter.   - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttribute/id2.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id2.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id2.vb" id="Snippet2"::: @@ -555,7 +549,6 @@ When implementing your own class derived from , you can o ## Examples The following code example defines a custom parameter class and applies the custom attribute to a method in a derived class and the base of the derived class. The example shows the use of the method to return the attributes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/CPP/getcustattrparam.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/.ctor/getcustattrparam.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/FS/getcustattrparam.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/VB/getcustattrparam.vb" id="Snippet1"::: @@ -636,7 +629,6 @@ When implementing your own class derived from , you can o ## Examples The following code example illustrates the use of the method taking an as a parameter.   - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttribute/id1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id1.vb" id="Snippet1"::: @@ -716,7 +708,6 @@ When implementing your own class derived from , you can o ## Examples The following code example illustrates the use of the method taking a as a parameter.   - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttribute/id4.cs" interactive="try-dotnet" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id4.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id4.vb" id="Snippet4"::: @@ -792,7 +783,6 @@ When implementing your own class derived from , you can o ## Examples The following code example illustrates the use of the method taking a as a parameter.   - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttribute/id2.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id2.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id2.vb" id="Snippet2"::: @@ -870,7 +860,6 @@ When implementing your own class derived from , you can o ## Examples The following code example defines a custom parameter class and applies the custom attribute to a method in a derived class and the base of the derived class. The example shows the use of the method to return the attributes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/CPP/getcustattrprminh.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/.ctor/getcustattrprminh.cs" interactive="try-dotnet" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/FS/getcustattrprminh.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Attribute.GetCustomAttribute/VB/getcustattrprminh.vb" id="Snippet3"::: @@ -950,7 +939,6 @@ When implementing your own class derived from , you can o ## Examples The following example retrieves the custom attributes found in the current assembly. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/ca1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttributes/ca1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca1.vb" id="Snippet1"::: @@ -1017,7 +1005,6 @@ When implementing your own class derived from , you can o ## Examples The following code example demonstrates the use of , taking a as a parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttributes/ca4.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca4.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca4.vb" id="Snippet4"::: @@ -1079,7 +1066,6 @@ When implementing your own class derived from , you can o ## Examples The following code example demonstrates the use of , taking a as a parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttributes/ca2.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca2.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca2.vb" id="Snippet2"::: @@ -1143,7 +1129,6 @@ When implementing your own class derived from , you can o ## Examples The following code example demonstrates the use of , taking a as a parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttributes/ca5.cs" interactive="try-dotnet" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca5.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca5.vb" id="Snippet5"::: @@ -1205,7 +1190,6 @@ When implementing your own class derived from , you can o ## Examples The following code example demonstrates the use of , taking an as a parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/ca1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttributes/ca1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca1.vb" id="Snippet1"::: @@ -1273,7 +1257,6 @@ When implementing your own class derived from , you can o ## Examples The following code example demonstrates the use of , taking an as a parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/ca1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttributes/ca1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca1.vb" id="Snippet1"::: @@ -1344,7 +1327,6 @@ When implementing your own class derived from , you can o ## Examples The following code example demonstrates the use of , taking a as a parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttributes/ca4.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca4.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca4.vb" id="Snippet4"::: @@ -1413,7 +1395,6 @@ When implementing your own class derived from , you can o ## Examples The following code example demonstrates the use of , taking a as a parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttributes/ca2.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca2.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca2.vb" id="Snippet2"::: @@ -1474,7 +1455,6 @@ When implementing your own class derived from , you can o ## Examples The following code example demonstrates the use of , taking a as a parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttributes/ca2.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca2.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca2.vb" id="Snippet2"::: @@ -1548,7 +1528,6 @@ When implementing your own class derived from , you can o ## Examples The following code example demonstrates the use of , taking a as a parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttributes/ca5.cs" interactive="try-dotnet" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca5.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca5.vb" id="Snippet5"::: @@ -1616,7 +1595,6 @@ When implementing your own class derived from , you can o ## Examples The following code example demonstrates the use of , taking a as a parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttributes/ca5.cs" interactive="try-dotnet" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca5.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca5.vb" id="Snippet5"::: @@ -1689,7 +1667,6 @@ When implementing your own class derived from , you can o ## Examples The following code example demonstrates the use of , taking an as a parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/ca1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttributes/ca1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca1.vb" id="Snippet1"::: @@ -1767,7 +1744,6 @@ When implementing your own class derived from , you can o ## Examples The following code example demonstrates the use of , taking a as a parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttributes/ca4.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca4.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca4.vb" id="Snippet4"::: @@ -1840,7 +1816,6 @@ When implementing your own class derived from , you can o ## Examples The following code example demonstrates the use of , taking a as a parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttributes/ca2.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca2.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca2.vb" id="Snippet2"::: @@ -1916,7 +1891,6 @@ When implementing your own class derived from , you can o ## Examples The following code example demonstrates the use of , taking a as a parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttributes/ca5.cs" interactive="try-dotnet" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca5.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca5.vb" id="Snippet5"::: @@ -1997,7 +1971,6 @@ When implementing your own class derived from , you can o ## Examples The following code example demonstrates the use of , taking a as a parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GetCustomAttributes/CPP/custattrs.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttributes/ca4.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/GetCustomAttributes/FS/ca4.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GetCustomAttributes/VB/ca4.vb" id="Snippet4"::: @@ -2129,7 +2102,6 @@ When implementing your own class derived from , you can o ## Examples The following code example illustrates the use of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IsDefaultAttribute/CPP/defattr.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/IsDefaultAttribute/defattr.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/IsDefaultAttribute/FS/defattr.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IsDefaultAttribute/VB/defattr.vb" id="Snippet1"::: @@ -2206,7 +2178,6 @@ When implementing your own class derived from , you can o ## Examples The following code example illustrates the use of , taking an as a parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttribute/id1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id1.vb" id="Snippet1"::: @@ -2278,7 +2249,6 @@ When implementing your own class derived from , you can o ## Examples The following code example illustrates the use of , taking a as a parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttribute/id4.cs" interactive="try-dotnet" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id4.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id4.vb" id="Snippet4"::: @@ -2349,7 +2319,6 @@ When implementing your own class derived from , you can o ## Examples The following code example illustrates the use of , taking a as a parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttribute/id2.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id2.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id2.vb" id="Snippet2"::: @@ -2418,7 +2387,6 @@ When implementing your own class derived from , you can o ## Examples The following code example illustrates the use of , taking a as a parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttribute/id5.cs" interactive="try-dotnet" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id5.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id5.vb" id="Snippet5"::: @@ -2491,7 +2459,6 @@ When implementing your own class derived from , you can o ## Examples The following code example illustrates the use of , taking an as a parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttribute/id1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id1.vb" id="Snippet1"::: @@ -2564,7 +2531,6 @@ When implementing your own class derived from , you can o ## Examples The following code example illustrates the use of , taking a as a parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttribute/id4.cs" interactive="try-dotnet" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id4.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id4.vb" id="Snippet4"::: @@ -2643,7 +2609,6 @@ When implementing your own class derived from , you can o ## Examples The following code example illustrates the use of , taking a as a parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttribute/id2.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id2.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id2.vb" id="Snippet2"::: @@ -2709,7 +2674,6 @@ When implementing your own class derived from , you can o ## Examples The following code example illustrates the use of , taking a as a parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IsDefined/CPP/isdefined.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/GetCustomAttribute/id5.cs" interactive="try-dotnet" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/IsDefined/FS/id5.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IsDefined/VB/id5.vb" id="Snippet5"::: @@ -3039,7 +3003,6 @@ When implementing your own class derived from , you can o ## Examples The following code example implements the property in a custom parameter class and shows its use. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Attribute.TypeId/CPP/typeid.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Attribute/TypeId/typeid.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Attribute.TypeId/FS/typeid.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Attribute.TypeId/VB/typeid.vb" id="Snippet1"::: diff --git a/xml/System/AttributeTargets.xml b/xml/System/AttributeTargets.xml index cddbd938d66..bcf361d6885 100644 --- a/xml/System/AttributeTargets.xml +++ b/xml/System/AttributeTargets.xml @@ -64,26 +64,22 @@ Specifies the application elements on which it is valid to apply an attribute. - class uses this enumeration to specify the kind of element on which it is valid to apply an attribute. - - enumeration values can be combined with a bitwise OR operation to get the preferred combination. - - - -## Examples - The following example illustrates the application of attributes to various targets. - + class uses this enumeration to specify the kind of element on which it's valid to apply an attribute. + + enumeration values can be combined with a bitwise OR operation to get the preferred combination. + +## Examples + The following example illustrates the application of attributes to various targets. + > [!NOTE] -> Visual Basic and Visual C++ syntax currently do not support the application of attributes to type parameters. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AttrTargs/CPP/attrtargs.cpp" id="Snippet1"::: +> Visual Basic syntax doesn't support the application of attributes to type parameters. + :::code language="csharp" source="~/snippets/csharp/System/AttributeTargets/Overview/attrtargs.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/AttrTargs/FS/attrtargs.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AttrTargs/VB/AttrTargs.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AttrTargs/VB/AttrTargs.vb" id="Snippet1"::: ]]> diff --git a/xml/System/AttributeUsageAttribute.xml b/xml/System/AttributeUsageAttribute.xml index 37f7a0dfd70..48d85aac071 100644 --- a/xml/System/AttributeUsageAttribute.xml +++ b/xml/System/AttributeUsageAttribute.xml @@ -65,29 +65,29 @@ Specifies the usage of another attribute class. This class cannot be inherited. - on your attribute class. The indicated attribute class must derive from , either directly or indirectly. - - Attribute classes have positional and named parameters. Each public constructor for an attribute class defines a valid sequence of positional parameters for that class. Named parameters are defined by the non-static, public, and read-write fields or properties of the attribute class. - - The three properties of are set by defining the following parameters: - -- - - This positional parameter specifies the program elements that the indicated attribute can be placed on. The set of all possible elements that you can place an attribute on is listed in the enumeration. You can combine several values using a bitwise OR operation to get the desired combination of valid program elements. - -- - - This named parameter specifies whether the indicated attribute can be specified more than once for a given program element. - -- - - This named parameter specifies whether the indicated attribute can be inherited by derived classes and overriding members. - - For more information about using attributes, see and [Attributes](/dotnet/standard/attributes/). - + on your attribute class. The indicated attribute class must derive from , either directly or indirectly. + + Attribute classes have positional and named parameters. Each public constructor for an attribute class defines a valid sequence of positional parameters for that class. Named parameters are defined by the non-static, public, and read-write fields or properties of the attribute class. + + The three properties of are set by defining the following parameters: + +- + + This positional parameter specifies the program elements that the indicated attribute can be placed on. The set of all possible elements that you can place an attribute on is listed in the enumeration. You can combine several values using a bitwise OR operation to get the desired combination of valid program elements. + +- + + This named parameter specifies whether the indicated attribute can be specified more than once for a given program element. + +- + + This named parameter specifies whether the indicated attribute can be inherited by derived classes and overriding members. + + For more information about using attributes, see and [Attributes](/dotnet/standard/attributes/). + ]]> @@ -138,23 +138,20 @@ The set of values combined using a bitwise OR operation to indicate which program elements are valid. Initializes a new instance of the class with the specified list of , the value, and the value. - values using a bitwise OR operation to get the desired combination of valid program elements. - - For default property values, see the , , and properties. - - - -## Examples - The definition of the DispId attribute illustrates the use of a bitwise OR operation to combine several values. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic AttributeUsageAttribute.AttributeUsageAttribute Example/CPP/source.cpp" id="Snippet1"::: + values using a bitwise OR operation to get the desired combination of valid program elements. + + For default property values, see the , , and properties. + +## Examples + The definition of the DispId attribute illustrates the use of a bitwise OR operation to combine several values. + :::code language="csharp" source="~/snippets/csharp/System/AttributeUsageAttribute/.ctor/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_Classic/classic AttributeUsageAttribute.AttributeUsageAttribute Example/FS/source.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic AttributeUsageAttribute.AttributeUsageAttribute Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic AttributeUsageAttribute.AttributeUsageAttribute Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -204,11 +201,11 @@ if more than one instance is allowed to be specified; otherwise, . The default is . - @@ -258,32 +255,32 @@ if the attribute can be inherited by derived classes and overriding members; otherwise, . The default is . - property determines: - -- Whether classes derived from a base class tagged with the attribute to which the attribute is applied inherit that attribute. - -- Whether methods of derived classes that override a base class method tagged with the attribute to which the attribute is applied inherit that attribute. (If a class inherits a base class member, it also inherits any attributes applied to that member.) - - - -## Examples - The following example illustrates the difference between an attribute to which an attribute with an property value of `true` is applied and one to which attribute with an property value of `false` is applied. The example defines two attributes, `InheritedAttribute` and `NotInheritedAttribute`. Both attributes can apply to classes and methods. Because the property of the attribute applied to `InheritedAttribute` is `true`, it is inherited by derived classes and the members of derived classes that override the base class method. On the other hand, because the property of the attribute applied to `NotInheritedAttribute` is `false`, it is not inherited by derived classes and the members of derived classes that override the base class method. - + property determines: + +- Whether classes derived from a base class tagged with the attribute to which the attribute is applied inherit that attribute. + +- Whether methods of derived classes that override a base class method tagged with the attribute to which the attribute is applied inherit that attribute. (If a class inherits a base class member, it also inherits any attributes applied to that member.) + + + +## Examples + The following example illustrates the difference between an attribute to which an attribute with an property value of `true` is applied and one to which attribute with an property value of `false` is applied. The example defines two attributes, `InheritedAttribute` and `NotInheritedAttribute`. Both attributes can apply to classes and methods. Because the property of the attribute applied to `InheritedAttribute` is `true`, it is inherited by derived classes and the members of derived classes that override the base class method. On the other hand, because the property of the attribute applied to `NotInheritedAttribute` is `false`, it is not inherited by derived classes and the members of derived classes that override the base class method. + :::code language="csharp" source="~/snippets/csharp/System/AttributeUsageAttribute/Inherited/Inherited1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/System.AttributeUsageAttribute.Inherited/fs/Inherited1.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.AttributeUsageAttribute.Inherited/vb/Inherited1.vb" id="Snippet1"::: - - The example then defines two base classes. The first, `BaseA`, has a single method, `MethodA`. The second, `BaseB`, has a single method, `MethodB`. `BaseA` and `MethodA` are tagged with the `InheritedAttribute` attribute, and `BaseB` and `MethodB` are tagged with the `NotInheritedAttribute` attribute. `DerivedA` inherits from `BaseA` and overrides its `MethodA` method. `DerivedB` inherits from `BaseB` and overrides its `MethodB` method. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.AttributeUsageAttribute.Inherited/vb/Inherited1.vb" id="Snippet1"::: + + The example then defines two base classes. The first, `BaseA`, has a single method, `MethodA`. The second, `BaseB`, has a single method, `MethodB`. `BaseA` and `MethodA` are tagged with the `InheritedAttribute` attribute, and `BaseB` and `MethodB` are tagged with the `NotInheritedAttribute` attribute. `DerivedA` inherits from `BaseA` and overrides its `MethodA` method. `DerivedB` inherits from `BaseB` and overrides its `MethodB` method. + :::code language="csharp" source="~/snippets/csharp/System/AttributeUsageAttribute/Inherited/Inherited1.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/System.AttributeUsageAttribute.Inherited/fs/Inherited1.fs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.AttributeUsageAttribute.Inherited/vb/Inherited1.vb" id="Snippet2"::: - - As the output from the example shows, `DerivedA` and `DerivedA.MethodA` inherit the `InheritedAttribute` attribute, but `DerivedB` and `DerivedB.MethodB` do not inherit the `NotInheritedAttribute` attribute. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.AttributeUsageAttribute.Inherited/vb/Inherited1.vb" id="Snippet2"::: + + As the output from the example shows, `DerivedA` and `DerivedA.MethodA` inherit the `InheritedAttribute` attribute, but `DerivedB` and `DerivedB.MethodB` do not inherit the `NotInheritedAttribute` attribute. + ]]> diff --git a/xml/System/BadImageFormatException.xml b/xml/System/BadImageFormatException.xml index 96696e6fba8..65f457d1132 100644 --- a/xml/System/BadImageFormatException.xml +++ b/xml/System/BadImageFormatException.xml @@ -117,7 +117,7 @@ :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.badimageformatexception.class/fs/targetplatform1.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.badimageformatexception.class/vb/targetplatform1.vb" id="Snippet4"::: -- Reflecting on C++ executable files may throw this exception. This is most likely caused by the C++ compiler stripping the relocation addresses or the .Reloc section from the executable file. To preserve the .relocation address in a C++ executable file, specify /fixed:no when linking. +- Reflecting on C++ executable files might throw this exception. This is most likely caused by the C++ compiler stripping the relocation addresses or the .Reloc section from the executable file. To preserve the .relocation address in a C++ executable file, specify /fixed:no when linking. uses the HRESULT `COR_E_BADIMAGEFORMAT`, which has the value 0x8007000B. diff --git a/xml/System/BitConverter.xml b/xml/System/BitConverter.xml index e68f4142bdf..921c1847916 100644 --- a/xml/System/BitConverter.xml +++ b/xml/System/BitConverter.xml @@ -115,7 +115,6 @@ ## Examples The following code example illustrates the use of several class methods. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.Class/CPP/bitconv.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/Overview/bitconv.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.Class/FS/bitconv.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.Class/VB/bitconv.vb" id="Snippet1"::: @@ -188,7 +187,6 @@ ## Examples The following code example converts the bit patterns of several values to values with the `DoubleToInt64Bits` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.DoubleInt64/CPP/dbltobits.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/DoubleToInt64Bits/dbltobits.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.DoubleInt64/FS/dbltobits.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.DoubleInt64/VB/dbltobits.vb" id="Snippet2"::: @@ -311,7 +309,6 @@ ## Examples The following example converts the bit patterns of values to arrays with the `GetBytes` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.Others/CPP/bytesbool.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/GetBytes/bytesbool.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.Others/FS/bytesbool.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.GetBytes.Others/VB/bytesbool.vb" id="Snippet1"::: @@ -378,7 +375,6 @@ ## Examples The following code example converts the bit patterns of values (Unicode characters) to arrays with the `GetBytes` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.Others/CPP/byteschar.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/GetBytes/byteschar.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.Others/FS/byteschar.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.GetBytes.Others/VB/byteschar.vb" id="Snippet2"::: @@ -451,7 +447,6 @@ ## Examples The following code example converts the bit patterns of values to arrays with the `GetBytes` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.Others/CPP/bytesdouble.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/GetBytes/bytesdouble.cs" interactive="try-dotnet" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.Others/FS/bytesdouble.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.GetBytes.Others/VB/bytesdouble.vb" id="Snippet4"::: @@ -597,7 +592,6 @@ ## Examples The following code example converts the bit patterns of values to arrays with the `GetBytes` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.SInts/CPP/bytesint16.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/GetBytes/bytesint16.cs" interactive="try-dotnet" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.SInts/FS/bytesint16.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.GetBytes.SInts/VB/bytesint16.vb" id="Snippet3"::: @@ -670,7 +664,6 @@ ## Examples The following code example converts the bit patterns of values to arrays with the `GetBytes` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.SInts/CPP/bytesint32.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/GetBytes/bytesint32.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.SInts/FS/bytesint32.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.GetBytes.SInts/VB/bytesint32.vb" id="Snippet2"::: @@ -743,7 +736,6 @@ ## Examples The following example calls the method to convert each element in an array to a arrays. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.SInts/CPP/bytesint64.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/GetBytes/bytesint64.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.SInts/FS/bytesint64.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.GetBytes.SInts/VB/bytesint64.vb" id="Snippet1"::: @@ -816,7 +808,6 @@ ## Examples The following code example converts the bit patterns of values to arrays with the `GetBytes` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.Others/CPP/bytessingle.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/GetBytes/bytessingle.cs" interactive="try-dotnet" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.Others/FS/bytessingle.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.GetBytes.Others/VB/bytessingle.vb" id="Snippet3"::: @@ -930,7 +921,6 @@ ## Examples The following code example converts the bit patterns of values to arrays with the `GetBytes` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.UInts/CPP/bytesuint16.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/GetBytes/bytesuint16.cs" interactive="try-dotnet" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.UInts/FS/bytesuint16.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.GetBytes.UInts/VB/bytesuint16.vb" id="Snippet3"::: @@ -1003,7 +993,6 @@ ## Examples The following code example converts the bit patterns of values to arrays with the `GetBytes` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.UInts/CPP/bytesuint32.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/GetBytes/bytesuint32.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.UInts/FS/bytesuint32.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.GetBytes.UInts/VB/bytesuint32.vb" id="Snippet2"::: @@ -1076,7 +1065,6 @@ ## Examples The following code example converts the bit patterns of values to arrays with the `GetBytes` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.UInts/CPP/bytesuint64.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/GetBytes/bytesuint64.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.GetBytes.UInts/FS/bytesuint64.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.GetBytes.UInts/VB/bytesuint64.vb" id="Snippet1"::: @@ -1312,7 +1300,6 @@ ## Examples The following code example converts the bit patterns of several values to values with the `Int64BitsToDouble` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.DoubleInt64/CPP/bitstodbl.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/DoubleToInt64Bits/bitstodbl.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.DoubleInt64/FS/bitstodbl.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.DoubleInt64/VB/bitstodbl.vb" id="Snippet1"::: @@ -1377,7 +1364,6 @@ ## Examples The following code example illustrates the use of the `IsLittleEndian` field. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.Class/CPP/littleend.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/Overview/littleend.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.Class/FS/littleend.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.Class/VB/littleend.vb" id="Snippet2"::: @@ -1576,7 +1562,6 @@ ## Examples The following code example converts elements of arrays to values with the `ToBoolean` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.Others/CPP/batobool.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/ToBoolean/batobool.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.Others/FS/batobool.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.ToXXX.Others/VB/batobool.vb" id="Snippet1"::: @@ -1692,7 +1677,6 @@ ## Examples The following code example converts elements of arrays to values (Unicode characters) with the `ToChar` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.Others/CPP/batochar.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/ToBoolean/batochar.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.Others/FS/batochar.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.ToXXX.Others/VB/batochar.vb" id="Snippet2"::: @@ -1816,7 +1800,6 @@ ## Examples The following code example converts elements of arrays to values with the `ToDouble` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.Others/CPP/batodouble.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/ToBoolean/batodouble.cs" interactive="try-dotnet" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.Others/FS/batodouble.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.ToXXX.Others/VB/batodouble.vb" id="Snippet3"::: @@ -2105,7 +2088,6 @@ ## Examples The following code example converts elements of arrays to values with the `ToInt16` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.SInts/CPP/batoint16.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/ToInt16/batoint16.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.SInts/FS/batoint16.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.ToXXX.SInts/VB/batoint16.vb" id="Snippet1"::: @@ -2352,7 +2334,6 @@ ## Examples The following code example converts elements of arrays to values with the `ToInt64` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.SInts/CPP/batoint64.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/ToInt16/batoint64.cs" interactive="try-dotnet" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.SInts/FS/batoint64.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.ToXXX.SInts/VB/batoint64.vb" id="Snippet3"::: @@ -2476,7 +2457,6 @@ ## Examples The following code example converts elements of arrays to values with the `ToSingle` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.Others/CPP/batosingle.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/ToBoolean/batosingle.cs" interactive="try-dotnet" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.Others/FS/batosingle.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.ToXXX.Others/VB/batosingle.vb" id="Snippet4"::: @@ -2561,7 +2541,6 @@ ## Examples The following code example converts arrays to objects with the `ToString` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToString/CPP/batostring.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/ToString/batostring.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.ToString/FS/batostring.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.ToString/VB/batostring.vb" id="Snippet1"::: @@ -2631,7 +2610,6 @@ ## Examples The following code example converts the part of a array starting at the specified `startIndex` to a with the `ToString` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToString/CPP/batostringii.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/ToString/batostringii.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.ToString/FS/batostringii.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.ToString/VB/batostringii.vb" id="Snippet2"::: @@ -2705,7 +2683,6 @@ ## Examples The following example uses the method to convert part of a byte array, starting at the specified `startIndex` and with the specified `length`, to a string. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToString/CPP/batostringii.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/ToString/batostringii.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.ToString/FS/batostringii.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.ToString/VB/batostringii.vb" id="Snippet2"::: @@ -2929,7 +2906,6 @@ ## Examples The following code example converts elements of arrays to values with the `ToUInt16` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.UInts/CPP/batouint16.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/ToUInt16/batouint16.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.UInts/FS/batouint16.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.ToXXX.UInts/VB/batouint16.vb" id="Snippet1"::: @@ -3059,7 +3035,6 @@ ## Examples The following code example converts elements of arrays to values with the `ToUInt32` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.UInts/CPP/batouint32.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/ToUInt16/batouint32.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.UInts/FS/batouint32.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.ToXXX.UInts/VB/batouint32.vb" id="Snippet2"::: @@ -3189,7 +3164,6 @@ ## Examples The following code example converts elements of arrays to values with the `ToUInt64` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.UInts/CPP/batouint64.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/BitConverter/ToUInt16/batouint64.cs" interactive="try-dotnet" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.BitConverter.ToXXX.UInts/FS/batouint64.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.BitConverter.ToXXX.UInts/VB/batouint64.vb" id="Snippet3"::: diff --git a/xml/System/Boolean.xml b/xml/System/Boolean.xml index d605eb24868..aa16e1888d6 100644 --- a/xml/System/Boolean.xml +++ b/xml/System/Boolean.xml @@ -201,7 +201,6 @@ This method implements the method for several value and reference types. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/T.CompareTo/CPP/cat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Boolean/CompareTo/cat.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Boolean/CompareTo/cat.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/T.CompareTo/VB/cat.vb" id="Snippet1"::: @@ -700,7 +699,6 @@ The `value` parameter, optionally preceded or trailed by white space, must conta The following code example illustrates the use of method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Boolean/CPP/booleanmembers.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Boolean/Parse/booleanmembers.cs" interactive="try-dotnet-method" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Boolean/Parse/booleanmembers.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Boolean/VB/booleanmembers.vb" id="Snippet2"::: @@ -1972,7 +1970,6 @@ This method returns the constants "True" or "False". The following example illustrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Boolean/CPP/booleanmembers.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Boolean/Parse/booleanmembers.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Boolean/Parse/booleanmembers.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Boolean/VB/booleanmembers.vb" id="Snippet1"::: diff --git a/xml/System/Buffer.xml b/xml/System/Buffer.xml index f5198903357..24154408605 100644 --- a/xml/System/Buffer.xml +++ b/xml/System/Buffer.xml @@ -64,24 +64,21 @@ Manipulates arrays of primitive types. - only affects arrays of primitive types; this class does not apply to objects. Each primitive type is treated as a series of bytes without regard to any behavior or limitation associated with the primitive type. - - provides methods to copy bytes from one array of primitive types to another array of primitive types, get a byte from an array, set a byte in an array, and obtain the length of an array. This class provides better performance for manipulating primitive types than similar methods in the class. - - is applicable to the following primitive types: , , , , , , , , , , , , , and . - - - -## Examples - The following code example illustrates the use of several `Buffer` class methods. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Buffer.BlockCopy/CPP/buffer.cpp" id="Snippet1"::: + only affects arrays of primitive types; this class does not apply to objects. Each primitive type is treated as a series of bytes without regard to any behavior or limitation associated with the primitive type. + + provides methods to copy bytes from one array of primitive types to another array of primitive types, get a byte from an array, set a byte in an array, and obtain the length of an array. This class provides better performance for manipulating primitive types than similar methods in the class. + + is applicable to the following primitive types: , , , , , , , , , , , , , and . + +## Examples + The following code example illustrates the use of several `Buffer` class methods. + :::code language="csharp" source="~/snippets/csharp/System/Buffer/Overview/buffer.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Buffer.BlockCopy/FS/buffer.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Buffer.BlockCopy/VB/buffer.vb" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Buffer.BlockCopy/VB/buffer.vb" id="Snippet1"::: ]]> @@ -147,50 +144,45 @@ The number of bytes to copy. Copies a specified number of bytes from a source array starting at a particular offset to a destination array starting at a particular offset. - method accesses the bytes in the `src` parameter array using offsets into memory, not programming constructs such as indexes or upper and lower array bounds. For example, if in the programming language of your application you declare an array with a zero-based lower bound of -50, and then pass the array and an offset of 5 to the method, the first array element the method will access is the second element of the array, which is at index -49. Furthermore, which byte of array element -49 is accessed first depends on the endianness of the computer that is executing your application. - - As its name suggests, the method copies a block of bytes as a whole, rather than copying one byte at a time. Therefore, if `src` and `dst` reference the same array, and the range from `srcOffset` + `count` -1 overlaps the range from `dstOffset` + `count` - 1, the values of the overlapping bytes are not overwritten before they are copied to the destination. In the following example, the values of bytes 0-16 in an array named `arr` are copied to bytes 12-28. Despite the overlapping range, the values of the source bytes are successfully copied. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Buffer.BlockCopy/CPP/overlap1.cpp" id="Snippet3"::: + method accesses the bytes in the `src` parameter array using offsets into memory, not programming constructs such as indexes or upper and lower array bounds. For example, if in the programming language of your application you declare an array with a zero-based lower bound of -50, and then pass the array and an offset of 5 to the method, the first array element the method will access is the second element of the array, which is at index -49. Furthermore, which byte of array element -49 is accessed first depends on the endianness of the computer that is executing your application. + + As its name suggests, the method copies a block of bytes as a whole, rather than copying one byte at a time. Therefore, if `src` and `dst` reference the same array, and the range from `srcOffset` + `count` -1 overlaps the range from `dstOffset` + `count` - 1, the values of the overlapping bytes are not overwritten before they are copied to the destination. In the following example, the values of bytes 0-16 in an array named `arr` are copied to bytes 12-28. Despite the overlapping range, the values of the source bytes are successfully copied. + :::code language="csharp" source="~/snippets/csharp/System/Buffer/Overview/overlap1.cs" interactive="try-dotnet-method" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Buffer.BlockCopy/FS/overlap1.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Buffer.BlockCopy/VB/overlap1.vb" id="Snippet3"::: - - In the following example, the values of bytes 12-28 in an array named `arr` are copied to bytes 0-16. Again, despite the overlapping range, the values of the source bytes are successfully copied. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Buffer.BlockCopy/CPP/overlap1.cpp" id="Snippet4"::: + + In the following example, the values of bytes 12-28 in an array named `arr` are copied to bytes 0-16. Again, despite the overlapping range, the values of the source bytes are successfully copied. + :::code language="csharp" source="~/snippets/csharp/System/Buffer/Overview/overlap1.cs" interactive="try-dotnet-method" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Buffer.BlockCopy/FS/overlap1.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Buffer.BlockCopy/VB/overlap1.vb" id="Snippet4"::: - - - -## Examples - The following example copies regions of arrays by using the method. For each operation, it lists the source and destination arrays as both an array of values and as a sequence of bytes. The example illustrates the importance of considering a system's endianness when working with the method: Because Windows systems are little-endian, the lower-order bytes of a primitive data type's value precede the higher-order bytes. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Buffer.BlockCopy/CPP/bcopy.cpp" id="Snippet2"::: + +## Examples + The following example copies regions of arrays by using the method. For each operation, it lists the source and destination arrays as both an array of values and as a sequence of bytes. The example illustrates the importance of considering a system's endianness when working with the method: Because Windows systems are little-endian, the lower-order bytes of a primitive data type's value precede the higher-order bytes. + :::code language="csharp" source="~/snippets/csharp/System/Buffer/Overview/bcopy.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Buffer.BlockCopy/FS/bcopy.fs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Buffer.BlockCopy/VB/bcopy.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Buffer.BlockCopy/VB/bcopy.vb" id="Snippet2"::: + ]]> or is . - or is not an array of primitives. - - -or- - - The number of bytes in is less than plus . - - -or- - + or is not an array of primitives. + + -or- + + The number of bytes in is less than plus . + + -or- + The number of bytes in is less than plus . , , or is less than 0. @@ -249,16 +241,15 @@ Returns the number of bytes in the specified array. The number of bytes in the array. - @@ -324,21 +315,20 @@ Retrieves the byte at the specified location in the specified array. The byte at the specified location in the array. - @@ -417,13 +407,13 @@ The target address. The number of bytes available in the destination memory block. The number of bytes to copy. - Copies a number of bytes specified as a long integer value from one address in memory to another. - + Copies a number of bytes specified as a long integer value from one address in memory to another. + This API is not CLS-compliant. - @@ -487,15 +477,15 @@ The target address. The number of bytes available in the destination memory block. The number of bytes to copy. - Copies a number of bytes specified as an unsigned long integer value from one address in memory to another. - + Copies a number of bytes specified as an unsigned long integer value from one address in memory to another. + This API is not CLS-compliant. - @@ -558,21 +548,20 @@ A value to assign. Assigns a specified value to a byte at a particular location in a specified array. - diff --git a/xml/System/Byte.xml b/xml/System/Byte.xml index 02912cd187e..3bda7fb98f0 100644 --- a/xml/System/Byte.xml +++ b/xml/System/Byte.xml @@ -400,12 +400,9 @@ Consult your programming language's documentation to determine whether its compiler performs implicit widening conversions on numeric types. - - ## Examples The following code example demonstrates generic and non-generic versions of the `CompareTo` method for several value and reference types. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/T.CompareTo/CPP/cat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Boolean/CompareTo/cat.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/T.CompareTo/VB/cat.vb" id="Snippet1"::: @@ -492,7 +489,6 @@ ## Examples The following code example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Byte Examples/CPP/systembyte.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Byte/CompareTo/systembyte.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Byte Examples/FS/systembyte.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Byte Examples/VB/systembyte.vb" id="Snippet3"::: @@ -725,7 +721,6 @@ ## Examples The following code example determines whether the first value is equal to the second value, and whether the first value is equal to the boxed version of the second value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.byte.equals/cpp/eq.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Byte/Equals/eq.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.byte.equals/fs/eq.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.byte.equals/vb/eq.vb" id="Snippet1"::: @@ -1264,7 +1259,6 @@ For , this method matches the IEEE 754: ## Examples The following example demonstrates how to use the field to screen variable inputs for values that are outside the range of possible byte values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Byte Examples/CPP/systembyte.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Byte/CompareTo/systembyte.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Byte Examples/FS/systembyte.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Byte Examples/VB/systembyte.vb" id="Snippet1"::: @@ -1376,7 +1370,6 @@ For , this method matches the IEEE 754: ## Examples The following example demonstrates how to use the field to screen variable inputs for values that are outside the range of possible byte values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Byte Examples/CPP/systembyte.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Byte/CompareTo/systembyte.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Byte Examples/FS/systembyte.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Byte Examples/VB/systembyte.vb" id="Snippet1"::: @@ -1471,7 +1464,6 @@ For , this method matches the IEEE 754: ## Examples The following example demonstrates how to convert a string value into a byte value using the method. The resulting byte value is then displayed to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Byte.Parse/cpp/parse.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Byte/Parse/parse.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Byte.Parse/FS/parse.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Byte.Parse/VB/parse.vb" id="Snippet1"::: @@ -1686,7 +1678,6 @@ For , this method matches the IEEE 754: ## Examples The following example parses string representations of `Byte` values with the method. The current culture for the example is en-US. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Byte.Parse/cpp/parse.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Byte/Parse/parse.cs" interactive="try-dotnet-method" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Byte.Parse/FS/parse.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Byte.Parse/VB/parse.vb" id="Snippet3"::: @@ -1804,7 +1795,6 @@ For , this method matches the IEEE 754: ## Examples The following example parses string representations of `Byte` values with the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Byte.Parse/cpp/parse.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Byte/Parse/parse.cs" interactive="try-dotnet-method" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Byte.Parse/FS/parse.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Byte.Parse/VB/parse.vb" id="Snippet2"::: @@ -2041,7 +2031,6 @@ For , this method matches the IEEE 754: ## Examples The following code example parses string representations of `Byte` values with this overload of the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Byte.Parse/cpp/parse.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Byte/Parse/parse.cs" interactive="try-dotnet-method" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Byte.Parse/FS/parse.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Byte.Parse/VB/parse.vb" id="Snippet4"::: @@ -6084,7 +6073,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example displays an array of byte values. Note that the method is not called explicitly in the example. Instead, it is called implicitly, because of the use of the [composite formatting](/dotnet/standard/base-types/composite-formatting) feature, the F# example uses [string interpolation](/dotnet/fsharp/language-reference/interpolated-strings). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Byte.ToString/CPP/newbytemembers2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Byte/ToString/NewByteMembers.cs" interactive="try-dotnet-method" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Byte.ToString/FS/NewByteMembers.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Byte.ToString/VB/NewByteMembers.vb" id="Snippet2"::: @@ -6185,7 +6173,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example iterates an array of byte values and displays each of them to the console by calling the method with different format providers. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Byte.ToString/CPP/newbytemembers.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Byte/ToString/NewByteMembers.cs" interactive="try-dotnet-method" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Byte.ToString/FS/NewByteMembers.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Byte.ToString/VB/NewByteMembers.vb" id="Snippet3"::: @@ -6281,7 +6268,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example initializes a value and displays it to the console using each of the supported standard format strings and a custom format string. The example is run with en-US as the current culture. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Byte.ToString/CPP/newbytemembers2.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Byte/ToString/NewByteMembers.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Byte.ToString/FS/NewByteMembers.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Byte.ToString/VB/NewByteMembers.vb" id="Snippet4"::: @@ -6387,7 +6373,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example uses the standard "N" format string and four different objects to display the string representation of a byte value to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Byte.ToString/CPP/newbytemembers2.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/Byte/ToString/NewByteMembers.cs" interactive="try-dotnet-method" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Byte.ToString/FS/NewByteMembers.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Byte.ToString/VB/NewByteMembers.vb" id="Snippet5"::: @@ -6751,7 +6736,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example calls the method with a number of different string values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Byte.TryParse/cpp/tryparse.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Byte/TryParse/TryParse.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Byte.TryParse/fs/TryParse.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Byte.TryParse/vb/TryParse.vb" id="Snippet1"::: @@ -7122,7 +7106,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example calls the method with a number of different string values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Byte.TryParse/cpp/tryparse2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Byte/TryParse/TryParse2.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Byte.TryParse/fs/TryParse2.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Byte.TryParse/vb/TryParse2.vb" id="Snippet2"::: diff --git a/xml/System/Char.xml b/xml/System/Char.xml index 85f20a2807d..48d1fbf5ad6 100644 --- a/xml/System/Char.xml +++ b/xml/System/Char.xml @@ -261,7 +261,6 @@ . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Char [Type Level]/CPP/charstructure.cpp" id="Snippet23"::: :::code language="csharp" source="~/snippets/csharp/System/Char/Overview/charstructure.cs" interactive="try-dotnet" id="Snippet23"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Char/FS/charstructure.fs" id="Snippet23"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Char [Type Level]/VB/charstructure.vb" id="Snippet23"::: @@ -371,7 +370,6 @@ The following code example demonstrates some of the methods in . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Char.CompareTo/CPP/compareto.cpp" id="Snippet19"::: :::code language="csharp" source="~/snippets/csharp/System/Char/CompareTo/compareto.cs" interactive="try-dotnet" id="Snippet19"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Char.CompareTo/FS/compareto.fs" id="Snippet19"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Char.CompareTo/VB/compareto.vb" id="Snippet19"::: @@ -535,7 +532,6 @@ The following code example demonstrates some of the methods in and methods. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/char.cvtutf32/CPP/utf.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Char/ConvertFromUtf32/utf.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/char.cvtutf32/FS/utf.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/char.cvtutf32/VB/utf.vb" id="Snippet1"::: @@ -566,7 +562,6 @@ The following code example demonstrates some of the methods in and methods. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/char.cvtutf32/CPP/utf.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Char/ConvertFromUtf32/utf.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/char.cvtutf32/FS/utf.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/char.cvtutf32/VB/utf.vb" id="Snippet1"::: @@ -843,7 +838,6 @@ The following code example demonstrates some of the methods in . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Char.Equals/CPP/equals.cpp" id="Snippet20"::: :::code language="csharp" source="~/snippets/csharp/System/Char/Equals/equals.cs" interactive="try-dotnet" id="Snippet20"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Char.Equals/FS/equals.fs" id="Snippet20"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Char.Equals/VB/equals.vb" id="Snippet20"::: @@ -977,7 +971,6 @@ The following code example demonstrates some of the methods in . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Char.GetNumericValue/CPP/getnumericvalue.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Char/GetNumericValue/getnumericvalue.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Char.GetNumericValue/FS/getnumericvalue.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Char.GetNumericValue/VB/getnumericvalue.vb" id="Snippet1"::: @@ -1062,7 +1055,6 @@ The following code example demonstrates some of the methods in . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Char.GetNumericValue/CPP/getnumericvalue.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Char/GetNumericValue/getnumericvalue.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Char.GetNumericValue/FS/getnumericvalue.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Char.GetNumericValue/VB/getnumericvalue.vb" id="Snippet1"::: @@ -1135,7 +1127,6 @@ The following code example demonstrates some of the methods in . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Char.GetUnicodeCategory/CPP/getunicodecategory.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Char/GetUnicodeCategory/getunicodecategory.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Char.GetUnicodeCategory/FS/getunicodecategory.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Char.GetUnicodeCategory/VB/getunicodecategory.vb" id="Snippet1"::: @@ -1795,7 +1786,6 @@ The method does not validate that `maxInclusive` is greater than or equal ## Examples The following example lists the Unicode code point of each of the control characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsControl/CPP/iscontrol1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Char/IsControl/IsControl1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Char.IsControl/FS/IsControl1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Char.IsControl/VB/IsControl1.vb" id="Snippet1"::: @@ -1866,7 +1856,6 @@ The method does not validate that `maxInclusive` is greater than or equal ## Examples The following example enumerates the characters in a string and determines whether any are control characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsControl/CPP/iscontrol2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Char/IsControl/IsControl2.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Char.IsControl/FS/IsControl2.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Char.IsControl/VB/IsControl2.vb" id="Snippet2"::: @@ -1898,7 +1887,6 @@ The method does not validate that `maxInclusive` is greater than or equal ## Examples The following code example demonstrates . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsDigit/CPP/isdigit.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Char/IsDigit/isdigit.cs" interactive="try-dotnet" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Char.IsDigit/FS/isdigit.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Char.IsDigit/VB/isdigit.vb" id="Snippet4"::: @@ -2061,7 +2049,6 @@ The method does not validate that `maxInclusive` is greater than or equal ## Examples The following code example demonstrates the , , and methods. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/char.surrogate/CPP/sur.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Char/IsHighSurrogate/sur.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/char.surrogate/FS/sur.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/char.surrogate/VB/sur.vb" id="Snippet1"::: @@ -2222,7 +2209,6 @@ The method does not validate that `maxInclusive` is greater than or equal The following code example demonstrates . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsLetter/CPP/isletter.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/Char/IsLetter/isletter.cs" interactive="try-dotnet" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Char.IsLetter/FS/isletter.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Char.IsLetter/VB/isletter.vb" id="Snippet5"::: @@ -2401,7 +2387,6 @@ The following code example demonstrates . ## Examples The following code example demonstrates . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsLetterOrDigit/CPP/isletterordigit.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System/Char/IsLetterOrDigit/isletterordigit.cs" interactive="try-dotnet" id="Snippet6"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Char.IsLetterOrDigit/FS/isletterordigit.fs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Char.IsLetterOrDigit/VB/isletterordigit.vb" id="Snippet6"::: @@ -2564,7 +2549,6 @@ The following code example demonstrates . ## Examples The following code example demonstrates . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsLower/CPP/islower.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System/Char/IsLower/islower.cs" interactive="try-dotnet" id="Snippet7"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Char.IsLower/FS/islower.fs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Char.IsLower/VB/islower.vb" id="Snippet7"::: @@ -2725,7 +2709,6 @@ The following code example demonstrates . ## Examples The following code example demonstrates the , , and methods. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/char.surrogate/CPP/sur.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Char/IsHighSurrogate/sur.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/char.surrogate/FS/sur.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/char.surrogate/VB/sur.vb" id="Snippet1"::: @@ -2938,7 +2921,6 @@ The following code example demonstrates . ## Examples The following example demonstrates . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsNumber/CPP/isnumber.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System/Char/IsNumber/isnumber.cs" interactive="try-dotnet" id="Snippet8"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Char.IsNumber/FS/isnumber.fs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Char.IsNumber/VB/isnumber.vb" id="Snippet8"::: @@ -3029,7 +3011,6 @@ The following code example demonstrates . ## Examples The following example demonstrates . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsNumber/CPP/isnumber.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System/Char/IsNumber/isnumber.cs" interactive="try-dotnet" id="Snippet8"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Char.IsNumber/FS/isnumber.fs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Char.IsNumber/VB/isnumber.vb" id="Snippet8"::: @@ -3160,7 +3141,6 @@ The following code example demonstrates . ## Examples The following code example demonstrates . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsPunctuation/CPP/ispunctuation.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System/Char/IsPunctuation/ispunctuation.cs" interactive="try-dotnet" id="Snippet9"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Char.IsPunctuation/FS/ispunctuation.fs" id="Snippet9"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Char.IsPunctuation/VB/ispunctuation.vb" id="Snippet9"::: @@ -3589,7 +3569,6 @@ The following code example demonstrates . ## Examples The following example lists the objects that are classified as separator characters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsSeparator/CPP/isseparator1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Char/IsSeparator/isseparator1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Char.IsSeparator/FS/isseparator1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Char.IsSeparator/VB/isseparator1.vb" id="Snippet1"::: @@ -3677,7 +3656,6 @@ The following code example demonstrates . ## Examples The following example demonstrates . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsSeparator/CPP/isseparator.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System/Char/IsSeparator/isseparator.cs" interactive="try-dotnet" id="Snippet10"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Char.IsSeparator/FS/isseparator.fs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Char.IsSeparator/VB/isseparator.vb" id="Snippet10"::: @@ -3709,7 +3687,6 @@ The following code example demonstrates . ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsSurrogate/CPP/issurrogate.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System/Char/IsSurrogate/issurrogate.cs" interactive="try-dotnet" id="Snippet11"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Char.IsSurrogate/FS/issurrogate.fs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Char.IsSurrogate/VB/issurrogate.vb" id="Snippet11"::: @@ -3865,7 +3842,6 @@ The following code example demonstrates . ## Examples The following code example demonstrates the , , and methods. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/char.surrogate/CPP/sur.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Char/IsHighSurrogate/sur.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/char.surrogate/FS/sur.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/char.surrogate/VB/sur.vb" id="Snippet1"::: @@ -4037,7 +4013,6 @@ The following code example demonstrates . ## Examples The following code example demonstrates . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsSymbol/CPP/issymbol.cpp" id="Snippet12"::: :::code language="csharp" source="~/snippets/csharp/System/Char/IsSymbol/issymbol.cs" interactive="try-dotnet" id="Snippet12"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Char.IsSymbol/FS/issymbol.fs" id="Snippet12"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Char.IsSymbol/VB/issymbol.vb" id="Snippet12"::: @@ -4388,7 +4363,6 @@ The following code example demonstrates . ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Char.IsWhiteSpace/CPP/iswhitespace.cpp" id="Snippet14"::: :::code language="csharp" source="~/snippets/csharp/System/Char/IsWhiteSpace/iswhitespace.cs" interactive="try-dotnet" id="Snippet14"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Char.IsWhiteSpace/FS/iswhitespace.fs" id="Snippet14"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Char.IsWhiteSpace/VB/iswhitespace.vb" id="Snippet14"::: @@ -4707,7 +4681,6 @@ The following code example demonstrates . ## Examples The following code example demonstrates . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Char.Parse/CPP/parse.cpp" id="Snippet15"::: :::code language="csharp" source="~/snippets/csharp/System/Char/Parse/parse.cs" interactive="try-dotnet" id="Snippet15"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Char.Parse/FS/parse.fs" id="Snippet15"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Char.Parse/VB/parse.vb" id="Snippet15"::: @@ -9206,7 +9179,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example demonstrates . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Char.ToLower/CPP/tolower.cpp" id="Snippet16"::: :::code language="csharp" source="~/snippets/csharp/System/Char/ToLower/tolower.cs" interactive="try-dotnet" id="Snippet16"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Char.ToLower/FS/tolower.fs" id="Snippet16"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Char.ToLower/VB/tolower.vb" id="Snippet16"::: @@ -9431,7 +9403,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following code example demonstrates . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Char.ToString/CPP/tostring.cpp" id="Snippet17"::: :::code language="csharp" source="~/snippets/csharp/System/Char/ToString/tostring.cs" interactive="try-dotnet" id="Snippet17"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Char.ToString/FS/tostring.fs" id="Snippet17"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Char.ToString/VB/tostring.vb" id="Snippet17"::: @@ -9915,7 +9886,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following code example demonstrates overloads of the method for several base types, and the method for the base type. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/T.TryParse/CPP/tp.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Char/TryParse/tp.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/T.TryParse/FS/tp.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/T.TryParse/VB/tp.vb" id="Snippet1"::: diff --git a/xml/System/CharEnumerator.xml b/xml/System/CharEnumerator.xml index 1709d852659..42064ab1eb7 100644 --- a/xml/System/CharEnumerator.xml +++ b/xml/System/CharEnumerator.xml @@ -98,14 +98,12 @@ ## Examples The following example uses the class to enumerate the individual characters in a string. It instantiates a object by calling the method, moves from one character to the next by calling the method, and displays the current character by retrieving the value of the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.CharEnumerator.Class/cpp/charenumerator1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/CharEnumerator/Overview/CharEnumerator1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.CharEnumerator.Class/fs/CharEnumerator1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.CharEnumerator.Class/vb/CharEnumerator1.vb" id="Snippet1"::: Note, however, that the same operation can be performed somewhat more intuitively by using `foreach` (in C#) or `For Each` (in Visual Basic), as the following example shows. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.CharEnumerator.Class/cpp/charenumerator1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/CharEnumerator/Overview/CharEnumerator1.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.CharEnumerator.Class/fs/CharEnumerator1.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.CharEnumerator.Class/vb/CharEnumerator1.vb" id="Snippet2"::: @@ -239,14 +237,12 @@ ## Examples The following example uses the class to enumerate the individual characters in a string. It instantiates a object by calling the method, moves from one character to the next by calling the method, and displays the current character by retrieving the value of the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.CharEnumerator.Class/cpp/charenumerator1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/CharEnumerator/Overview/CharEnumerator1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.CharEnumerator.Class/fs/CharEnumerator1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.CharEnumerator.Class/vb/CharEnumerator1.vb" id="Snippet1"::: Note, however, that the same operation can be performed somewhat more intuitively by using `foreach` (in C#) or `For Each` (in Visual Basic), as the following example shows. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.CharEnumerator.Class/cpp/charenumerator1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/CharEnumerator/Overview/CharEnumerator1.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.CharEnumerator.Class/fs/CharEnumerator1.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.CharEnumerator.Class/vb/CharEnumerator1.vb" id="Snippet2"::: @@ -366,14 +362,12 @@ ## Examples The following example uses the class to enumerate the individual characters in a string. It instantiates a object by calling the method, moves from one character to the next by calling the method, and displays the current character by retrieving the value of the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.CharEnumerator.Class/cpp/charenumerator1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/CharEnumerator/Overview/CharEnumerator1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.CharEnumerator.Class/fs/CharEnumerator1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.CharEnumerator.Class/vb/CharEnumerator1.vb" id="Snippet1"::: Note, however, that the same operation can be performed somewhat more intuitively by using `foreach` (in C#) or `For Each` (in Visual Basic), as the following example shows. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.CharEnumerator.Class/cpp/charenumerator1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/CharEnumerator/Overview/CharEnumerator1.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.CharEnumerator.Class/fs/CharEnumerator1.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.CharEnumerator.Class/vb/CharEnumerator1.vb" id="Snippet2"::: diff --git a/xml/System/Comparison`1.xml b/xml/System/Comparison`1.xml index 4548e6b7462..fa4e2613f88 100644 --- a/xml/System/Comparison`1.xml +++ b/xml/System/Comparison`1.xml @@ -74,47 +74,46 @@ The first object to compare. The second object to compare. Represents the method that compares two objects of the same type. - A signed integer that indicates the relative values of and , as shown in the following table. - - Value - - Meaning - - Less than 0 - - is less than . - - 0 - - equals . - - Greater than 0 - - is greater than . - + A signed integer that indicates the relative values of and , as shown in the following table. + + Value + + Meaning + + Less than 0 + + is less than . + + 0 + + equals . + + Greater than 0 + + is greater than . + - method overload of the class and the method overload of the class to sort the elements of an array or list. - - - -## Examples - The following code example demonstrates the use of the delegate with the method overload. - - The code example defines an alternative comparison method for strings, named `CompareDinosByLength`. This method works as follows: First, the comparands are tested for `null`, and a null reference is treated as less than a non-null. Second, the string lengths are compared, and the longer string is deemed to be greater. Third, if the lengths are equal, ordinary string comparison is used. - - 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. + method overload of the class and the method overload of the class to sort the elements of an array or list. + + + +## Examples + The following code example demonstrates the use of the delegate with the method overload. + + The code example defines an alternative comparison method for strings, named `CompareDinosByLength`. This method works as follows: First, the comparands are tested for `null`, and a null reference is treated as less than a non-null. Second, the string lengths are compared, and the longer string is deemed to be greater. Third, if the lengths are equal, ordinary string comparison is used. + + 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="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/List`1_SortComparison/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/List`1_SortComparison/vb/source.vb" id="Snippet1"::: - The following example uses the delegate to sort the elements of a collection of `CityInfo` objects. `CityInfo` is an application-defined class that contains information about a city and its population. The example defines three methods, `CompareByName`, `CompareByPopulation`, and `CompareByNames`, that offer three different ways of ordering the `CityInfo` objects. Each method is assigned to the `comparison` argument of the method. - + The following example uses the delegate to sort the elements of a collection of `CityInfo` objects. `CityInfo` is an application-defined class that contains information about a city and its population. The example defines three methods, `CompareByName`, `CompareByPopulation`, and `CompareByNames`, that offer three different ways of ordering the `CityInfo` objects. Each method is assigned to the `comparison` argument of the method. + :::code language="csharp" source="~/snippets/csharp/System/ComparisonT/Overview/comparisont1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.comparison`1/fs/comparisont1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.comparison`1/vb/comparisont1.vb" id="Snippet1"::: diff --git a/xml/System/Console.xml b/xml/System/Console.xml index 60aabe3b375..ed6a5ffbade 100644 --- a/xml/System/Console.xml +++ b/xml/System/Console.xml @@ -224,12 +224,9 @@ wraps a call to the Windows [Beep function](/windows/win32/api/utilapiset/nf-utilapiset-beep). Whether produces a sound on versions of Windows before Windows 7 depends on the presence of a 8254 programmable interval timer chip. Starting with Windows 7, it depends on the default sound device. - - ## Examples The following example demonstrates the method. The example accepts a number from 1 through 9 as a command line argument, and plays the beep that number of times. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.beep/CPP/beep.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Beep/beep.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.beep/FS/beep.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.beep/VB/beep.vb" id="Snippet1"::: @@ -302,7 +299,6 @@ ## Examples This example demonstrates the method by playing the first few notes of a song through the console speaker. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.beep2/CPP/b2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Beep/b2.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.beep2/FS/b2.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.beep2/VB/b2.vb" id="Snippet1"::: @@ -399,7 +395,6 @@ ## Examples This example demonstrates the and properties. The example reports the dimensions of an operating system window set to a buffer size of 300 rows and 85 columns. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.bufferHW/CPP/hw.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/BufferHeight/hw.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.bufferHW/FS/hw.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.bufferHW/VB/hw.vb" id="Snippet1"::: @@ -499,7 +494,6 @@ ## Examples This example demonstrates the and properties. The example reports the dimensions of an operating system window set to a buffer size of 300 rows and 85 columns. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.bufferHW/CPP/hw.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/BufferHeight/hw.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.bufferHW/FS/hw.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.bufferHW/VB/hw.vb" id="Snippet1"::: @@ -610,7 +604,6 @@ ## Examples The following example demonstrates how the event is used. When you press Ctrl+C, the read operation is interrupted and the `myHandler` event handler is invoked. Upon entry to the event handler, the property is `false`, which means that the current process will terminate when the event handler terminates. However, the event handler sets the property to `true`, which means that the process will not terminate and the read operation will resume. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.cancelkeypress/cpp/ckp.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/CancelKeyPress/ckp.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.cancelkeypress/fs/ckp.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.cancelkeypress/vb/ckp.vb" id="Snippet1"::: @@ -753,7 +746,6 @@ This example demonstrates the and properties, and the and methods. The example positions the cursor, which determines where the next write will occur, to draw a 5 character by 5 character rectangle using a combination of "+", "|", and "-" strings. Note that the rectangle could be drawn with fewer steps using a combination of other strings. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.cursorLTS/CPP/lts.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Clear/lts.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.cursorLTS/FS/lts.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.cursorLTS/VB/lts.vb" id="Snippet1"::: @@ -833,7 +825,6 @@ ## Examples This example demonstrates the and properties, and the and methods. The example positions the cursor, which determines where the next write will occur, to draw a 5 character by 5 character rectangle using a combination of "+", "|", and "-" strings. Note that the rectangle could be drawn with fewer steps using a combination of other strings. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.cursorLTS/CPP/lts.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Clear/lts.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.cursorLTS/FS/lts.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.cursorLTS/VB/lts.vb" id="Snippet1"::: @@ -928,7 +919,6 @@ ## Examples This example demonstrates the property. The example increases the size of the cursor each time any console key is pressed, then restores the cursor to its original size before terminating. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.cursorsize/CPP/csize.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/CursorSize/csize.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.cursorsize/FS/csize.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.cursorsize/VB/csize.vb" id="Snippet1"::: @@ -1011,7 +1001,6 @@ ## Examples This example demonstrates the and properties, and the and methods. The example positions the cursor, which determines where the next write will occur, to draw a 5 character by 5 character rectangle using a combination of "+", "|", and "-" strings. Note that the rectangle could be drawn with fewer steps using a combination of other strings. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.cursorLTS/CPP/lts.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Clear/lts.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.cursorLTS/FS/lts.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.cursorLTS/VB/lts.vb" id="Snippet1"::: @@ -1102,7 +1091,6 @@ ## Examples This example demonstrates the property. The example makes the cursor visible if the first column of input is a '+' character or invisible if the input is a '-' character. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.cursorvis/CPP/vis.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/CursorVisible/vis.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.cursorvis/FS/vis.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.cursorvis/VB/vis.vb" id="Snippet1"::: @@ -1176,7 +1164,6 @@ ## Examples The following example is a command line utility named ExpandTabs that replaces tab characters in a text file with four spaces, the value defined by the `tabSize` variable. It redirects the standard input and output streams to files, but uses the property to write the standard error stream to the console. It can be launched from the command line by supplying the name of the file that contains tab characters and the name of the output file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Console-EXPANDTABSEX/CPP/expandtabsex.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Error/expandtabsex.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Console-EXPANDTABSEX/FS/expandtabsex.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Console-EXPANDTABSEX/VB/expandtabsex.vb" id="Snippet1"::: @@ -1426,7 +1413,6 @@ Columns are numbered from left to right starting at 0. Rows are numbered from to ## Examples The following sample illustrates the use of the `In` property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/consolein/CPP/consolein.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/In/consolein.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/consolein/FS/consolein.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/consolein/VB/consolein.vb" id="Snippet1"::: @@ -1728,7 +1714,6 @@ Columns are numbered from left to right starting at 0. Rows are numbered from to ## Examples The following example demonstrates how to use the property to create a loop that runs until a key is pressed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.keyavailable/CPP/ka.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/KeyAvailable/ka.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.keyavailable/FS/ka.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.keyavailable/VB/ka.vb" id="Snippet1"::: @@ -2333,7 +2318,6 @@ This method can be used to reacquire the standard input stream after it has been The following example illustrates the use of the `OpenStandardInput` method. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console.OpenStandartInput/CPP/decode.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/OpenStandardInput/decode.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console.OpenStandartInput/FS/decode.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.OpenStandartInput/VB/decode.vb" id="Snippet1"::: @@ -2474,7 +2458,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example illustrates the use of the method. It replaces four consecutive space characters in a string with a tab character. To run it, you must supply two command-line arguments. The first is the name of an existing text file to redirect the standard input stream to. The second is the name of a file to redirect the standard output stream to. This file need not exist. If it does, its contents will be overwritten. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console-INSERTTABS/CPP/inserttabs.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/OpenStandardOutput/inserttabs.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console-INSERTTABS/FS/inserttabs.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-INSERTTABS/VB/inserttabs.vb" id="Snippet1"::: @@ -2539,7 +2522,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example illustrates the use of the method. It replaces four consecutive space characters in a string with a tab character. To run it, you must supply two command line arguments. The first is the name of an existing text file to redirect the standard input stream to. The second is the name of a file to redirect the standard output stream to. This file need not exist. If it does, its contents will be overwritten. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console-INSERTTABS/CPP/inserttabs.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/OpenStandardOutput/inserttabs.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console-INSERTTABS/FS/inserttabs.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-INSERTTABS/VB/inserttabs.vb" id="Snippet1"::: @@ -2778,7 +2760,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.read/CPP/read.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Read/read.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.read/FS/read.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.read/VB/read.vb" id="Snippet1"::: @@ -2879,7 +2860,6 @@ This method can be used to reacquire the standard output stream after it has bee The following example uses the method to display information about which key the user pressed. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.readkey1/CPP/rk.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/ReadKey/rk.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.readkey1/FS/rk.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.readkey1/VB/rk.vb" id="Snippet1"::: @@ -2978,7 +2958,6 @@ This method can be used to reacquire the standard output stream after it has bee The following example uses the method to display information about the key pressed by a user without echoing that key to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.readkey2/CPP/rkbool.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/ReadKey/rkbool.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.readkey2/FS/rkbool.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.readkey2/VB/rkbool.vb" id="Snippet1"::: @@ -3053,7 +3032,6 @@ This method can be used to reacquire the standard output stream after it has bee One of the most common uses of the method is to pause program execution before clearing the console and displaying new information to it, or to prompt the user to press the Enter key before terminating the application. The following example illustrates this. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console.ReadLine/cpp/ReadLineSimple.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System/Console/ReadLine/ReadLineSimple.cs" id="Snippet6"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console.ReadLine/fs/ReadLineSimple.fs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.ReadLine/vb/ReadLineSimple.vb" id="Snippet6"::: @@ -3089,7 +3067,6 @@ This method can be used to reacquire the standard output stream after it has bee If the Ctrl+Z key combination (followed by Enter on Windows) is pressed when the method is reading input from the console, the method returns `null`. This enables the user to prevent further keyboard input when the method is called in a loop. The following example illustrates this scenario. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console.ReadLine/cpp/readline2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/ReadLine/ReadLine2.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console.ReadLine/fs/ReadLine2.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.ReadLine/vb/ReadLine2.vb" id="Snippet1"::: @@ -3097,7 +3074,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example requires two command line arguments: the name of an existing text file, and the name of a file to write the output to. It opens the existing text file and redirects the standard input from the keyboard to that file. It also redirects the standard output from the console to the output file. It then uses the method to read each line in the file, replaces every sequence of four spaces with a tab character, and uses the method to write the result to the output file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console-INSERTTABS/CPP/inserttabs.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/OpenStandardOutput/inserttabs.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console-INSERTTABS/FS/inserttabs.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-INSERTTABS/VB/inserttabs.vb" id="Snippet1"::: @@ -3252,7 +3228,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example demonstrates the , , , , , , and properties; and the , , and methods. The example draws a grid pattern in the screen buffer based on the screen buffer width. Then the example moves the console window in response to which of the UP ARROW, DOWN ARROW, LEFT ARROW, or RIGHT ARROW console keys is pressed. The grid pattern helps you see the movement of the console window relative to the screen buffer. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.windowLT/CPP/wlt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/SetBufferSize/wlt.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.windowLT/VB/wlt.vb" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.windowLT/FS/wlt.fs" id="Snippet1"::: @@ -3356,7 +3331,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples This example demonstrates the and properties, and the and methods. The example positions the cursor, which determines where the next write will occur, to draw a 5 character by 5 character rectangle using a combination of "+", "|", and "-" strings. Note that the rectangle could be drawn with fewer steps using a combination of other strings. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.cursorLTS/CPP/lts.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Clear/lts.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.cursorLTS/FS/lts.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.cursorLTS/VB/lts.vb" id="Snippet1"::: @@ -3438,7 +3412,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example shows how to redirect the standard error stream to a file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console.SetError/cpp/seterror1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/SetError/SetError1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console.SetError/fs/SetError1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.SetError/vb/SetError1.vb" id="Snippet1"::: @@ -3529,7 +3502,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example illustrates the use of the method. It replaces four consecutive space characters in a string with a tab character. To run it, you must supply two command line arguments. The first is the name of an existing text file to redirect the standard input stream to. The second is the name of a file to redirect the standard output stream to. This file need not exist. If it does, its contents will be overwritten. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console-INSERTTABS/CPP/inserttabs.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/OpenStandardOutput/inserttabs.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console-INSERTTABS/FS/inserttabs.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-INSERTTABS/VB/inserttabs.vb" id="Snippet1"::: @@ -3599,7 +3571,6 @@ This method can be used to reacquire the standard output stream after it has bee A that encapsulates a can be used to send output to a file. For example: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.console.setout/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/SetOut/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.console.setout/fs/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.console.setout/vb/source.vb" id="Snippet1"::: @@ -3609,7 +3580,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example illustrates the use of the method. It replaces four consecutive space characters in a string with a tab character. To run it, you must supply two command line arguments. The first is the name of an existing text file to redirect the standard input stream to. The second is the name of a file to redirect the standard output stream to. This file need not exist. If it does, its contents will be overwritten. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console-INSERTTABS/CPP/inserttabs.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/OpenStandardOutput/inserttabs.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console-INSERTTABS/FS/inserttabs.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-INSERTTABS/VB/inserttabs.vb" id="Snippet1"::: @@ -3689,7 +3659,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example demonstrates the , , , , , , and properties; and the , , and methods. The example draws a grid pattern in the screen buffer based on the screen buffer width. Then the example moves the console window in response to which of the UP ARROW, DOWN ARROW, LEFT ARROW, or RIGHT ARROW console keys is pressed. The grid pattern helps you see the movement of the console window relative to the screen buffer. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.windowLT/CPP/wlt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/SetBufferSize/wlt.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.windowLT/VB/wlt.vb" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.windowLT/FS/wlt.fs" id="Snippet1"::: @@ -3788,7 +3757,6 @@ This method can be used to reacquire the standard output stream after it has bee The example reports the dimensions of a console window set to 85 columns and 43 rows, then waits for a key to be pressed. When any key is pressed, the dimensions of the console window are halved, the new dimensions are reported, and the example waits for another key press. Finally, when any key is pressed, the console window is restored to its original dimensions and the example terminates. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.setwindowsize/CPP/sws.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/SetWindowSize/sws.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.setwindowsize/FS/sws.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.setwindowsize/VB/sws.vb" id="Snippet1"::: @@ -3884,7 +3852,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples This example demonstrates the property. The example displays the current title of the operating system window, waits for a key press, then displays a new title. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.title/CPP/mytitle.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Title/mytitle.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.title/FS/mytitle.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.title/VB/mytitle.vb" id="Snippet1"::: @@ -3977,7 +3944,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example demonstrates the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.readkey1/CPP/rk.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/ReadKey/rk.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.readkey1/FS/rk.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.readkey1/VB/rk.vb" id="Snippet1"::: @@ -4087,7 +4053,6 @@ This method can be used to reacquire the standard output stream after it has bee The example reports the dimensions of a console window set to 85 columns and 43 rows, then waits for a key press. When any key is pressed, the dimensions of the console window are halved, the new dimensions are reported, and the example waits for another key press. Finally, when any key is pressed the console window is restored to its original dimensions and the example terminates. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.setwindowsize/CPP/sws.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/SetWindowSize/sws.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.setwindowsize/FS/sws.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.setwindowsize/VB/sws.vb" id="Snippet1"::: @@ -4176,7 +4141,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example opens an 80-column console window and defines a buffer area that is 120 columns wide. It displays information on window and buffer size, and then waits for the user to press either the LEFT ARROW key or the RIGHT ARROW key. In the former case, it decrements the value of the property by one if the result is a legal value. In the latter case, it increases the value of the property by one if the result would be legal. Note that the example does not have to handle an , because it checks that the value to be assigned to the property is not negative and does not cause the sum of the and properties to exceed the property value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.console.windowleft/cpp/windowleft1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/WindowLeft/windowleft1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.console.windowleft/fs/windowleft1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.console.windowleft/vb/windowleft1.vb" id="Snippet1"::: @@ -4257,7 +4221,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example demonstrates the , , , , , , and properties; and the , , and methods. The example draws a grid pattern in the screen buffer based on the screen buffer width. Then the example moves the console window in response to which of the UP ARROW, DOWN ARROW, LEFT ARROW, or RIGHT ARROW console keys is pressed. The grid pattern helps you see the movement of the console window relative to the screen buffer. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.windowLT/CPP/wlt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/SetBufferSize/wlt.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.windowLT/VB/wlt.vb" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.windowLT/FS/wlt.fs" id="Snippet1"::: @@ -4370,7 +4333,6 @@ This method can be used to reacquire the standard output stream after it has bee The example reports the dimensions of a console window set to 85 columns and 43 rows, then waits for a key press. When any key is pressed, the dimensions of the console window are halved, the new dimensions are reported, and the example waits for another key press. Finally, when any key is pressed the console window is restored to its original dimensions and the example terminates. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.setwindowsize/CPP/sws.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/SetWindowSize/sws.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.setwindowsize/FS/sws.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.setwindowsize/VB/sws.vb" id="Snippet1"::: @@ -4453,7 +4415,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example illustrates the use of the `Write` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Write/reformat.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: @@ -4514,7 +4475,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example illustrates the use of the `Write` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Write/reformat.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: @@ -4630,7 +4590,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example illustrates the use of the `Write` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Write/reformat.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: @@ -4696,7 +4655,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example illustrates the use of the `Write` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Write/reformat.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: @@ -4762,7 +4720,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example illustrates the use of the `Write` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Write/reformat.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: @@ -4828,7 +4785,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example illustrates the use of the `Write` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Write/reformat.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: @@ -4895,7 +4851,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example illustrates the use of the `Write` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Write/reformat.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: @@ -4988,7 +4943,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example illustrates the use of the `Write` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Write/reformat.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: @@ -5055,7 +5009,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example illustrates the use of the `Write` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Write/reformat.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: @@ -5127,7 +5080,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example illustrates the use of the `Write` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Write/reformat.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: @@ -5199,7 +5151,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example illustrates the use of the `Write` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Write/reformat.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: @@ -5298,14 +5249,12 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example uses the `WriteLine` method to demonstrate the standard formatting specifiers for numbers, dates, and enumerations. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.writelineFmt1/cpp/wl.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Write/wl.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.writelineFmt1/fs/wl.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.writelineFmt1/vb/wl.vb" id="Snippet1"::: The following example illustrates the use of the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Write/reformat.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: @@ -5646,14 +5595,12 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example uses the `WriteLine` method to demonstrate the standard formatting specifiers for numbers, dates, and enumerations. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.writelineFmt1/cpp/wl.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Write/wl.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.writelineFmt1/fs/wl.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.writelineFmt1/vb/wl.vb" id="Snippet1"::: The following example illustrates the use of the `Write` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Write/reformat.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: @@ -5758,14 +5705,12 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example uses the `WriteLine` method to demonstrate the standard formatting specifiers for numbers, dates, and enumerations. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.writelineFmt1/cpp/wl.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Write/wl.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.writelineFmt1/fs/wl.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.writelineFmt1/vb/wl.vb" id="Snippet1"::: The following example illustrates the use of the `Write` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console-REFORMAT/CPP/reformat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Write/reformat.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console-REFORMAT/FS/reformat.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console-REFORMAT/VB/reformat.vb" id="Snippet1"::: @@ -5862,7 +5807,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example illustrates the use of variable parameters with the method. The method is called with a composite format string and five format items. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.console.write/cpp/con_write.cpp" id="Snippet3"::: ]]> @@ -5947,7 +5891,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The example changes the line terminator from its default value of "\r\n" or `vbCrLf` to "\r\n\r\n" or `vbCrLf` + `vbCrLf`. It then calls the and methods to display output to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console.WriteLine/CPP/newline1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Console/WriteLine/newline1.cs" interactive="try-dotnet-method" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/newline1.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.WriteLine/VB/newline1.vb" id="Snippet2"::: @@ -6017,7 +5960,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example generates ten random integers and uses the method to indicate whether they are even. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console.WriteLine/CPP/writeline_boolean1.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Console/WriteLine/writeline_boolean1.cs" interactive="try-dotnet-method" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/writeline_boolean1.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.WriteLine/VB/writeline_boolean1.vb" id="Snippet4"::: @@ -6476,7 +6418,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example uses the method to display each value in an object array to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console.WriteLine/CPP/writeline_obj1.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Console/WriteLine/writeline_obj1.cs" interactive="try-dotnet-method" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/writeline_obj1.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.WriteLine/VB/writeline_obj1.vb" id="Snippet3"::: @@ -6639,7 +6580,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The example changes the line terminator from its default value of "\r\n" or `vbCrLf` to "\r\n\r\n" or `vbCrLf` + `vbCrLf`. It then calls the and methods to display output to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Console.WriteLine/CPP/newline1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Console/WriteLine/newline1.cs" interactive="try-dotnet-method" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Console.WriteLine/FS/newline1.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Console.WriteLine/VB/newline1.vb" id="Snippet2"::: @@ -7001,7 +6941,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example demonstrates the standard formatting specifiers for numbers, dates, and enumerations. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.writelineFmt1/cpp/wl.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Write/wl.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.writelineFmt1/fs/wl.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.writelineFmt1/vb/wl.vb" id="Snippet1"::: @@ -7235,7 +7174,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example demonstrates the standard formatting specifiers for numbers, dates, and enumerations. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.writelineFmt1/cpp/wl.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Write/wl.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.writelineFmt1/fs/wl.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.writelineFmt1/vb/wl.vb" id="Snippet1"::: @@ -7348,7 +7286,6 @@ This method can be used to reacquire the standard output stream after it has bee ## Examples The following example demonstrates the standard formatting specifiers for numbers, dates, and enumerations. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.writelineFmt1/cpp/wl.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/Write/wl.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.writelineFmt1/fs/wl.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.writelineFmt1/vb/wl.vb" id="Snippet1"::: @@ -7448,8 +7385,6 @@ This method can be used to reacquire the standard output stream after it has bee For more information about the line terminator, see the Remarks section of the method that takes no parameters. - - ## Examples The following example illustrates the use of variable arguments with the method. The method is called with a composite format string and five format items. diff --git a/xml/System/ConsoleCancelEventArgs.xml b/xml/System/ConsoleCancelEventArgs.xml index f3fc91cddbb..06e6f1304b6 100644 --- a/xml/System/ConsoleCancelEventArgs.xml +++ b/xml/System/ConsoleCancelEventArgs.xml @@ -61,7 +61,6 @@ ## Examples The following example demonstrates how to use the class to handle an event. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.cancelkeypress/cpp/ckp.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/CancelKeyPress/ckp.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.cancelkeypress/fs/ckp.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.cancelkeypress/vb/ckp.vb" id="Snippet1"::: @@ -122,7 +121,6 @@ ## Examples The following example demonstrates how to use the property to handle an event. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.cancelkeypress/cpp/ckp.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/CancelKeyPress/ckp.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.cancelkeypress/fs/ckp.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.cancelkeypress/vb/ckp.vb" id="Snippet1"::: @@ -182,7 +180,6 @@ ## Examples The following example demonstrates how to use the property to handle an event. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.cancelkeypress/cpp/ckp.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Console/CancelKeyPress/ckp.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.cancelkeypress/fs/ckp.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.cancelkeypress/vb/ckp.vb" id="Snippet1"::: diff --git a/xml/System/ConsoleCancelEventHandler.xml b/xml/System/ConsoleCancelEventHandler.xml index 3221a96d317..1e266232ed0 100644 --- a/xml/System/ConsoleCancelEventHandler.xml +++ b/xml/System/ConsoleCancelEventHandler.xml @@ -60,21 +60,18 @@ A object that contains the event data. Represents the method that will handle the event of a . - delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). - - - -## Examples - The following code example demonstrates how to use the class to handle an event. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.cancelkeypress/cpp/ckp.cpp" id="Snippet1"::: + delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event-handler delegates, see [Handling and Raising Events](/dotnet/standard/events/). + +## Examples + The following code example demonstrates how to use the class to handle an event. + :::code language="csharp" source="~/snippets/csharp/System/Console/CancelKeyPress/ckp.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.cancelkeypress/fs/ckp.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.cancelkeypress/vb/ckp.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.cancelkeypress/vb/ckp.vb" id="Snippet1"::: + ]]> diff --git a/xml/System/ConsoleKey.xml b/xml/System/ConsoleKey.xml index 7d99cf6dcd0..2ada2cca609 100644 --- a/xml/System/ConsoleKey.xml +++ b/xml/System/ConsoleKey.xml @@ -50,21 +50,18 @@ Specifies the standard keys on a console. - enumeration is typically used in the nfo structure, which is returned by the method to indicate which key on the console has been pressed. - - - -## Examples - The following example uses the enumeration to indicate to the user which key the user had pressed. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.ConsoleKey/cpp/consolekey.cpp" id="Snippet1"::: + enumeration is typically used in the nfo structure, which is returned by the method to indicate which key on the console has been pressed. + +## Examples + The following example uses the enumeration to indicate to the user which key the user had pressed. + :::code language="csharp" source="~/snippets/csharp/System/ConsoleKey/Overview/ConsoleKey1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKey/fs/ConsoleKey1.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.ConsoleKey/vb/ConsoleKey1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.ConsoleKey/vb/ConsoleKey1.vb" id="Snippet1"::: + ]]> diff --git a/xml/System/ConsoleKeyInfo.xml b/xml/System/ConsoleKeyInfo.xml index 1f61ed5f758..891effcec0d 100644 --- a/xml/System/ConsoleKeyInfo.xml +++ b/xml/System/ConsoleKeyInfo.xml @@ -64,23 +64,22 @@ Describes the console key that was pressed, including the character represented by the console key and the state of the SHIFT, ALT, and CTRL modifier keys. - type is not intended to be created by users. Instead, it is returned to the user in response to calling the method. - - The object describes the constant and Unicode character, if any, that correspond to the pressed console key. The object also describes, in a bitwise combination of values, whether one or more SHIFT, ALT, or CTRL modifier keys was pressed simultaneously with the console key. - - - -## Examples - The following example demonstrates using a object in a read operation. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.readkey1/CPP/rk.cpp" id="Snippet1"::: + type is not intended to be created by users. Instead, it is returned to the user in response to calling the method. + + The object describes the constant and Unicode character, if any, that correspond to the pressed console key. The object also describes, in a bitwise combination of values, whether one or more SHIFT, ALT, or CTRL modifier keys was pressed simultaneously with the console key. + + + +## Examples + The following example demonstrates using a object in a read operation. + :::code language="csharp" source="~/snippets/csharp/System/Console/ReadKey/rk.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.readkey1/FS/rk.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.readkey1/VB/rk.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.readkey1/VB/rk.vb" id="Snippet1"::: + ]]> @@ -137,13 +136,13 @@ to indicate that a CTRL key was pressed; otherwise, . Initializes a new instance of the structure using the specified character, console key, and modifier keys. - method. - - The type does not specify whether the left or right SHIFT, ALT, or CTRL modifier key was pressed. - + method. + + The type does not specify whether the left or right SHIFT, ALT, or CTRL modifier key was pressed. + ]]> The numeric value of the parameter is less than 0 or greater than 255. @@ -208,13 +207,13 @@ if is equal to the current object; otherwise, . - objects are equal if their corresponding , , and properties are equal. - - The method performs slightly better than the method because it does not have to convert `obj` to an object. - + objects are equal if their corresponding , , and properties are equal. + + The method performs slightly better than the method because it does not have to convert `obj` to an object. + ]]> @@ -271,21 +270,20 @@ if is a object and is equal to the current object; otherwise, . - objects are equal if their corresponding , , and properties are equal. - - - -## Examples - The following example demonstrates the method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.Equals/cpp/consolekeyinfo.equals.cpp" id="Snippet1"::: + objects are equal if their corresponding , , and properties are equal. + + + +## Examples + The following example demonstrates the method. + :::code language="csharp" source="~/snippets/csharp/System/ConsoleKeyInfo/Equals/equals.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.Equals/fs/equals.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.ConsoleKeyInfo.Equals/vb/equals.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.ConsoleKeyInfo.Equals/vb/equals.vb" id="Snippet1"::: + ]]> @@ -330,21 +328,20 @@ Returns the hash code for the current object. A 32-bit signed integer hash code. - method is not suitable for distinguishing one object from another. If your application needs a unique hash code, override the method with your own method. - - - -## Examples - The following example demonstrates the method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.GetHashcode/cpp/hash.cpp" id="Snippet1"::: + method is not suitable for distinguishing one object from another. If your application needs a unique hash code, override the method with your own method. + + + +## Examples + The following example demonstrates the method. + :::code language="csharp" source="~/snippets/csharp/System/ConsoleKeyInfo/GetHashCode/hash.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.ConsoleKeyInfo.GetHashcode/fs/hash.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.ConsoleKeyInfo.GetHashcode/vb/hash.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.ConsoleKeyInfo.GetHashcode/vb/hash.vb" id="Snippet1"::: + ]]> @@ -388,16 +385,15 @@ Gets the console key represented by the current object. A value that identifies the console key that was pressed. - property in a read operation. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.readkey1/CPP/rk.cpp" id="Snippet1"::: + property in a read operation. + :::code language="csharp" source="~/snippets/csharp/System/Console/ReadKey/rk.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.readkey1/FS/rk.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.readkey1/VB/rk.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.readkey1/VB/rk.vb" id="Snippet1"::: + ]]> @@ -441,20 +437,20 @@ Gets the Unicode character represented by the current object. An object that corresponds to the console key represented by the current object. - property is \U0000. - - - -## Examples - The following example uses the property to add the characters input by the user into a string. The example ignores special keys other than **ENTER**, **ESC**, and **BACKSPACE**. - + property is \U0000. + + + +## Examples + The following example uses the property to add the characters input by the user into a string. The example ignores special keys other than **ENTER**, **ESC**, and **BACKSPACE**. + :::code language="csharp" source="~/snippets/csharp/System/ConsoleKeyInfo/KeyChar/keychar1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.consolekeyinfo.keychar/fs/keychar1.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.consolekeyinfo.keychar/vb/keychar1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.consolekeyinfo.keychar/vb/keychar1.vb" id="Snippet1"::: + ]]> @@ -498,16 +494,15 @@ Gets a bitwise combination of values that specifies one or more modifier keys pressed simultaneously with the console key. A bitwise combination of the enumeration values. There is no default value. - property in a read operation. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.readkey1/CPP/rk.cpp" id="Snippet1"::: + property in a read operation. + :::code language="csharp" source="~/snippets/csharp/System/Console/ReadKey/rk.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.readkey1/FS/rk.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.readkey1/VB/rk.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.readkey1/VB/rk.vb" id="Snippet1"::: + ]]> @@ -558,11 +553,11 @@ if is equal to ; otherwise, . - objects are equal if their corresponding , , and properties are equal. - + objects are equal if their corresponding , , and properties are equal. + The equivalent method for this operator is .]]> @@ -613,11 +608,11 @@ if is not equal to ; otherwise, . - objects are equal if their corresponding , , and properties are equal. - + objects are equal if their corresponding , , and properties are equal. + ]]> diff --git a/xml/System/ConsoleModifiers.xml b/xml/System/ConsoleModifiers.xml index 1ae04d23c7f..909239a9869 100644 --- a/xml/System/ConsoleModifiers.xml +++ b/xml/System/ConsoleModifiers.xml @@ -54,23 +54,20 @@ Represents the SHIFT, ALT, and CTRL modifier keys on a keyboard. - enumeration is used in conjunction with the type. - - - -## Examples - The following code example reads a key and determines whether one or more modifier keys was pressed. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.readkey1/CPP/rk.cpp" id="Snippet1"::: + enumeration is used in conjunction with the type. + +## Examples + The following code example reads a key and determines whether one or more modifier keys was pressed. + :::code language="csharp" source="~/snippets/csharp/System/Console/ReadKey/rk.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.readkey1/FS/rk.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.readkey1/VB/rk.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.readkey1/VB/rk.vb" id="Snippet1"::: + ]]> diff --git a/xml/System/ConsoleSpecialKey.xml b/xml/System/ConsoleSpecialKey.xml index 686f7e0f3fb..747a498ccba 100644 --- a/xml/System/ConsoleSpecialKey.xml +++ b/xml/System/ConsoleSpecialKey.xml @@ -50,23 +50,20 @@ Specifies combinations of modifier and console keys that can interrupt the current process. - property returns the enumeration type. - - Simultaneously pressing certain key combinations signals the operating system to interrupt the currently running process. The two valid key combinations are plus BREAK (CTRL+BREAK) and plus (CTRL+C). - - - -## Examples - The following code example displays the value that invokes the associated event handler. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/console.cancelkeypress/cpp/ckp.cpp" id="Snippet1"::: + property returns the enumeration type. + + Simultaneously pressing certain key combinations signals the operating system to interrupt the currently running process. The two valid key combinations are plus BREAK (CTRL+BREAK) and plus (Ctrl+C). + +## Examples + The following code example displays the value that invokes the associated event handler. + :::code language="csharp" source="~/snippets/csharp/System/Console/CancelKeyPress/ckp.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/console.cancelkeypress/fs/ckp.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.cancelkeypress/vb/ckp.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/console.cancelkeypress/vb/ckp.vb" id="Snippet1"::: + ]]> diff --git a/xml/System/Convert.xml b/xml/System/Convert.xml index 9aca9dac108..9a6d3bec974 100644 --- a/xml/System/Convert.xml +++ b/xml/System/Convert.xml @@ -169,12 +169,9 @@ This method uses the current thread's culture for the conversion. - - ## Examples The following example illustrates the use of the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/convertchangetype/CPP/convertchangetype.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ChangeType/convertchangetype.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ChangeType/convertchangetype.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/convertchangetype/VB/convertchangetype.vb" id="Snippet1"::: @@ -282,7 +279,6 @@ ## Examples The following example illustrates how to use the method to change an to the type specified by the parameter, if possible. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.convert.changetype/cpp/changetype_01.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ChangeType/changetype01.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ChangeType/changetype01.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.convert.changetype/vb/changetype01.vb" id="Snippet2"::: @@ -391,14 +387,12 @@ ## Examples The following example defines a `Temperature` class that implements the interface. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.convert.changetype/cpp/changetype03.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ChangeType/changetype03.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ChangeType/changetype03.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.convert.changetype/vb/changetype03.vb" id="Snippet3"::: The following example creates an instance of the `Temperature` class and calls the method to convert it to the basic numeric types supported by .NET and to a . It illustrates that the method wraps a call to the source type's implementation. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.convert.changetype/cpp/changetype03.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ChangeType/changetype03.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ChangeType/changetype03.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.convert.changetype/vb/changetype03.vb" id="Snippet4"::: @@ -510,7 +504,6 @@ ## Examples The following example defines a custom format provider named `InterceptProvider` that indicates when its method is called and returns a for the fr-FR culture and a object for the en-US culture. This format provider is used in all calls to the method. The example then creates an array with a and a value and makes repeated calls to with each value and each member of the enumeration. The example illustrates when the method uses the parameter and also illustrates the use of the `provider` parameter to perform culture-sensitive formatting. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.convert.changetype/cpp/changetype00.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ChangeType/changetype00.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ChangeType/changetype00.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.convert.changetype/vb/changetype00.vb" id="Snippet1"::: @@ -672,7 +665,6 @@ ## Examples The following example demonstrates the use of the method to decode UUencoded (base-64) data and save it as binary output. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Convert UUEncodeDecode functions/CPP/class1.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/FromBase64CharArray/class1.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/FromBase64CharArray/class1.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Convert UUEncodeDecode functions/VB/class1.vb" id="Snippet3"::: @@ -681,7 +673,6 @@ If an integral number of 3-byte groups does not exist, the remaining bytes are effectively padded with zeros to form a complete group. In this example, the value of the last byte is hexadecimal FF. The first 6 bits are equal to decimal 63, which corresponds to the base-64 digit "/" at the end of the output, and the next 2 bits are padded with zeros to yield decimal 48, which corresponds to the base-64 digit, "w". The last two 6-bit values are padding and correspond to the valueless padding character, "=". - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/convert.tobase64chararray/CPP/tb64ca.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/FromBase64CharArray/tb64ca.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/FromBase64CharArray/tb64ca.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/convert.tobase64chararray/VB/tb64ca.vb" id="Snippet1"::: @@ -1200,7 +1191,6 @@ ## Examples The following example demonstrates using the method to UUencode (encode in base 64) a binary stream, then save the encoding to a file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Convert UUEncodeDecode functions/CPP/class1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/FromBase64CharArray/class1.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/FromBase64CharArray/class1.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Convert UUEncodeDecode functions/VB/class1.vb" id="Snippet2"::: @@ -1310,7 +1300,6 @@ If an integral number of 3-byte groups does not exist, the remaining bytes are effectively padded with zeros to form a complete group. In this example, the value of the last byte is hexadecimal FF. The first 6 bits are equal to decimal 63, which corresponds to the base-64 digit "/" at the end of the output, and the next 2 bits are padded with zeros to yield decimal 48, which corresponds to the base-64 digit, "w". The last two 6-bit values are padding and correspond to the valueless padding character, "=". - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/convert.tobase64chararray/CPP/tb64ca.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/FromBase64CharArray/tb64ca.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/FromBase64CharArray/tb64ca.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/convert.tobase64chararray/VB/tb64ca.vb" id="Snippet1"::: @@ -1734,7 +1723,6 @@ If an integral number of 3-byte groups does not exist, the remaining bytes are effectively padded with zeros to form a complete group. In this example, the value of the last byte is hexadecimal FF. The first 6 bits are equal to decimal 63, which corresponds to the base-64 digit "/" at the end of the output, and the next 2 bits are padded with zeros to yield decimal 48, which corresponds to the base-64 digit, "w". The last two 6-bit values are padding and correspond to the valueless padding character, "=". - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/convert.tobase64string/CPP/tb64s.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBase64String/tb64s.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBase64String/tb64s.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/convert.tobase64string/VB/tb64s.vb" id="Snippet1"::: @@ -1875,7 +1863,6 @@ ## Examples The following example converts an array of values to values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToBoolean/cpp/toboolean2.cpp" id="Snippet12"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/toboolean2.cs" interactive="try-dotnet-method" id="Snippet12"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/toboolean2.fs" id="Snippet12"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToBoolean/vb/toboolean2.vb" id="Snippet12"::: @@ -1986,7 +1973,6 @@ ## Examples The following example demonstrates that an attempt to convert a value to a Boolean type throws . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert Snippets/CPP/system.convert snippet.cpp" id="Snippet20"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/system.convert snippet.cs" id="Snippet20"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/system.convert snippet.fs" id="Snippet20"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert Snippets/VB/system.convert snippet.vb" id="Snippet20"::: @@ -2051,7 +2037,6 @@ ## Examples The following example converts an array of values to values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToBoolean/cpp/toboolean2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/toboolean2.cs" interactive="try-dotnet-method" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/toboolean2.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToBoolean/vb/toboolean2.vb" id="Snippet2"::: @@ -2116,7 +2101,6 @@ ## Examples The following example converts a Boolean to a and a to a Boolean value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert Snippets/CPP/system.convert snippet.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/system.convert snippet.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/system.convert snippet.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert Snippets/VB/system.convert snippet.vb" id="Snippet1"::: @@ -2181,7 +2165,6 @@ ## Examples The following example converts an array of values to values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToBoolean/cpp/toboolean2.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/toboolean2.cs" interactive="try-dotnet-method" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/toboolean2.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToBoolean/vb/toboolean2.vb" id="Snippet3"::: @@ -2246,7 +2229,6 @@ ## Examples The following example converts an array of values to values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToBoolean/cpp/toboolean2.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/toboolean2.cs" interactive="try-dotnet-method" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/toboolean2.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToBoolean/vb/toboolean2.vb" id="Snippet4"::: @@ -2311,7 +2293,6 @@ ## Examples The following example converts an array of values to values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToBoolean/cpp/toboolean2.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/toboolean2.cs" interactive="try-dotnet-method" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/toboolean2.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToBoolean/vb/toboolean2.vb" id="Snippet5"::: @@ -2384,7 +2365,6 @@ ## Examples The following example converts an array of object values to values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToBoolean/cpp/toboolean2.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/toboolean2.cs" interactive="try-dotnet-method" id="Snippet11"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/toboolean2.fs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToBoolean/vb/toboolean2.vb" id="Snippet11"::: @@ -2463,7 +2443,6 @@ ## Examples The following example converts an array of values to values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToBoolean/cpp/toboolean2.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/toboolean2.cs" interactive="try-dotnet-method" id="Snippet6"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/toboolean2.fs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToBoolean/vb/toboolean2.vb" id="Snippet6"::: @@ -2528,7 +2507,6 @@ ## Examples The following example converts an array of values to values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToBoolean/cpp/toboolean2.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/toboolean2.cs" interactive="try-dotnet-method" id="Snippet7"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/toboolean2.fs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToBoolean/vb/toboolean2.vb" id="Snippet7"::: @@ -2608,7 +2586,6 @@ ## Examples The following example uses the method to convert various strings to Boolean values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToBoolean/cpp/toboolean1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/ToBoolean1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/ToBoolean1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToBoolean/vb/ToBoolean1.vb" id="Snippet1"::: @@ -2681,7 +2658,6 @@ ## Examples The following example converts an array of values to values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToBoolean/cpp/toboolean2.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/toboolean2.cs" interactive="try-dotnet-method" id="Snippet8"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/toboolean2.fs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToBoolean/vb/toboolean2.vb" id="Snippet8"::: @@ -2752,7 +2728,6 @@ ## Examples The following example converts an array of values to values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToBoolean/cpp/toboolean2.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/toboolean2.cs" interactive="try-dotnet-method" id="Snippet9"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/toboolean2.fs" id="Snippet9"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToBoolean/vb/toboolean2.vb" id="Snippet9"::: @@ -2823,7 +2798,6 @@ ## Examples The following example converts an array of values to values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToBoolean/cpp/toboolean2.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/toboolean2.cs" interactive="try-dotnet-method" id="Snippet10"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/toboolean2.fs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToBoolean/vb/toboolean2.vb" id="Snippet10"::: @@ -2903,7 +2877,6 @@ ## Examples The following example defines a class that implements and a class that implements . Objects of the class that implements hold an array of values. An object of each class is passed to the method. This method returns `true` if any of the non-discarded array values are non-zero. The object determines how elements are discarded for this calculation. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToXXX_Object_IFP/CPP/objectifp.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/objectifp.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/objectifp.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToXXX_Object_IFP/VB/objectifp.vb" id="Snippet1"::: @@ -3059,7 +3032,6 @@ ## Examples The following example illustrates the conversion of to values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.convert.tobyte/cpp/tobyte1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Byte/Overview/tobyte1.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Byte/Overview/tobyte1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.convert.tobyte/vb/tobyte1.vb" id="Snippet1"::: @@ -3291,7 +3263,6 @@ ## Remarks The following example converts a value to a and a value to a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert Snippets/CPP/system.convert snippet.cpp" id="Snippet18"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/system.convert snippet.cs" id="Snippet18"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/system.convert snippet.fs" id="Snippet18"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert Snippets/VB/system.convert snippet.vb" id="Snippet18"::: @@ -3357,7 +3328,6 @@ ## Examples The following example converts a value to a and a value to a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert Snippets/CPP/system.convert snippet.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/system.convert snippet.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/system.convert snippet.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert Snippets/VB/system.convert snippet.vb" id="Snippet2"::: @@ -3763,7 +3733,6 @@ ## Examples The following example converts a value to a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert Snippets/CPP/system.convert snippet.cpp" id="Snippet19"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/system.convert snippet.cs" id="Snippet19"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/system.convert snippet.fs" id="Snippet19"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert Snippets/VB/system.convert snippet.vb" id="Snippet19"::: @@ -4589,7 +4558,6 @@ ## Examples The following example attempts to convert a to , and throws on failure. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert Snippets/CPP/system.convert snippet.cpp" id="Snippet17"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/system.convert snippet.cs" id="Snippet17"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/system.convert snippet.fs" id="Snippet17"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert Snippets/VB/system.convert snippet.vb" id="Snippet17"::: @@ -4830,7 +4798,6 @@ ## Examples The following example attempts to convert a long integer to a , and throws a on failure. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert Snippets/CPP/system.convert snippet.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/system.convert snippet.cs" id="Snippet8"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/system.convert snippet.fs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert Snippets/VB/system.convert snippet.vb" id="Snippet8"::: @@ -5382,7 +5349,6 @@ ## Examples The following example defines a class that implements and a class that implements . Objects of the class that implements hold an array of values. An object of each class is passed to the `ToChar` method. This method returns a character whose Unicode value is the average of the array of values, using the object that implements to determine how to calculate the average. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToXXX_Object_IFP/CPP/objectifp.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/objectifp.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/objectifp.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToXXX_Object_IFP/VB/objectifp.vb" id="Snippet1"::: @@ -5472,7 +5438,6 @@ ## Examples The following example converts a string representation of a value with the `ToChar` method, using an object that displays the type of the format provider for which it is called. The example shows that the format provider is not referenced. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToNonNum_String/CPP/stringnonnum.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToChar/stringnonnum.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToChar/stringnonnum.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToNonNum_String/VB/stringnonnum.vb" id="Snippet2"::: @@ -6655,7 +6620,6 @@ ## Examples The following example converts a value to a value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert Snippets/CPP/system.convert snippet.cpp" id="Snippet18"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/system.convert snippet.cs" id="Snippet18"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/system.convert snippet.fs" id="Snippet18"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert Snippets/VB/system.convert snippet.vb" id="Snippet18"::: @@ -6716,7 +6680,6 @@ ## Examples The following example attempts to convert a value to , and throws upon failure. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert Snippets/CPP/system.convert snippet.cpp" id="Snippet17"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/system.convert snippet.cs" id="Snippet17"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/system.convert snippet.fs" id="Snippet17"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert Snippets/VB/system.convert snippet.vb" id="Snippet17"::: @@ -6891,7 +6854,6 @@ ## Examples The following example converts a value to a value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert Snippets/CPP/system.convert snippet.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/system.convert snippet.cs" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/system.convert snippet.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert Snippets/VB/system.convert snippet.vb" id="Snippet5"::: @@ -7084,7 +7046,6 @@ ## Examples The following example converts an value to a value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert Snippets/CPP/system.convert snippet.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/system.convert snippet.cs" id="Snippet10"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/system.convert snippet.fs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert Snippets/VB/system.convert snippet.vb" id="Snippet10"::: @@ -7376,7 +7337,6 @@ ## Examples The following example illustrates the use of `ToDecimal`. It attempts to convert a to a , and throws the possible exceptions that may arise during the conversion. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert Snippets/CPP/system.convert snippet.cpp" id="Snippet15"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/system.convert snippet.cs" id="Snippet15"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/system.convert snippet.fs" id="Snippet15"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert Snippets/VB/system.convert snippet.vb" id="Snippet15"::: @@ -7829,7 +7789,6 @@ ## Examples The following example converts a value to a value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert Snippets/CPP/system.convert snippet.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/system.convert snippet.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/system.convert snippet.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert Snippets/VB/system.convert snippet.vb" id="Snippet1"::: @@ -7892,7 +7851,6 @@ ## Examples The following example converts a value to a value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert Snippets/CPP/system.convert snippet.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/system.convert snippet.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/system.convert snippet.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert Snippets/VB/system.convert snippet.vb" id="Snippet2"::: @@ -8054,7 +8012,6 @@ ## Examples The following example converts a value to a value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert Snippets/CPP/system.convert snippet.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/system.convert snippet.cs" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/system.convert snippet.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert Snippets/VB/system.convert snippet.vb" id="Snippet5"::: @@ -8232,7 +8189,6 @@ ## Examples The following example converts an value to a value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert Snippets/CPP/system.convert snippet.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/system.convert snippet.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/system.convert snippet.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert Snippets/VB/system.convert snippet.vb" id="Snippet3"::: @@ -8503,7 +8459,6 @@ ## Examples The following example converts a value to a value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert Snippets/CPP/system.convert snippet.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/system.convert snippet.cs" id="Snippet6"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/system.convert snippet.fs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert Snippets/VB/system.convert snippet.vb" id="Snippet6"::: @@ -8857,7 +8812,6 @@ ## Examples The following example defines a class that implements and a class that implements . Objects of the class that implements hold an array of values. An object of each class is passed to the `ToDouble` method. This method returns an average of the array of values, using the object that implements to determine how to calculate the average. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToXXX_Object_IFP/CPP/objectifp.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/objectifp.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/objectifp.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToXXX_Object_IFP/VB/objectifp.vb" id="Snippet1"::: @@ -10063,7 +10017,6 @@ ## Examples The following example converts string representations of 16-bit integers with the `ToInt16` method, using default formatting. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToSInts_String/CPP/toint16.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToInt16/toint16.cs" interactive="try-dotnet" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToInt16/toint16.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToSInts_String/VB/toint16.vb" id="Snippet3"::: @@ -10351,7 +10304,6 @@ ## Examples The following example defines a class that implements and a class that implements . Objects of the class that implements hold an array of values. An object of each class is passed to the `ToInt16` method. This method returns an average of the array of values, using the object that implements to determine how to calculate the average. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToXXX_Object_IFP/CPP/objectifp.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/objectifp.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/objectifp.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToXXX_Object_IFP/VB/objectifp.vb" id="Snippet1"::: @@ -10430,7 +10382,6 @@ ## Examples The following example converts string representations of 16-bit integers with the `ToInt16` method, using an object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToSInts_String/CPP/toint16.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToInt16/toint16.cs" interactive="try-dotnet" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToInt16/toint16.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToSInts_String/VB/toint16.vb" id="Snippet3"::: @@ -11672,7 +11623,6 @@ ## Examples The following example defines a class that implements and a class that implements . Objects of the class that implements hold an array of values. An object of each class is passed to the `ToInt32` method. This method returns an average of the array of values, using the object that implements to determine how to calculate the average. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToXXX_Object_IFP/CPP/objectifp.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/objectifp.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/objectifp.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToXXX_Object_IFP/VB/objectifp.vb" id="Snippet1"::: @@ -11824,14 +11774,12 @@ Because the negative sign is not supported for non-base 10 numeric representations, the method assumes that negative numbers use two's complement representation. In other words, the method always interprets the highest-order binary bit of an integer (bit 31) as its sign bit. As a result, it is possible to write code in which a non-base 10 number that is out of the range of the data type is converted to an value without the method throwing an exception. The following example increments by one, converts the resulting number to its hexadecimal string representation, and then calls the method. Instead of throwing an exception, the method displays the message, "0x80000000 converts to -2147483648." - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.BaseConversion/cpp/toint_str_int32.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToByte/Conversion.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToByte/Conversion.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.BaseConversion/vb/Conversion.vb" id="Snippet1"::: When performing binary operations or numeric conversions, it is always the responsibility of the developer to verify that a method is using the appropriate numeric representation to interpret a particular value. As the following example illustrates, you can ensure that the method handles overflows appropriately by first retrieving the sign of the numeric value before converting it to its hexadecimal string representation. Throw an exception if the original value was positive but the conversion back to an integer yields a negative value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.BaseConversion/cpp/toint_str_int32.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToByte/Conversion.cs" interactive="try-dotnet-method" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToByte/Conversion.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.BaseConversion/vb/Conversion.vb" id="Snippet2"::: @@ -12977,7 +12925,6 @@ ## Examples The following example defines a class that implements and a class that implements . Objects of the class that implements hold an array of values. An object of each class is passed to the `ToInt64` method. This method returns an average of the array of values, using the object that implements to determine how to calculate the average. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToXXX_Object_IFP/CPP/objectifp.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/objectifp.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/objectifp.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToXXX_Object_IFP/VB/objectifp.vb" id="Snippet1"::: @@ -14082,7 +14029,6 @@ ## Examples The following example converts string representations of values with the `ToSByte` method, using default formatting. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToSInts_String/CPP/tosbyte.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToInt16/tosbyte.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToInt16/tosbyte.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToSInts_String/VB/tosbyte.vb" id="Snippet4"::: @@ -14477,7 +14423,6 @@ ## Examples The following example converts string representations of values with the `ToSByte` method, using an object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToSInts_String/CPP/tosbyte.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToInt16/tosbyte.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToInt16/tosbyte.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToSInts_String/VB/tosbyte.vb" id="Snippet4"::: @@ -15997,7 +15942,6 @@ ## Examples The following example converts a to a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert Snippets/CPP/system.convert snippet.cpp" id="Snippet14"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/system.convert snippet.cs" id="Snippet14"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/system.convert snippet.fs" id="Snippet14"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert Snippets/VB/system.convert snippet.vb" id="Snippet14"::: @@ -16132,7 +16076,6 @@ ## Examples The following example converts a to a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert Snippets/CPP/system.convert snippet.cpp" id="Snippet15"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/system.convert snippet.cs" id="Snippet15"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/system.convert snippet.fs" id="Snippet15"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert Snippets/VB/system.convert snippet.vb" id="Snippet15"::: @@ -16200,7 +16143,6 @@ ## Examples The following example converts a to a . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert Snippets/CPP/system.convert snippet.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToBoolean/system.convert snippet.cs" id="Snippet7"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToBoolean/system.convert snippet.fs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert Snippets/VB/system.convert snippet.vb" id="Snippet7"::: @@ -16971,7 +16913,6 @@ ## Examples The following example converts a value to a with the `ToString` method, using an object that displays the type of the format provider for which it is called. The example shows that the object is not referenced. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToString.IFormatProvider/CPP/nonnumeric.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToString/nonnumeric.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToString/nonnumeric.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToString.IFormatProvider/VB/nonnumeric.vb" id="Snippet2"::: @@ -17204,7 +17145,6 @@ ## Examples The following example converts a value to a with the `ToString` method, using an object that displays the type of the format provider for which it is called. The example shows that the object is not referenced. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToString.IFormatProvider/CPP/nonnumeric.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToString/nonnumeric.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToString/nonnumeric.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToString.IFormatProvider/VB/nonnumeric.vb" id="Snippet2"::: @@ -18208,7 +18148,6 @@ ## Examples The following example calls the `ToString` method with a parameter. The method returns the unmodified without referencing the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Convert.ToString.IFormatProvider/CPP/nonnumeric.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Convert/ToString/nonnumeric.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Convert/ToString/nonnumeric.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Convert.ToString.IFormatProvider/VB/nonnumeric.vb" id="Snippet2"::: diff --git a/xml/System/Converter`2.xml b/xml/System/Converter`2.xml index 6c8405f30c1..b4c5412d8ab 100644 --- a/xml/System/Converter`2.xml +++ b/xml/System/Converter`2.xml @@ -82,29 +82,27 @@ Represents a method that converts an object from one type to another type. The that represents the converted . - method of the class and the method of the class to convert each element of the collection from one type to another. - - - -## Examples - This section contains two code examples. The first demonstrates the delegate with the method of the class, and the second demonstrates the delegate with the method of the generic class. - - Example 1 - - The following code example defines a method named `PointFToPoint` that converts a structure to a structure. The example then creates an array 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. + method of the class and the method of the class to convert each element of the collection from one type to another. + + + +## Examples + This section contains two code examples. The first demonstrates the delegate with the method of the class, and the second demonstrates the delegate with the method of the generic class. + + Example 1 + + The following code example defines a method named `PointFToPoint` that converts a structure to a structure. The example then creates an array 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/Array_ConvertAll/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Array/ConvertAllTInput,TOutput/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Array_ConvertAll/vb/source.vb" id="Snippet1"::: - Example 2 - - The following code 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"::: + Example 2 + + The following code 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="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"::: diff --git a/xml/System/CrossAppDomainDelegate.xml b/xml/System/CrossAppDomainDelegate.xml index 72822815b07..80b9acadf40 100644 --- a/xml/System/CrossAppDomainDelegate.xml +++ b/xml/System/CrossAppDomainDelegate.xml @@ -28,11 +28,10 @@ Used by for cross-application domain calls. - and has a constructor and an `Invoke` method. See the C++ code example given in the description for . - + and has a constructor and an `Invoke` method. + ]]> diff --git a/xml/System/DateTime.xml b/xml/System/DateTime.xml index c8b649bb31d..48a5311fb4a 100644 --- a/xml/System/DateTime.xml +++ b/xml/System/DateTime.xml @@ -208,12 +208,9 @@ For applications in which portability of date and time data or a limited degree of time zone awareness is important, you can use the corresponding constructor. - - ## Examples The following example demonstrates one of the constructors. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/datetime.ctor_Int64/CPP/ticks.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/datetime.ctor_Int64/FS/ticks.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/.ctor/ticks.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/datetime.ctor_Int64/VB/ticks.vb" id="Snippet1"::: @@ -1654,7 +1651,6 @@ For applications in which portability of date and time data or a limited degree ## Examples The following example demonstrates the method. It calculates the day of the week that is 36 days (864 hours) from this moment. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/DateTime.Add/CPP/class1.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/DateTime.Add/FS/class1.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/Add/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/DateTime.Add/VB/class1.vb" id="Snippet1"::: @@ -1728,7 +1724,6 @@ For applications in which portability of date and time data or a limited degree ## Examples The following example uses the method to determine the day of the week 36 days after the current date. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/DateTime.AddDays/CPP/class1.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/DateTime.AddDays/FS/class1.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/AddDays/class1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/DateTime.AddDays/VB/class1.vb" id="Snippet1"::: @@ -1991,7 +1986,6 @@ The value parameter is rounded to the nearest integer. ## Examples The following example uses the method to add a number of whole and fractional values to a date and time. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.datetime.addminutes/cpp/addminutes1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/AddMinutes/addminutes1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.datetime.addminutes/fs/addminutes1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.datetime.addminutes/vb/addminutes1.vb" id="Snippet1"::: @@ -2560,7 +2554,6 @@ The value parameter is rounded to the nearest integer. ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/DateTime.CompareTo/CPP/class1.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/DateTime.CompareTo/FS/class1.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/CompareTo/class1.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/DateTime.CompareTo/VB/class1.vb" id="Snippet1"::: @@ -2634,7 +2627,6 @@ The value parameter is rounded to the nearest integer. ## Examples The following example uses the property to extract the date component of a value with its time component set to zero (or 0:00:00, or midnight). It also illustrates that, depending on the format string used when displaying the value, the time component can continue to appear in formatted output. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.DateTime.Date/cpp/date1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/Date/Date1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.DateTime.Date/fs/Date1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.DateTime.Date/vb/Date1.vb" id="Snippet1"::: @@ -2704,7 +2696,6 @@ The value parameter is rounded to the nearest integer. ## Examples The following example demonstrates the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.DateTime.Minute etc/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/Day/class1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.DateTime.Minute etc/FS/class1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.DateTime.Minute etc/VB/class1.vb" id="Snippet1"::: @@ -2774,7 +2765,6 @@ The value parameter is rounded to the nearest integer. ## Examples The following example demonstrates the property and the enumeration. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/DateTime.DayOfWeek/CPP/dow.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/DateTime.DayOfWeek/FS/dow.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/DayOfWeek/dow.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/DateTime.DayOfWeek/VB/dow.vb" id="Snippet1"::: @@ -2906,7 +2896,6 @@ The value parameter is rounded to the nearest integer. ## Examples The following example demonstrates how to use the method to determine the number of days in July 2001, February 1998 (a non-leap year), and February 1996 (a leap year). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/DateTime.DaysInMonth/CPP/class1.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/DateTime.DaysInMonth/FS/class1.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/DaysInMonth/class1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/DateTime.DaysInMonth/VB/class1.vb" id="Snippet1"::: @@ -3229,7 +3218,6 @@ The value parameter is rounded to the nearest integer. ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/DateTime.Equals/CPP/class1.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/DateTime.Equals/FS/class1.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/Equals/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/DateTime.Equals/VB/class1.vb" id="Snippet1"::: @@ -3353,7 +3341,6 @@ The value parameter is rounded to the nearest integer. ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/DateTime.FromFileTime/CPP/class1.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/DateTime.FromFileTime/FS/class1.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/FromFileTime/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/DateTime.FromFileTime/VB/class1.vb" id="Snippet1"::: @@ -3584,7 +3571,6 @@ The value parameter is rounded to the nearest integer. ## Examples The following example demonstrates the method. It displays the string representation of a date using all possible standard date and time formats in the computer's current culture, which in this case is en-US. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/DateTime.GetDateTimeFormats/CPP/class1.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/DateTime.GetDateTimeFormats/FS/class1.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/GetDateTimeFormats/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/DateTime.GetDateTimeFormats/VB/class1.vb" id="Snippet1"::: @@ -3875,7 +3861,6 @@ July, 2009 ## Examples The following example demonstrates the method. It displays the string representation of a date using all possible standard date and time formats for the fr-FR culture. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/DateTime.GetDateTimeFormats/CPP/class1.cpp" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/DateTime.GetDateTimeFormats/FS/class1.fs" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/GetDateTimeFormats/class1.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/DateTime.GetDateTimeFormats/VB/class1.vb" id="Snippet2"::: @@ -4244,7 +4229,6 @@ juillet 2009 ## Examples The following example demonstrates the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.DateTime.Minute etc/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/Day/class1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.DateTime.Minute etc/FS/class1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.DateTime.Minute etc/VB/class1.vb" id="Snippet1"::: @@ -4618,7 +4602,6 @@ juillet 2009 ## Examples The following example demonstrates the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.DateTime.Minute etc/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/Day/class1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.DateTime.Minute etc/FS/class1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.DateTime.Minute etc/VB/class1.vb" id="Snippet1"::: @@ -4681,7 +4664,6 @@ juillet 2009 ## Examples The following example demonstrates the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.DateTime.Minute etc/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/Day/class1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.DateTime.Minute etc/FS/class1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.DateTime.Minute etc/VB/class1.vb" id="Snippet1"::: @@ -4806,7 +4788,6 @@ juillet 2009 ## Examples The following example demonstrates the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.DateTime.Minute etc/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/Day/class1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.DateTime.Minute etc/FS/class1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.DateTime.Minute etc/VB/class1.vb" id="Snippet1"::: @@ -4893,7 +4874,6 @@ juillet 2009 ## Remarks The property returns a value that represents the current date and time on the local computer. Note that there is a difference between a value, which represents the number of ticks that have elapsed since midnight of January 1, 0001, and the string representation of that value, which expresses a date and time value in a culture-specific-specific format. For information on formatting date and time values, see the method. The following example displays the short date and time string in a number of culture-specific formats. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.datetime.now/cpp/now1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/Now/now1.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.datetime.now/fs/now1.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.datetime.now/vb/now1.vb" id="Snippet2"::: @@ -4912,7 +4892,6 @@ juillet 2009 ## Examples The following example uses the and properties to retrieve the current local date and time and the current universal coordinated (UTC) date and time. It then uses the formatting conventions of a number of cultures to display the strings, along with the values of their properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.datetime.now/cpp/now2.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/Now/now2.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.datetime.now/fs/now2.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.datetime.now/vb/now2.vb" id="Snippet3"::: @@ -4977,7 +4956,6 @@ juillet 2009 ## Examples The following example demonstrates the addition operator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/DateTime Operators/CPP/class1.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/DateTime Operators/FS/class1.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/op_Addition/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/DateTime Operators/VB/class1.vb" id="Snippet1"::: @@ -5057,7 +5035,6 @@ juillet 2009 ## Examples The following example demonstrates the equality operator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/DateTime Operators/CPP/class1.cpp" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/DateTime Operators/FS/class1.fs" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/op_Addition/class1.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/DateTime Operators/VB/class1.vb" id="Snippet2"::: @@ -5479,7 +5456,6 @@ juillet 2009 ## Examples The following example demonstrates the method and the subtraction operator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/DateTime.Subtraction/CPP/class1.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/DateTime.Subtraction/FS/class1.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/op_Subtraction/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/DateTime.Subtraction/VB/class1.vb" id="Snippet1"::: @@ -5550,7 +5526,6 @@ juillet 2009 ## Examples The following example demonstrates the method and the subtraction operator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/DateTime.Subtraction/CPP/class1.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/DateTime.Subtraction/FS/class1.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/op_Subtraction/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/DateTime.Subtraction/VB/class1.vb" id="Snippet1"::: @@ -6736,7 +6711,6 @@ The following example demonstrates the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.DateTime.Minute etc/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/Day/class1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.DateTime.Minute etc/FS/class1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.DateTime.Minute etc/VB/class1.vb" id="Snippet1"::: @@ -6904,7 +6878,6 @@ The following example demonstrates the method and the subtraction operator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/DateTime.Subtraction/CPP/class1.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/DateTime.Subtraction/FS/class1.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/op_Subtraction/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/DateTime.Subtraction/VB/class1.vb" id="Snippet1"::: @@ -6994,7 +6967,6 @@ The following example demonstrates the method and the subtraction operator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/DateTime.Subtraction/CPP/class1.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/DateTime.Subtraction/FS/class1.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/op_Subtraction/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/DateTime.Subtraction/VB/class1.vb" id="Snippet1"::: @@ -8272,7 +8244,6 @@ In general, the ticks represent the time according to the time zone specified by ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/DateTime.ToFileTime/CPP/class1.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/DateTime.ToFileTime/FS/class1.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/ToFileTime/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/DateTime.ToFileTime/VB/class1.vb" id="Snippet1"::: @@ -8432,7 +8403,6 @@ In general, the ticks represent the time according to the time zone specified by ## Examples The following example demonstrates the method. Note that the exact output depends on the current culture and the local time zone of the system on which it is run. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/DateTime.ToLocalTime ToUniversalTime/CPP/class1.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/DateTime.ToLocalTime ToUniversalTime/FS/class1.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/ToLocalTime/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/DateTime.ToLocalTime ToUniversalTime/VB/class1.vb" id="Snippet1"::: @@ -9228,7 +9198,6 @@ The following example illustrates how the string representation of a value using the invariant . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic DateTime.ToString2 Example/CPP/source.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_Classic/classic DateTime.ToString2 Example/FS/source.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/ToString/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic DateTime.ToString2 Example/VB/source.vb" id="Snippet1"::: @@ -9329,7 +9298,6 @@ The following example illustrates how the string representation of a method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/DateTime.ToLocalTime ToUniversalTime/CPP/class1.cpp" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/DateTime.ToLocalTime ToUniversalTime/FS/class1.fs" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/ToLocalTime/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/DateTime.ToLocalTime ToUniversalTime/VB/class1.vb" id="Snippet1"::: @@ -9622,7 +9590,6 @@ The following example illustrates how the string representation of a method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.DateTime.TryParse/cpp/datetime.tryparse1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/TryParse/TryParse1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.DateTime.TryParse/fs/TryParse1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.DateTime.TryParse/vb/TryParse1.vb" id="Snippet1"::: @@ -10485,7 +10452,6 @@ The following example illustrates the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.DateTime.Minute etc/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/Day/class1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.DateTime.Minute etc/FS/class1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.DateTime.Minute etc/VB/class1.vb" id="Snippet1"::: diff --git a/xml/System/DayOfWeek.xml b/xml/System/DayOfWeek.xml index 99dcc0e3325..f070ca8c127 100644 --- a/xml/System/DayOfWeek.xml +++ b/xml/System/DayOfWeek.xml @@ -60,23 +60,22 @@ Specifies the day of the week. - enumeration represents the day of the week in calendars that have seven days per week. The value of the constants in this enumeration ranges from Sunday to Saturday. If cast to an integer, its value ranges from zero (which indicates Sunday) to six (which indicates Saturday). + + This enumeration is useful when it is desirable to have a strongly typed specification of the day of the week. For example, this enumeration is the type of the property value for the and properties. + + The members of the enumeration are not localized. To return the localized name of the day of the week, call the or the method with either the "ddd" or "dddd" format strings. The former format string produces the abbreviated weekday name; the latter produces the full weekday name. + +## Examples + The following example demonstrates the property and the enumeration. -## Remarks - The enumeration represents the day of the week in calendars that have seven days per week. The value of the constants in this enumeration ranges from Sunday to Saturday. If cast to an integer, its value ranges from zero (which indicates Sunday) to six (which indicates Saturday). - - This enumeration is useful when it is desirable to have a strongly typed specification of the day of the week. For example, this enumeration is the type of the property value for the and properties. - - The members of the enumeration are not localized. To return the localized name of the day of the week, call the or the method with either the "ddd" or "dddd" format strings. The former format string produces the abbreviated weekday name; the latter produces the full weekday name. - -## Examples - The following example demonstrates the property and the enumeration. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/DateTime.DayOfWeek/CPP/dow.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/DateTime/DayOfWeek/dow.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/DateTime.DayOfWeek/FS/dow.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/DateTime.DayOfWeek/VB/dow.vb" id="Snippet1"::: - + ]]> diff --git a/xml/System/Decimal.xml b/xml/System/Decimal.xml index e3e2bc3a8c5..7587a22e965 100644 --- a/xml/System/Decimal.xml +++ b/xml/System/Decimal.xml @@ -348,12 +348,9 @@ ## Remarks This constructor rounds `value` to 15 significant digits using rounding to nearest. This is done even if the number has more than 15 digits and the less significant digits are zero. - - ## Examples The following code example creates several `Decimal` numbers using the constructor overload that initializes a `Decimal` structure with a value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Reals/CPP/ctordo.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/.ctor/ctordo.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/.ctor/ctordo.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.Ctor.Reals/VB/ctordo.vb" id="Snippet2"::: @@ -416,7 +413,6 @@ ## Examples The following code example creates several `Decimal` numbers using the constructor overload that initializes a `Decimal` structure with an value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Ints/CPP/ctori.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/.ctor/ctori.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/.ctor/ctori.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.Ctor.Ints/VB/ctori.vb" id="Snippet1"::: @@ -494,7 +490,6 @@ ## Examples The following code example creates several `Decimal` numbers using the constructor overload that initializes a `Decimal` structure with an array of four values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Arrays/CPP/ctoriarr.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/.ctor/ctoriarr.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/.ctor/ctoriarr.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.Ctor.Arrays/VB/ctoriarr.vb" id="Snippet1"::: @@ -559,7 +554,6 @@ ## Examples The following code example creates several `Decimal` numbers using the constructor overload that initializes a `Decimal` structure with an value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Ints/CPP/ctorl.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/.ctor/ctorl.cs" interactive="try-dotnet" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/.ctor/ctorl.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.Ctor.Ints/VB/ctorl.vb" id="Snippet3"::: @@ -660,7 +654,6 @@ ## Examples The following code example creates several `Decimal` numbers using the constructor overload that initializes a `Decimal` structure with a value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Reals/CPP/ctors.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/.ctor/ctors.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/.ctor/ctors.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.Ctor.Reals/VB/ctors.vb" id="Snippet1"::: @@ -729,7 +722,6 @@ ## Examples The following code example creates several `Decimal` numbers using the constructor overload that initializes a `Decimal` structure with a value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Ints/CPP/ctorui.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/.ctor/ctorui.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/.ctor/ctorui.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.Ctor.Ints/VB/ctorui.vb" id="Snippet2"::: @@ -792,7 +784,6 @@ ## Examples The following code example creates several `Decimal` numbers using the constructor overload that initializes a `Decimal` structure with a value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Ints/CPP/ctorul.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/.ctor/ctorul.cs" interactive="try-dotnet" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/.ctor/ctorul.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.Ctor.Ints/VB/ctorul.vb" id="Snippet4"::: @@ -863,7 +854,6 @@ ## Examples The following code example creates several `Decimal` numbers using the constructor overload that initializes a `Decimal` structure with three value words, a sign, and a scale factor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Ctor.Arrays/CPP/ctoriiibby.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/.ctor/ctoriiibby.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/.ctor/ctoriiibby.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.Ctor.Arrays/VB/ctoriiibby.vb" id="Snippet2"::: @@ -978,7 +968,6 @@ ## Remarks The following code sample illustrates the use of `Add` : - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Decimal Example/CPP/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/Overview/source.cs" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/Overview/source.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Decimal Example/VB/source.vb" id="Snippet5"::: @@ -1297,7 +1286,6 @@ ## Examples The following code example demonstrates generic and nongeneric versions of the method for several value and reference types. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/T.CompareTo/CPP/cat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Boolean/CompareTo/cat.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/T.CompareTo/VB/cat.vb" id="Snippet1"::: @@ -1390,7 +1378,6 @@ ## Examples The following code example compares several `Decimal` and other objects to a reference `Decimal` value using the `CompareTo` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Compare_Equals/CPP/cto_eq_obj.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/CompareTo/cto_eq_obj.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/CompareTo/cto_eq_obj.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.Compare_Equals/VB/cto_eq_obj.vb" id="Snippet1"::: @@ -1934,7 +1921,6 @@ ## Examples The following code example compares several `Decimal` and other objects to a reference `Decimal` value using the `Equals` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Compare_Equals/CPP/cto_eq_obj.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/CompareTo/cto_eq_obj.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/CompareTo/cto_eq_obj.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.Compare_Equals/VB/cto_eq_obj.vb" id="Snippet1"::: @@ -2013,7 +1999,6 @@ ## Examples The following code example compares several `Decimal` values to a reference `Decimal` value using the static `Equals` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Compare_Equals/CPP/comp_equal.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/CompareTo/comp_equal.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/CompareTo/comp_equal.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.Compare_Equals/VB/comp_equal.vb" id="Snippet2"::: @@ -2155,7 +2140,6 @@ ## Examples The following code example uses the `FromOACurrency` method to convert fields that contain OLE Automation Currency values to the equivalent `Decimal` numbers. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.OACurrency/CPP/fromoacurrency.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/FromOACurrency/fromoacurrency.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/FromOACurrency/fromoacurrency.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.OACurrency/VB/fromoacurrency.vb" id="Snippet2"::: @@ -2238,7 +2222,6 @@ ## Examples The following example uses the `GetBits` method to convert several `Decimal` values to their equivalent binary representations. It then displays the decimal values and the hexadecimal value of the elements in the array returned by the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Get_Bits_Hash_Type/CPP/getbits.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/GetBits/getbits.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/GetBits/getbits.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.Get_Bits_Hash_Type/VB/getbits.vb" id="Snippet2"::: @@ -2394,7 +2377,6 @@ ## Examples The following code example uses the `GetTypeCode` method to return the type code for `Decimal` value type. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Get_Bits_Hash_Type/CPP/gettypecode.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/GetBits/gettypecode.cs" interactive="try-dotnet" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/GetBits/gettypecode.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.Get_Bits_Hash_Type/VB/gettypecode.vb" id="Snippet3"::: @@ -2831,7 +2813,6 @@ For , this method matches the IE ## Examples The following code sample illustrates the use of `MaxValue` : - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Decimal Example/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/Overview/source.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/Overview/source.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Decimal Example/VB/source.vb" id="Snippet2"::: @@ -2989,7 +2970,6 @@ For , this method matches the IE ## Examples The following code example illustrates the use of the `MinusOne` field. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Fields/CPP/fields.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/MinusOne/fields.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/MinusOne/fields.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.Fields/VB/fields.vb" id="Snippet1"::: @@ -3054,7 +3034,6 @@ For , this method matches the IE ## Examples The following code example illustrates the use of the `MinValue` field. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Fields/CPP/fields.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/MinusOne/fields.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/MinusOne/fields.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.Fields/VB/fields.vb" id="Snippet1"::: @@ -3127,7 +3106,6 @@ For , this method matches the IE ## Examples The following code example creates several pairs of `Decimal` values and calculates their products with the `Multiply` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Mul_Div_Rem/CPP/mul_div_rem.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/Multiply/mul_div_rem.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/Multiply/mul_div_rem.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.Mul_Div_Rem/VB/mul_div_rem.vb" id="Snippet1"::: @@ -3196,7 +3174,6 @@ For , this method matches the IE ## Examples The following code example uses the `Negate` method to change the sign of several `Decimal` values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Flr_Neg_Rnd_Trnc/CPP/floor_neg_trunc.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/Negate/floor_neg_trunc.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/Negate/floor_neg_trunc.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.Flr_Neg_Rnd_Trnc/VB/floor_neg_trunc.vb" id="Snippet1"::: @@ -3252,7 +3229,6 @@ For , this method matches the IE ## Examples The following code example illustrates the use of the `One` field. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Fields/CPP/fields.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/MinusOne/fields.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/MinusOne/fields.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.Fields/VB/fields.vb" id="Snippet1"::: @@ -3634,13 +3610,11 @@ For , this method matches the IE to a . The syntax for such explicit conversions is language-dependent, and individual language compilers can provide different implementations and return different results. The example illustrates the different return values when you explicitly convert a value to a value by using C#, C++, and Visual Basic. To perform a conversion that is independent of language, you can call the or the method. - + This operator supports the explicit conversion of a to a . The syntax for such explicit conversions is language-dependent, and individual language compilers can provide different implementations and return different results. The example illustrates the different return values when you explicitly convert a value to a value. To perform a conversion that is independent of language, you can call the or the method. ## Examples The following example converts numbers to values by using the explicit to conversion operator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvTo/CPP/ctos_byte.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/op_Explicit/ctos_byte.cs" interactive="try-dotnet" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/op_Explicit/ctos_byte.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Decimal.ConvTo/VB/ctos_byte.vb" id="Snippet4"::: @@ -3704,7 +3678,6 @@ For , this method matches the IE ## Remarks This operator supports the explicit conversion of a to a . The syntax for such explicit conversions is language-dependent, and individual language compilers can provide different implementations and return different results, or might not support the conversion at all. For example, the Visual Basic and C++ compilers do not support an explicit to a conversion. - ## Examples The following example converts numbers to values (Unicode characters) by using the explicit to conversion operator. @@ -3771,13 +3744,11 @@ For , this method matches the IE ## Remarks This operation can result in a loss of precision, because a double-precision floating-point number has fewer significant digits than a . - This operator supports the explicit conversion of a to a . The syntax for such explicit conversions is language-dependent, and individual language compilers can provide different implementations and return different results. The example illustrates the different return values when you explicitly convert a value to a value by using C#, C++, and Visual Basic. To perform a conversion that is independent of language, you can call the or the method. - + This operator supports the explicit conversion of a to a . The syntax for such explicit conversions is language-dependent, and individual language compilers can provide different implementations and return different results. The example illustrates the different return values when you explicitly convert a value to a value. To perform a conversion that is independent of language, you can call the or the method. ## Examples The following example converts numbers to values by using the explicit to conversion operator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvTo/CPP/ctosgl_dbl.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/op_Explicit/ctosgl_dbl.cs" interactive="try-dotnet" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/op_Explicit/ctosgl_dbl.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Decimal.ConvTo/VB/ctosgl_dbl.vb" id="Snippet5"::: @@ -3838,13 +3809,11 @@ For , this method matches the IE ## Remarks - This operator supports the explicit conversion of a to an . The syntax for such explicit conversions is language-dependent, and individual language compilers can provide different implementations and return different results. The example illustrates the different return values when you explicitly convert a value to an value by using C#, Visual Basic, and C++. To perform a conversion that is independent of language, you can call the or the method. - + This operator supports the explicit conversion of a to an . The syntax for such explicit conversions is language-dependent, and individual language compilers can provide different implementations and return different results. The example illustrates the different return values when you explicitly convert a value to an value. To perform a conversion that is independent of language, you can call the or the method. ## Examples The following example converts numbers to values by using the explicit to conversion operator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvTo/CPP/ctou_int16.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/op_Explicit/ctou_int16.cs" interactive="try-dotnet" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/op_Explicit/ctou_int16.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Decimal.ConvTo/VB/ctou_int16.vb" id="Snippet3"::: @@ -3906,13 +3875,11 @@ For , this method matches the IE to an . The syntax for such explicit conversions is language-dependent, and individual language compilers can provide different implementations and return different results. The example illustrates the different return values when you explicitly convert a value to an value by using C#, C++, and Visual Basic. To perform a conversion that is independent of language, you can call the or the method. - + This operator supports the explicit conversion of a to an . The syntax for such explicit conversions is language-dependent, and individual language compilers can provide different implementations and return different results. The example illustrates the different return values when you explicitly convert a value to an value. To perform a conversion that is independent of language, you can call the or the method. ## Examples The following example converts numbers to values by using the explicit to conversion operator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvTo/CPP/ctou_int32.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/op_Explicit/ctou_int32.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/op_Explicit/ctou_int32.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Decimal.ConvTo/VB/ctou_int32.vb" id="Snippet2"::: @@ -3979,7 +3946,6 @@ For , this method matches the IE ## Examples The following example converts numbers to values by using the explicit to conversion operator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvTo/CPP/ctou_int64.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/op_Explicit/ctou_int64.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/op_Explicit/ctou_int64.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Decimal.ConvTo/VB/ctou_int64.vb" id="Snippet1"::: @@ -4055,7 +4021,6 @@ For , this method matches the IE ## Examples The following example converts numbers to values by using the explicit to conversion operator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.decimal.operators.explicit/cpp/tosbyte.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/op_Explicit/tosbyte.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/op_Explicit/tosbyte.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.decimal.operators.explicit/vb/tosbyte.vb" id="Snippet1"::: @@ -4126,7 +4091,6 @@ For , this method matches the IE ## Examples The following example converts numbers to values by using the explicit to conversion operator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.decimal.operators.explicit/cpp/tosingle1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/op_Explicit/tosingle1.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/op_Explicit/tosingle1.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.decimal.operators.explicit/vb/tosingle1.vb" id="Snippet2"::: @@ -4200,7 +4164,6 @@ For , this method matches the IE ## Examples The following example converts numbers to values by using the explicit to conversion operator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvTo/CPP/ctou_int16.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/op_Explicit/ctou_int16.cs" interactive="try-dotnet" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/op_Explicit/ctou_int16.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Decimal.ConvTo/VB/ctou_int16.vb" id="Snippet3"::: @@ -4276,7 +4239,6 @@ For , this method matches the IE ## Examples The following example converts numbers to values by using the explicit to conversion operator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvTo/CPP/ctou_int32.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/op_Explicit/ctou_int32.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/op_Explicit/ctou_int32.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Decimal.ConvTo/VB/ctou_int32.vb" id="Snippet2"::: @@ -4353,7 +4315,6 @@ For , this method matches the IE ## Examples The following example converts numbers to values by using the explicit to conversion operator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvTo/CPP/ctou_int64.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/op_Explicit/ctou_int64.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/op_Explicit/ctou_int64.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Decimal.ConvTo/VB/ctou_int64.vb" id="Snippet1"::: @@ -4418,7 +4379,6 @@ For , this method matches the IE The following example converts values to numbers by using the to conversion operator. This conversion requires the op_Explicit operator in Visual Basic. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.Others/CPP/cfromdouble.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/op_Explicit/cfromdouble.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/op_Explicit/cfromdouble.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Decimal.ConvFrom.Others/VB/cfromdouble.vb" id="Snippet2"::: @@ -4486,7 +4446,6 @@ For , this method matches the IE ## Examples The following example converts values to numbers by using the to conversion operator. This conversion requires the op_Explicit operator in Visual Basic. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.Others/CPP/cfromsingle.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/op_Explicit/cfromsingle.cs" interactive="try-dotnet" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/op_Explicit/cfromsingle.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Decimal.ConvFrom.Others/VB/cfromsingle.vb" id="Snippet3"::: @@ -4733,7 +4692,6 @@ For , this method matches the IE ## Examples The following example converts values to numbers. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.UInts/CPP/cfrombyte.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/op_Implicit/cfrombyte.cs" interactive="try-dotnet" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/op_Implicit/cfrombyte.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Decimal.ConvFrom.UInts/VB/cfrombyte.vb" id="Snippet4"::: @@ -4796,9 +4754,8 @@ For , this method matches the IE The overloads of the method define the types from which the compiler can automatically convert a value without an explicit casting operator (in C#) or a call to a conversion function (in Visual Basic). They are widening conversions that do not involve data loss and do not throw an exception. ## Examples - The following example converts values (Unicode characters) to numbers. This conversion requires the op_Implicit operator in Visual Basic, but not in C# and C++. + The following example converts values (Unicode characters) to numbers. This conversion requires the op_Implicit operator in Visual Basic, but not in C#. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.Others/CPP/cfromchar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/op_Explicit/cfromchar.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/op_Explicit/cfromchar.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Decimal.ConvFrom.Others/VB/cfromchar.vb" id="Snippet1"::: @@ -4861,9 +4818,8 @@ For , this method matches the IE The overloads of the method define the types from which the compiler can automatically convert a value without an explicit casting operator (in C#) or a call to a conversion function (in Visual Basic). They are widening conversions that do not involve data loss and do not throw an exception. ## Examples - The following example converts values to numbers. This conversion requires the op_Implicit operator in Visual Basic, but not in C# and C++. + The following example converts values to numbers. This conversion requires the op_Implicit operator in Visual Basic, but not in C#. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.SInts/CPP/cfromint16.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/op_Implicit/cfromint16.cs" interactive="try-dotnet" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/op_Implicit/cfromint16.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Decimal.ConvFrom.SInts/VB/cfromint16.vb" id="Snippet3"::: @@ -4928,7 +4884,6 @@ For , this method matches the IE ## Examples The following example converts values to numbers. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.SInts/CPP/cfromint32.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/op_Implicit/cfromint32.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/op_Implicit/cfromint32.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Decimal.ConvFrom.SInts/VB/cfromint32.vb" id="Snippet2"::: @@ -4993,7 +4948,6 @@ For , this method matches the IE ## Examples The following example converts values to numbers. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.SInts/CPP/cfromint64.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/op_Implicit/cfromint64.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/op_Implicit/cfromint64.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Decimal.ConvFrom.SInts/VB/cfromint64.vb" id="Snippet1"::: @@ -5066,7 +5020,6 @@ For , this method matches the IE ## Examples The following example converts values to numbers. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.SInts/CPP/cfromsbyte.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/op_Implicit/cfromsbyte.cs" interactive="try-dotnet" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/op_Implicit/cfromsbyte.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Decimal.ConvFrom.SInts/VB/cfromsbyte.vb" id="Snippet4"::: @@ -5139,7 +5092,6 @@ For , this method matches the IE ## Examples The following example converts values to numbers. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.UInts/CPP/cfromuint16.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/op_Implicit/cfromuint16.cs" interactive="try-dotnet" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/op_Implicit/cfromuint16.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Decimal.ConvFrom.UInts/VB/cfromuint16.vb" id="Snippet3"::: @@ -5212,7 +5164,6 @@ For , this method matches the IE ## Examples The following example converts values to numbers. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.UInts/CPP/cfromuint32.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/op_Implicit/cfromuint32.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/op_Implicit/cfromuint32.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Decimal.ConvFrom.UInts/VB/cfromuint32.vb" id="Snippet2"::: @@ -5285,7 +5236,6 @@ For , this method matches the IE ## Examples The following example converts values to numbers by using the to conversion operator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Decimal.ConvFrom.UInts/CPP/cfromuint64.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/op_Implicit/cfromuint64.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/op_Implicit/cfromuint64.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Decimal.ConvFrom.UInts/VB/cfromuint64.vb" id="Snippet1"::: @@ -7150,7 +7100,6 @@ It is recommended that a function return `1`, `0`, and `-1`, respectively. ## Examples The following example illustrates the use of `Subtract`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Decimal Example/CPP/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/Overview/source.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/Overview/source.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Decimal Example/VB/source.vb" id="Snippet4"::: @@ -9967,7 +9916,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following code example converts `Decimal` numbers to values using `ToDouble` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.ToXXX/CPP/tosgl_dbl.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/ToDouble/tosgl_dbl.cs" interactive="try-dotnet" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/ToDouble/tosgl_dbl.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.ToXXX/VB/tosgl_dbl.vb" id="Snippet5"::: @@ -10245,7 +10193,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following code example uses the `ToOACurrency` method to convert `Decimal` numbers to the equivalent OLE Automation Currency values that are contained in fields. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.OACurrency/CPP/tooacurrency.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/FromOACurrency/tooacurrency.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/FromOACurrency/tooacurrency.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.OACurrency/VB/tooacurrency.vb" id="Snippet1"::: @@ -10395,7 +10342,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following code example converts `Decimal` numbers to values using the `ToSingle` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.ToXXX/CPP/tosgl_dbl.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/ToDouble/tosgl_dbl.cs" interactive="try-dotnet" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/ToDouble/tosgl_dbl.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.ToXXX/VB/tosgl_dbl.vb" id="Snippet5"::: @@ -10496,7 +10442,6 @@ This member is an explicit interface member implementation. It can be used only The following example displays the amount of money in an account. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Decimal Example/CPP/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/Overview/source.cs" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/Overview/source.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Decimal Example/VB/source.vb" id="Snippet5"::: @@ -11129,7 +11074,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following code example uses the `Truncate` method to discard the fractional digits of several `Decimal` values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Flr_Neg_Rnd_Trnc/CPP/floor_neg_trunc.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/Negate/floor_neg_trunc.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/Negate/floor_neg_trunc.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.Flr_Neg_Rnd_Trnc/VB/floor_neg_trunc.vb" id="Snippet1"::: @@ -11919,7 +11863,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following code example illustrates the use of the `Zero` field. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Decimal.Fields/CPP/fields.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Decimal/MinusOne/fields.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Decimal/MinusOne/fields.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Decimal.Fields/VB/fields.vb" id="Snippet1"::: diff --git a/xml/System/Delegate.xml b/xml/System/Delegate.xml index c12ad95f42d..6872224f1be 100644 --- a/xml/System/Delegate.xml +++ b/xml/System/Delegate.xml @@ -89,19 +89,16 @@ Most languages implement a `delegate` keyword, and compilers for those languages are able to derive from the class; therefore, users should use the `delegate` keyword provided by the language. > [!NOTE] -> The common language runtime provides an `Invoke` method for each delegate type, with the same signature as the delegate. You do not have to call this method explicitly from C#, Visual Basic, or Visual C++, because the compilers call it automatically. The `Invoke` method is useful in [reflection](/dotnet/framework/reflection-and-codedom/reflection) when you want to find the signature of the delegate type. +> The common language runtime provides an `Invoke` method for each delegate type, with the same signature as the delegate. You don't have to call this method explicitly from C# or Visual Basic because the compilers call it automatically. The `Invoke` method is useful in [reflection](/dotnet/framework/reflection-and-codedom/reflection) when you want to find the signature of the delegate type. The common language runtime provides each delegate type with `BeginInvoke` and `EndInvoke` methods, to enable asynchronous invocation of the delegate. For more information about these methods, see [Calling Synchronous Methods Asynchronously](/dotnet/standard/asynchronous-programming-patterns/calling-synchronous-methods-asynchronously). The declaration of a delegate type establishes a contract that specifies the signature of one or more methods. A delegate is an instance of a delegate type that has references to: -- An instance method of a type and a target object assignable to that type. - -- An instance method of a type, with the hidden `this` parameter exposed in the formal parameter list. The delegate is said to be an open instance delegate. - -- A static method. - -- A static method and a target object assignable to the first parameter of the method. The delegate is said to be closed over its first argument. +- An instance method of a type and a target object assignable to that type. +- An instance method of a type, with the hidden `this` parameter exposed in the formal parameter list. The delegate is said to be an open instance delegate. +- A static method. +- A static method and a target object assignable to the first parameter of the method. The delegate is said to be closed over its first argument. For more information on delegate binding, see the method overload. @@ -116,12 +113,12 @@ Combining operations, such as and , do not alter existing delegates. Instead, such an operation returns a new delegate that contains the results of the operation, an unchanged delegate, or `null`. A combining operation returns `null` when the result of the operation is a delegate that does not reference at least one method. A combining operation returns an unchanged delegate when the requested operation has no effect. > [!NOTE] -> Managed languages use the and methods to implement delegate operations. Examples include the `AddHandler` and `RemoveHandler` statements in Visual Basic and the += and -= operators on delegate types in C#. +> Managed languages use the and methods to implement delegate operations. Examples include the `AddHandler` and `RemoveHandler` statements in Visual Basic and the += and -= operators on delegate types in C#. - Starting with the .NET Framework 4, generic delegate types can have variant type parameters. Contravariant type parameters can be used as parameter types of the delegate, and a covariant type parameter can be used as the return type. This feature allows generic delegate types that are constructed from the same generic type definition to be assignment-compatible if their type arguments are reference types with an inheritance relationship, as explained in [Covariance and Contravariance](/dotnet/standard/generics/covariance-and-contravariance). +Generic delegate types can have variant type parameters. Contravariant type parameters can be used as parameter types of the delegate, and a covariant type parameter can be used as the return type. This feature allows generic delegate types that are constructed from the same generic type definition to be assignment-compatible if their type arguments are reference types with an inheritance relationship, as explained in [Covariance and Contravariance](/dotnet/standard/generics/covariance-and-contravariance). > [!NOTE] -> Generic delegates that are assignment-compatible because of variance are not necessarily combinable. To be combinable, the types must match exactly. For example, suppose that a class named `Derived` is derived from a class named `Base`. A delegate of type `Action` (`Action(Of Base)` in Visual Basic) can be assigned to a variable of type `Action`, but the two delegates cannot be combined because the types do not match exactly. +> Generic delegates that are assignment-compatible because of variance are not necessarily combinable. To be combinable, the types must match exactly. For example, suppose that a class named `Derived` is derived from a class named `Base`. A delegate of type `Action` (`Action(Of Base)` in Visual Basic) can be assigned to a variable of type `Action`, but the two delegates cannot be combined because the types do not match exactly. If an invoked method throws an exception, the method stops executing, the exception is passed back to the caller of the delegate, and remaining methods in the invocation list are not invoked. Catching the exception in the caller does not alter this behavior. @@ -450,7 +447,7 @@ For examples, see [Supplemental API remarks for System.Delegate.CreateDelegate]( The invocation list can contain duplicate entries; that is, entries that refer to the same method on the same object. > [!NOTE] -> Generic delegates that are assignment-compatible because of variance are not necessarily combinable. To be combinable, the types must match exactly. For example, suppose that a class named `Derived` is derived from a class named `Base`. A delegate of type `Action` (`Action(Of Base)` in Visual Basic) can be assigned to a variable of type `Action`, as explained in [Covariance and Contravariance](/dotnet/standard/generics/covariance-and-contravariance), but the two delegates cannot be combined because the types do not match exactly. +> Generic delegates that are assignment-compatible because of variance are not necessarily combinable. To be combinable, the types must match exactly. For example, suppose that a class named `Derived` is derived from a class named `Base`. A delegate of type `Action` (`Action(Of Base)` in Visual Basic) can be assigned to a variable of type `Action`, as explained in [Covariance and Contravariance](/dotnet/standard/generics/covariance-and-contravariance), but the two delegates cannot be combined because the types do not match exactly. is useful for creating event handlers that call multiple methods each time an event occurs. @@ -575,7 +572,7 @@ For examples, see [Supplemental API remarks for System.Delegate.CreateDelegate]( The invocation list can contain duplicate entries; that is, entries that refer to the same method on the same object. > [!NOTE] -> Generic delegates that are assignment-compatible because of variance are not necessarily combinable. To be combinable, the types must match exactly. For example, suppose that a class named `Derived` is derived from a class named `Base`. A delegate of type `Action` (`Action(Of Base)` in Visual Basic) can be assigned to a variable of type `Action`, as explained in [Covariance and Contravariance](/dotnet/standard/generics/covariance-and-contravariance), but the two delegates cannot be combined because the types do not match exactly. +> Generic delegates that are assignment-compatible because of variance are not necessarily combinable. To be combinable, the types must match exactly. For example, suppose that a class named `Derived` is derived from a class named `Base`. A delegate of type `Action` (`Action(Of Base)` in Visual Basic) can be assigned to a variable of type `Action`, as explained in [Covariance and Contravariance](/dotnet/standard/generics/covariance-and-contravariance), but the two delegates cannot be combined because the types do not match exactly. is useful for creating event handlers that call multiple methods each time an event occurs. @@ -1217,7 +1214,7 @@ For examples, see [Supplemental API remarks for System.Delegate.CreateDelegate]( This method overload and the method overload, which always throws on failure to bind, provide the most flexible way to create delegates. You can use them to create delegates for either static or instance methods, with or without a first argument. > [!NOTE] -> If you do not supply a first argument, use the method overload for better performance. +> If you do not supply a first argument, use the method overload for better performance. For more information and examples, see [Supplemental API remarks for System.Delegate.CreateDelegate](/dotnet/fundamentals/runtime-libraries/system-delegate-createdelegate). @@ -1984,11 +1981,11 @@ The number, order, or type of parameters listed in is i The methods and targets are compared for equality as follows: -- If the two methods being compared are both static and are the same method on the same class, the methods are considered equal and the targets are also considered equal. +- If the two methods being compared are both static and are the same method on the same class, the methods are considered equal and the targets are also considered equal. -- If the two methods being compared are instance methods and are the same method on the same object, the methods are considered equal and the targets are also considered equal. +- If the two methods being compared are instance methods and are the same method on the same object, the methods are considered equal and the targets are also considered equal. -- Otherwise, the methods are not considered to be equal and the targets are also not considered to be equal. +- Otherwise, the methods are not considered to be equal and the targets are also not considered to be equal. Two invocation lists are considered identical only if they have the same order and the corresponding elements from the two lists represent the same method and target. @@ -2386,11 +2383,11 @@ The number, order, or type of parameters listed in is i The methods and targets are compared for equality as follows: -- If the two methods being compared are both static and are the same method on the same class, the methods are considered equal and the targets are also considered equal. +- If the two methods being compared are both static and are the same method on the same class, the methods are considered equal and the targets are also considered equal. -- If the two methods being compared are instance methods and are the same method on the same object, the methods are considered equal and the targets are also considered equal. +- If the two methods being compared are instance methods and are the same method on the same object, the methods are considered equal and the targets are also considered equal. -- Otherwise, the methods are not considered to be equal and the targets are also not considered to be equal. +- Otherwise, the methods are not considered to be equal and the targets are also not considered to be equal. Two invocation lists are considered identical if they have the same order and the corresponding elements from the two lists represent the same method and target. @@ -2459,11 +2456,11 @@ The number, order, or type of parameters listed in is i The methods and targets are compared for equality as follows: -- If the two methods being compared are both static and are the same method on the same class, the methods are considered equal and the targets are also considered equal. +- If the two methods being compared are both static and are the same method on the same class, the methods are considered equal and the targets are also considered equal. -- If the two methods being compared are instance methods and are the same method on the same object, the methods are considered equal and the targets are also considered equal. +- If the two methods being compared are instance methods and are the same method on the same object, the methods are considered equal and the targets are also considered equal. -- Otherwise, the methods are not considered to be equal and the targets are also not considered to be equal. +- Otherwise, the methods are not considered to be equal and the targets are also not considered to be equal. Two invocation lists are not equal if they have different sizes, if they are ordered differently, or if at least one element from one list represents a method or target that is different from that represented by its corresponding element in the other list. diff --git a/xml/System/Double.xml b/xml/System/Double.xml index 49786fbe5be..15797b5b48d 100644 --- a/xml/System/Double.xml +++ b/xml/System/Double.xml @@ -1156,7 +1156,6 @@ This computes `arctan(x) / π` in the interval `[-0.5, +0.5]`. method for several value and reference types. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/T.CompareTo/CPP/cat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Boolean/CompareTo/cat.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/T.CompareTo/VB/cat.vb" id="Snippet1"::: ]]> @@ -2643,7 +2642,6 @@ A return value of `false` does not imply that : - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Double/CPP/doublesample.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System/Double/CompareTo/doublesample.cs" interactive="try-dotnet-method" id="Snippet11"::: :::code language="fsharp" source="~/snippets/fsharp/System/Double/CompareTo/doublesample.fs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Double/VB/doublesample.vb" id="Snippet11"::: @@ -2778,7 +2776,6 @@ This method correctly handles floating-point values and so `2.0` and `3.0` will ## Examples The following code example illustrates the use of : - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Double/CPP/doublesample.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System/Double/CompareTo/doublesample.cs" id="Snippet8"::: :::code language="fsharp" source="~/snippets/fsharp/System/Double/CompareTo/doublesample.fs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Double/VB/doublesample.vb" id="Snippet8"::: @@ -2894,15 +2891,12 @@ This method correctly handles floating-point values and so `2.0` and `3.0` will ## Examples The following code example illustrates the use of : - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Double/CPP/doublesample.cpp" id="Snippet13"::: :::code language="csharp" source="~/snippets/csharp/System/Double/CompareTo/doublesample.cs" id="Snippet13"::: :::code language="fsharp" source="~/snippets/fsharp/System/Double/CompareTo/doublesample.fs" id="Snippet13"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Double/VB/doublesample.vb" id="Snippet13"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Double/CPP/doublesample.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Double/CompareTo/doublesample.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/Double/CompareTo/doublesample.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Double/VB/doublesample.vb" id="Snippet4"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Double/CPP/doublesample.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System/Double/CompareTo/doublesample.cs" id="Snippet9"::: :::code language="fsharp" source="~/snippets/fsharp/System/Double/CompareTo/doublesample.fs" id="Snippet9"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Double/VB/doublesample.vb" id="Snippet9"::: @@ -3117,7 +3111,6 @@ A return value of `false` does not imply that : - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Double/CPP/doublesample.cpp" id="Snippet12"::: :::code language="csharp" source="~/snippets/csharp/System/Double/CompareTo/doublesample.cs" id="Snippet12"::: :::code language="fsharp" source="~/snippets/fsharp/System/Double/CompareTo/doublesample.fs" id="Snippet12"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Double/VB/doublesample.vb" id="Snippet12"::: @@ -3868,7 +3861,6 @@ For this method matches the IEEE 754:2 ## Examples The following code example illustrates the use of : - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Double Example/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Double/Overview/source.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Double/Overview/source.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Double Example/VB/source.vb" id="Snippet2"::: @@ -4167,7 +4159,6 @@ For this method matches the IEEE 754:2 ## Examples The following code example illustrates the use of : - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Double Example/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Double/Overview/source.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Double/Overview/source.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Double Example/VB/source.vb" id="Snippet2"::: @@ -4283,7 +4274,6 @@ Use the method to determine whether a value is not The following example illustrates the use of . -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Double/CPP/doublesample.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System/Double/CompareTo/doublesample.cs" interactive="try-dotnet-method" id="Snippet7"::: :::code language="fsharp" source="~/snippets/fsharp/System/Double/CompareTo/doublesample.fs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Double/VB/doublesample.vb" id="Snippet7"::: @@ -4348,7 +4338,6 @@ Use to determine whether a value eval The following code example illustrates the use of : -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Double/CPP/doublesample.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System/Double/CompareTo/doublesample.cs" interactive="try-dotnet-method" id="Snippet9"::: :::code language="fsharp" source="~/snippets/fsharp/System/Double/CompareTo/doublesample.fs" id="Snippet9"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Double/VB/doublesample.vb" id="Snippet9"::: @@ -4861,7 +4850,6 @@ If a separator is encountered in the `s` parameter during a parse operation, and ## Examples The following example illustrates the use of the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Double Example/CPP/source.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/Double/Overview/source.cs" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System/Double/Overview/source.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Double Example/VB/source.vb" id="Snippet5"::: @@ -5593,7 +5581,6 @@ Use to determine whether a value eval The following code example illustrates the use of : -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Double/CPP/doublesample.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System/Double/CompareTo/doublesample.cs" interactive="try-dotnet-method" id="Snippet10"::: :::code language="fsharp" source="~/snippets/fsharp/System/Double/CompareTo/doublesample.fs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Double/VB/doublesample.vb" id="Snippet10"::: @@ -9360,7 +9347,6 @@ Tau is approximately 6.2831853071795864769. The following example illustrates the use of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Double/CPP/doublesample.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Double/CompareTo/doublesample.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/Double/CompareTo/doublesample.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Double/VB/doublesample.vb" id="Snippet3"::: @@ -9487,7 +9473,6 @@ Tau is approximately 6.2831853071795864769. The following example illustrates the use of , taking a and an as parameters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Double Example/CPP/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Double/Overview/source.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/Double/Overview/source.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Double Example/VB/source.vb" id="Snippet4"::: @@ -9598,7 +9583,6 @@ Tau is approximately 6.2831853071795864769. The following example displays several values using the supported standard numeric format specifiers together with three custom numeric format strings. One of those custom format strings illustrates how to pad a value with leading zeros. In addition, the example uses precision specifiers with each standard format specifier except for "R". The values of the precision specifiers range from 0 to 3. To convert the numeric values to strings, the example uses the formatting conventions of the en-US culture. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Double.ToString/cpp/tostring3.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Double/ToString/ToString1.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/Double/ToString/ToString1.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Double.ToString/vb/ToString1.vb" id="Snippet3"::: @@ -9717,14 +9701,12 @@ Tau is approximately 6.2831853071795864769. ## Examples The following example displays a value using each of the supported standard numeric format specifiers for several different cultures. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Double.ToString/cpp/tostring1.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Double/ToString/ToString1.cs" interactive="try-dotnet-method" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/Double/ToString/ToString1.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Double.ToString/vb/ToString1.vb" id="Snippet4"::: The following example illustrates the use of , taking a and an as parameters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Double Example/CPP/source.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Double/Overview/source.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/Double/Overview/source.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Double Example/VB/source.vb" id="Snippet4"::: diff --git a/xml/System/EntryPointNotFoundException.xml b/xml/System/EntryPointNotFoundException.xml index a0370d64052..019a2954bda 100644 --- a/xml/System/EntryPointNotFoundException.xml +++ b/xml/System/EntryPointNotFoundException.xml @@ -59,65 +59,65 @@ The exception that is thrown when an attempt to load a class fails due to the absence of an entry method. - exception is thrown when the common language runtime is unable to load an assembly because it cannot identify the assembly's entry point. This exception can be thrown under the following conditions: - -- The common language runtime is unable to locate an application entry point (typically a `Main` method) in an executable assembly. The application entry point must be a global or `static` method that has either no parameters or a string array as its only parameter. The entry point can return `void`, or it can return an or exit code. An application assembly cannot define more than one entry point. - -- The call to a function in a Windows DLL cannot be resolved because the function cannot be found. In the following example, an exception is thrown because User32.dll does not include a function named `GetMyNumber`. - + exception is thrown when the common language runtime is unable to load an assembly because it cannot identify the assembly's entry point. This exception can be thrown under the following conditions: + +- The common language runtime is unable to locate an application entry point (typically a `Main` method) in an executable assembly. The application entry point must be a global or `static` method that has either no parameters or a string array as its only parameter. The entry point can return `void`, or it can return an or exit code. An application assembly cannot define more than one entry point. + +- The call to a function in a Windows DLL cannot be resolved because the function cannot be found. In the following example, an exception is thrown because User32.dll does not include a function named `GetMyNumber`. + :::code language="csharp" source="~/snippets/csharp/System/EntryPointNotFoundException/Overview/nofunction1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/EntryPointNotFoundException/Overview/nofunction1.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.entrypointnotfoundexception.class/vb/nofunction1.vb" id="Snippet1"::: - -- The call to a function in a Windows DLL cannot be resolved because the name used in the method call does not match a name found in the assembly. Frequently, this occurs because the field is either implicitly or explicitly set to `true`, the called method includes one or more string parameters and has both an ANSI and a Unicode version, and the name used in the method call does not correspond to the name of this ANSI or Unicode version. The following example provides an illustration by attempting to call the Windows `MessageBox` function in User32.dll. Because the first method definition specifies for string marshaling, the common language looks for the wide-character version of the function, `MessageBoxW`, instead of the name used in the method call, `MessageBox`. The second method definition corrects this problem by calling the `MessageBoxW` instead of the `MessageBox` function. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.entrypointnotfoundexception.class/vb/nofunction1.vb" id="Snippet1"::: + +- The call to a function in a Windows DLL cannot be resolved because the name used in the method call does not match a name found in the assembly. Frequently, this occurs because the field is either implicitly or explicitly set to `true`, the called method includes one or more string parameters and has both an ANSI and a Unicode version, and the name used in the method call does not correspond to the name of this ANSI or Unicode version. The following example provides an illustration by attempting to call the Windows `MessageBox` function in User32.dll. Because the first method definition specifies for string marshaling, the common language looks for the wide-character version of the function, `MessageBoxW`, instead of the name used in the method call, `MessageBox`. The second method definition corrects this problem by calling the `MessageBoxW` instead of the `MessageBox` function. + :::code language="csharp" source="~/snippets/csharp/System/EntryPointNotFoundException/Overview/badcall1.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/EntryPointNotFoundException/Overview/badcall1.fs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.entrypointnotfoundexception.class/vb/badcall1.vb" id="Snippet2"::: - -- You are trying to call a function in a dynamic link library by its simple name rather than its decorated name. Typically, the C++ compiler generates a decorated name for DLL functions. For example, the following C++ code defines a function named `Double` in a library named TestDll.dll. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.entrypointnotfoundexception.class/cpp/testdll.cpp" id="Snippet6"::: - - When the code in the following example tries to call the function, an exception is thrown because the `Double` function cannot be found. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.entrypointnotfoundexception.class/vb/badcall1.vb" id="Snippet2"::: + +- You're trying to call a function in a dynamic link library by its simple name rather than its decorated name. Typically, the C++ compiler generates a decorated name for DLL functions. For example, the following C++ code defines a function named `Double` in a library named TestDll.dll. + + :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.entrypointnotfoundexception.class/cpp/testdll.cpp" id="Snippet6"::: + + When the code in the following example tries to call the function, an exception is thrown because the `Double` function cannot be found. + :::code language="csharp" source="~/snippets/csharp/System/EntryPointNotFoundException/Overview/mangle1.cs" id="Snippet7"::: :::code language="fsharp" source="~/snippets/fsharp/System/EntryPointNotFoundException/Overview/mangle1.fs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.entrypointnotfoundexception.class/vb/mangle1.vb" id="Snippet7"::: - - However, if the function is called by using its decorated name (in this case, `?Double@@YAHH@Z`), the function call succeeds, as the following example shows. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.entrypointnotfoundexception.class/vb/mangle1.vb" id="Snippet7"::: + + However, if the function is called by using its decorated name (in this case, `?Double@@YAHH@Z`), the function call succeeds, as the following example shows. + :::code language="csharp" source="~/snippets/csharp/System/EntryPointNotFoundException/Overview/mangle2.cs" id="Snippet8"::: :::code language="fsharp" source="~/snippets/fsharp/System/EntryPointNotFoundException/Overview/mangle2.fs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.entrypointnotfoundexception.class/vb/mangle2.vb" id="Snippet8"::: - - You can find the decorated names of functions exported by a DLL by using a utility such as Dumpbin.exe. - -- You are attempting to call a method in a managed assembly as if it were an unmanaged dynamic link library. To see this in action, compile the following example to an assembly named StringUtilities.dll. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.entrypointnotfoundexception.class/vb/mangle2.vb" id="Snippet8"::: + + You can find the decorated names of functions exported by a DLL by using a utility such as Dumpbin.exe. + +- You are attempting to call a method in a managed assembly as if it were an unmanaged dynamic link library. To see this in action, compile the following example to an assembly named StringUtilities.dll. + :::code language="csharp" source="~/snippets/csharp/System/EntryPointNotFoundException/Overview/stringutilities.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/EntryPointNotFoundException/Overview/stringutilities.fs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.entrypointnotfoundexception.class/vb/stringutilities.vb" id="Snippet3"::: - - Then compile and execute the following example, which attempts to call the `StringUtilities.SayGoodMorning` method in the StringUtilities.dll dynamic link library as if it were unmanaged code. The result is an exception. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.entrypointnotfoundexception.class/vb/stringutilities.vb" id="Snippet3"::: + + Then compile and execute the following example, which attempts to call the `StringUtilities.SayGoodMorning` method in the StringUtilities.dll dynamic link library as if it were unmanaged code. The result is an exception. + :::code language="csharp" source="~/snippets/csharp/System/EntryPointNotFoundException/Overview/importassembly1.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/EntryPointNotFoundException/Overview/importassembly1.fs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.entrypointnotfoundexception.class/vb/importassembly1.vb" id="Snippet4"::: - - To eliminate the exception, add a reference to the managed assembly and access the `StringUtilities.SayGoodMorning` method just as you would access any other method in managed code, as the following example does. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.entrypointnotfoundexception.class/vb/importassembly1.vb" id="Snippet4"::: + + To eliminate the exception, add a reference to the managed assembly and access the `StringUtilities.SayGoodMorning` method just as you would access any other method in managed code, as the following example does. + :::code language="csharp" source="~/snippets/csharp/System/EntryPointNotFoundException/Overview/fiximportassembly1.cs" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System/EntryPointNotFoundException/Overview/fiximportassembly1.fs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.entrypointnotfoundexception.class/vb/fiximportassembly1.vb" id="Snippet5"::: - -- You are trying to call a method in a COM DLL as if it were a Windows DLL. To access a COM DLL, select the **Add Reference** option in Visual Studio to add a reference to the project, and then select the type library from the **COM** tab. - - For a list of initial property values for an instance of , see the constructors. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.entrypointnotfoundexception.class/vb/fiximportassembly1.vb" id="Snippet5"::: + +- You are trying to call a method in a COM DLL as if it were a Windows DLL. To access a COM DLL, select the **Add Reference** option in Visual Studio to add a reference to the project, and then select the type library from the **COM** tab. + + For a list of initial property values for an instance of , see the constructors. + ]]> @@ -169,18 +169,18 @@ Initializes a new instance of the class. - property of the new instance to a system-supplied message that describes the error, such as "Entry point was not found." This message takes into account the current system culture. - - The following table shows the initial property values for an instance of . - -|Property|Value| -|--------------|-----------| -||A null reference (`Nothing` in Visual Basic).| -||The localized error message string.| - + property of the new instance to a system-supplied message that describes the error, such as "Entry point was not found." This message takes into account the current system culture. + + The following table shows the initial property values for an instance of . + +|Property|Value| +|--------------|-----------| +||A null reference (`Nothing` in Visual Basic).| +||The localized error message string.| + ]]> @@ -225,18 +225,18 @@ The error message that explains the reason for the exception. Initializes a new instance of the class with a specified error message. - . - -|Property|Value| -|--------------|-----------| -||A null reference (`Nothing` in Visual Basic).| -||The error message string.| - + . + +|Property|Value| +|--------------|-----------| +||A null reference (`Nothing` in Visual Basic).| +||The error message string.| + ]]> @@ -296,11 +296,11 @@ The contextual information about the source or destination. Initializes a new instance of the class with serialized data. - @@ -347,18 +347,18 @@ The exception that is the cause of the current exception. If the parameter is not a null reference ( in Visual Basic), the current exception is raised in a block that handles the inner exception. Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. - property. The property returns the same value that is passed into the constructor, or a null reference (`Nothing` in Visual Basic) if the property does not supply the inner exception value to the constructor. - - The following table shows the initial property values for an instance of . - -|Property|Value| -|--------------|-----------| -||The inner exception reference.| -||The error message string.| - + property. The property returns the same value that is passed into the constructor, or a null reference (`Nothing` in Visual Basic) if the property does not supply the inner exception value to the constructor. + + The following table shows the initial property values for an instance of . + +|Property|Value| +|--------------|-----------| +||The inner exception reference.| +||The error message string.| + ]]> diff --git a/xml/System/Enum.xml b/xml/System/Enum.xml index 71556131620..39d7c18a181 100644 --- a/xml/System/Enum.xml +++ b/xml/System/Enum.xml @@ -214,7 +214,6 @@ ## Examples The following example illustrates the use of `CompareTo` in the context of `Enum`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/enumcompareto/CPP/EnumCompareTo.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Enum/CompareTo/EnumCompareTo.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Enum/CompareTo/EnumCompareTo.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/enumcompareto/VB/EnumCompareTo.vb" id="Snippet1"::: @@ -301,7 +300,6 @@ ## Examples The following example illustrates the use of the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/enumequals/CPP/EnumEquals.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Enum/Equals/EnumEquals.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Enum/Equals/EnumEquals.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/enumequals/VB/EnumEquals.vb" id="Snippet1"::: @@ -397,7 +395,6 @@ ## Examples The following example illustrates the use of `Format` in the context of `Enum`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/enumformat/CPP/EnumFormat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Enum/Format/EnumFormat.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Enum/Format/EnumFormat.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/enumformat/VB/EnumFormat.vb" id="Snippet1"::: @@ -543,7 +540,6 @@ ## Examples The following example illustrates the use of `GetName`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/enumgetname/CPP/EnumGetName.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Enum/GetName/EnumGetName.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Enum/GetName/EnumGetName.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/enumgetname/VB/EnumGetName.vb" id="Snippet1"::: @@ -682,7 +678,6 @@ ## Examples The following example illustrates the use of the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/enumgetnames/CPP/EnumGetNames.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Enum/GetNames/EnumGetNames.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Enum/GetNames/EnumGetNames.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/enumgetnames/VB/EnumGetNames.vb" id="Snippet1"::: @@ -960,7 +955,6 @@ ## Examples The following example illustrates the use of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/enumgetvalues/CPP/EnumGetValues.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Enum/GetValues/EnumGetValues.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Enum/GetValues/EnumGetValues.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/enumgetvalues/VB/EnumGetValues.vb" id="Snippet1"::: @@ -1507,7 +1501,6 @@ ## Examples The following example uses the method to parse an array of strings that are created by calling the method. It also uses the method to parse an enumeration value that consists of a bit field. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/enumparse/CPP/EnumParse.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Enum/Parse/EnumParse.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Enum/Parse/EnumParse.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/enumparse/VB/EnumParse.vb" id="Snippet1"::: @@ -3720,7 +3713,6 @@ ## Examples The following example demonstrates converting an enumerated value to a string. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Enum.ToString2 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Enum/ToString/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Enum/ToString/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Enum.ToString2 Example/VB/source.vb" id="Snippet1"::: @@ -3885,7 +3877,6 @@ ## Examples The following example demonstrates how to convert an enumerated value to a string. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/enum.tostring/CPP/tostr.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Enum/ToString/tostr.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Enum/ToString/tostr.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/enum.tostring/VB/tostr.vb" id="Snippet1"::: diff --git a/xml/System/Environment+SpecialFolder.xml b/xml/System/Environment+SpecialFolder.xml index 94ec53afb30..2ac063278da 100644 --- a/xml/System/Environment+SpecialFolder.xml +++ b/xml/System/Environment+SpecialFolder.xml @@ -58,25 +58,24 @@ Specifies enumerated constants used to retrieve directory paths to system special folders. - method returns the locations associated with this enumeration. The locations of these folders can have different values on different operating systems, the user can change some of the locations, and the locations are localized. + + For more information about special folders, see the [KNOWNFOLDERID](/windows/desktop/shell/knownfolderid) constants in the Windows documentation. + + + +## Examples + The following example shows how to use with the method to get the System directory. -## Remarks - The system special folders are folders such as **Program Files**, **Programs**, **System**, or **Startup**, which contain common information. Special folders are set by default by the system, or explicitly by the user, when installing a version of Windows. - - The method returns the locations associated with this enumeration. The locations of these folders can have different values on different operating systems, the user can change some of the locations, and the locations are localized. - - For more information about special folders, see the [KNOWNFOLDERID](/windows/desktop/shell/knownfolderid) constants in the Windows documentation. - - - -## Examples - The following example shows how to use with the method to get the System directory. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Environment.GetFolderPath/CPP/getfolderpath.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Environment+SpecialFolder/Overview/getfolderpath.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Environment+SpecialFolder/Overview/getfolderpath.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Environment.GetFolderPath/VB/getfolderpath.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Environment.GetFolderPath/VB/getfolderpath.vb" id="Snippet1"::: + ]]> @@ -535,8 +534,8 @@ 43 - The directory for components that are shared across applications. - + The directory for components that are shared across applications. + To get the x86 common program files directory in a non-x86 process, use the member. @@ -1546,8 +1545,8 @@ 38 - The program files directory. - + The program files directory. + In a non-x86 process, passing to the method returns the path for non-x86 programs. To get the x86 program files directory in a non-x86 process, use the member. diff --git a/xml/System/Environment.xml b/xml/System/Environment.xml index b126fd1cbe6..7c8a065ca48 100644 --- a/xml/System/Environment.xml +++ b/xml/System/Environment.xml @@ -80,7 +80,6 @@ ## Examples The following example displays a list of information about the current environment. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/environment.class/CPP/env0.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Environment/Overview/env0.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Environment/Overview/env0.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/environment.class/VB/env0.vb" id="Snippet1"::: @@ -149,7 +148,6 @@ ## Examples The following example displays its own command line. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/environment.CommandLine/CPP/commandline.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Environment/CommandLine/commandline.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Environment/CommandLine/commandline.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/environment.CommandLine/VB/commandline.vb" id="Snippet1"::: @@ -260,7 +258,6 @@ ## Examples The following example demonstrates setting the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Environment/CPP/Vars1.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Environment/CurrentDirectory/Vars1.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/Environment/CurrentDirectory/Vars1.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Environment/VB/Vars1.vb" id="Snippet4"::: @@ -593,7 +590,6 @@ Invalid argument ## Examples The following example shows how to obtain the system drive and system root variables. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/environment.ExpandEnvironmentVariables/CPP/expandenvironmentvariables.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Environment/ExpandEnvironmentVariables/expandenvironmentvariables.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Environment/ExpandEnvironmentVariables/expandenvironmentvariables.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/environment.ExpandEnvironmentVariables/VB/expandenvironmentvariables.vb" id="Snippet1"::: @@ -856,7 +852,6 @@ In .NET 5 and later versions, for single-file publishing, the first element is t ## Examples The following example displays the application's command line arguments. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Environment.GetCommandLineArgs/CPP/getcommandlineargs.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Environment/GetCommandLineArgs/getcommandlineargs.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Environment/GetCommandLineArgs/getcommandlineargs.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Environment.GetCommandLineArgs/VB/getcommandlineargs.vb" id="Snippet1"::: @@ -938,7 +933,6 @@ In .NET 5 and later versions, for single-file publishing, the first element is t method to retrieve the `windir` environment variable, which contains the path of the Windows directory. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Environment/CPP/Vars1.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Environment/CurrentDirectory/Vars1.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/Environment/CurrentDirectory/Vars1.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Environment/VB/Vars1.vb" id="Snippet4"::: @@ -1126,7 +1120,6 @@ On Unix-like systems, the `GetEnvironmentVariables` method retrieves the name an The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Environment.GetEnvironmentVariables/CPP/getenvironmentvariables.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Environment/GetEnvironmentVariables/getenvironmentvariables.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Environment/GetEnvironmentVariables/getenvironmentvariables.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Environment.GetEnvironmentVariables/VB/getenvironmentvariables.vb" id="Snippet1"::: @@ -1301,7 +1294,6 @@ The following example creates environment variables for the method to return and display the path associated with the `folder` parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Environment.GetFolderPath/CPP/getfolderpath.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Environment+SpecialFolder/Overview/getfolderpath.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Environment+SpecialFolder/Overview/getfolderpath.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Environment.GetFolderPath/VB/getfolderpath.vb" id="Snippet1"::: @@ -1446,7 +1438,6 @@ The following example creates environment variables for the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Environment.GetLogicalDrives/CPP/getlogicaldrives.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Environment/GetLogicalDrives/getlogicaldrives.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Environment/GetLogicalDrives/getlogicaldrives.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Environment.GetLogicalDrives/VB/getlogicaldrives.vb" id="Snippet1"::: @@ -1704,7 +1695,6 @@ The following example creates environment variables for the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/environment.processorcount/CPP/pc.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Environment/ProcessorCount/pc.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Environment/ProcessorCount/pc.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/environment.processorcount/VB/pc.vb" id="Snippet1"::: @@ -2347,7 +2335,6 @@ The following example creates environment variables for the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Environment.StackTrace/CPP/stacktrace.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Environment/StackTrace/stacktrace.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Environment/StackTrace/stacktrace.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Environment.StackTrace/VB/stacktrace.vb" id="Snippet1"::: @@ -2412,7 +2399,6 @@ The following example creates environment variables for the property. The property cycles between , which is a negative number, and once every 49.8 days. This code sample removes the sign bit to yield a nonnegative number that cycles between zero and once every 24.9 days. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Environment.TickCount/CPP/tickcount.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Environment/TickCount/tickcount.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Environment/TickCount/tickcount.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Environment.TickCount/VB/tickcount.vb" id="Snippet1"::: @@ -2709,7 +2694,6 @@ The following example creates environment variables for the class. An instance of the event data class is passed to the event handler for the `ThresholdReached` event. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/eventsoverview/cpp/programwithdata.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System/EventArgs/Overview/programwithdata.cs" id="Snippet6"::: :::code language="fsharp" source="~/snippets/fsharp/System/EventArgs/Overview/programwithdata.fs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventsoverview/vb/module1withdata.vb" id="Snippet6"::: diff --git a/xml/System/EventHandler`1.xml b/xml/System/EventHandler`1.xml index a0792d082ef..20e53d225e0 100644 --- a/xml/System/EventHandler`1.xml +++ b/xml/System/EventHandler`1.xml @@ -110,7 +110,6 @@ The event model in .NET is based on having an event delegate that connects an ev The following example shows an event named `ThresholdReached`. The event is associated with an delegate. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/eventsoverview/cpp/programwithdata.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System/EventArgs/Overview/programwithdata.cs" id="Snippet6"::: :::code language="fsharp" source="~/snippets/fsharp/System/EventArgs/Overview/programwithdata.fs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/eventsoverview/vb/module1withdata.vb" id="Snippet6"::: diff --git a/xml/System/Exception.xml b/xml/System/Exception.xml index dd0a989c77b..740738bbda3 100644 --- a/xml/System/Exception.xml +++ b/xml/System/Exception.xml @@ -168,7 +168,6 @@ ## Examples The following code example derives an `Exception` that uses a predefined message. The code demonstrates the use of the parameterless constructor for the derived class and the base `Exception` class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Exception.Ctor/CPP/new.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Exception/.ctor/new.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Exception/.ctor/new.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Exception.Ctor/VB/new.vb" id="Snippet1"::: @@ -238,7 +237,6 @@ ## Examples The following code example derives an `Exception` for a specific condition. The code demonstrates the use of the constructor that takes a caller-specified message as a parameter, for both the derived class and the base `Exception` class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Exception.Ctor/CPP/news.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Exception/.ctor/news.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Exception/.ctor/news.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Exception.Ctor/VB/news.vb" id="Snippet2"::: @@ -312,7 +310,6 @@ ## Examples The following code example defines a derived serializable `Exception` class. The code forces a divide-by-0 error and then creates an instance of the derived exception using the (, ) constructor. The code serializes the instance to a file, deserializes the file into a new exception, which it throws, and then catches and displays the exception's data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Exception.GetObjectData/CPP/getobjdata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Exception/.ctor/getobjdata.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Exception/.ctor/getobjdata.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Exception.GetObjectData/VB/getobjdata.vb" id="Snippet1"::: @@ -390,7 +387,6 @@ ## Examples The following code example derives an `Exception` for a specific condition. The code demonstrates the use of the constructor that takes a message and an inner exception as parameters, for both the derived class and the base `Exception` class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Exception.Ctor/CPP/newsi.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Exception/.ctor/newsi.cs" interactive="try-dotnet" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/Exception/.ctor/newsi.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Exception.Ctor/VB/newsi.vb" id="Snippet3"::: @@ -455,7 +451,6 @@ property. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/exception.data/CPP/data.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Exception/Data/data.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Exception/Data/data.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/exception.data/VB/data.vb" id="Snippet1"::: @@ -525,7 +520,6 @@ The following example demonstrates how to add and retrieve information using the ## Examples The following code example defines two derived `Exception` classes. It forces an exception and then throws it again with each of the derived classes. The code shows the use of the `GetBaseException` method to retrieve the original exception. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Exception.GetBaseException/CPP/getbaseexc.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Exception/GetBaseException/getbaseexc.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Exception/GetBaseException/getbaseexc.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Exception.GetBaseException/VB/getbaseexc.vb" id="Snippet1"::: @@ -609,7 +603,6 @@ The following example demonstrates how to add and retrieve information using the ## Examples The following code example defines a derived serializable `Exception` class that implements `GetObjectData`, which makes minor changes to two properties and then calls the base class to perform the serialization. The example forces a divide-by-0 error and then creates an instance of the derived exception. The code serializes the instance to a file, deserializes the file into a new exception, which it throws, and then catches and displays the exception's data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Exception.GetObjectData/CPP/getobjdata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Exception/.ctor/getobjdata.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Exception/.ctor/getobjdata.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Exception.GetObjectData/VB/getobjdata.vb" id="Snippet1"::: @@ -735,7 +728,6 @@ The following example demonstrates how to add and retrieve information using the ## Examples The following code example throws an `Exception` that sets the `HelpLink` property in its constructor and then catches the exception and displays `HelpLink`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Exception.Properties/CPP/properties.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Exception/HelpLink/properties.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Exception/HelpLink/properties.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Exception.Properties/VB/properties.vb" id="Snippet1"::: @@ -804,7 +796,6 @@ The following example demonstrates how to add and retrieve information using the ## Examples The following code example defines a derived `Exception` class that sets the `HResult` property to a custom value in its constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Exception.HResult/CPP/hresult.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Exception/HResult/hresult.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Exception/HResult/hresult.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Exception.HResult/VB/hresult.vb" id="Snippet1"::: @@ -880,7 +871,6 @@ The following example demonstrates how to add and retrieve information using the ## Examples The following example demonstrates throwing and catching an exception that references an inner exception. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/InnerEx/CPP/innerex.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Exception/InnerException/innerex.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Exception/InnerException/innerex.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/InnerEx/VB/innerex.vb" id="Snippet1"::: @@ -957,7 +947,6 @@ The value of the property is included in the inf The following code example throws and then catches an exception and displays the exception's text message using the property. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Exception.Properties/CPP/properties.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Exception/HelpLink/properties.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Exception/HelpLink/properties.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Exception.Properties/VB/properties.vb" id="Snippet1"::: @@ -1103,7 +1092,6 @@ The following code example throws and then catches an ex ## Examples The following example throws an `Exception` that sets the `Source` property in its constructor and then catches the exception and displays `Source`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Exception.Properties/CPP/properties.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Exception/HelpLink/properties.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Exception/HelpLink/properties.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Exception.Properties/VB/properties.vb" id="Snippet1"::: @@ -1182,7 +1170,6 @@ The following code example throws and then catches an ex ## Examples The following code example throws an `Exception` and then catches it and displays a stack trace using the `StackTrace` property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Exception.Properties/CPP/properties.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Exception/HelpLink/properties.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Exception/HelpLink/properties.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Exception.Properties/VB/properties.vb" id="Snippet1"::: @@ -1263,7 +1250,6 @@ The following code example throws and then catches an ex ## Examples The following code example throws an `Exception` and then catches it and displays the originating method using the `TargetSite` property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Exception.Properties/CPP/properties.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Exception/HelpLink/properties.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Exception/HelpLink/properties.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Exception.Properties/VB/properties.vb" id="Snippet1"::: @@ -1341,7 +1327,6 @@ The following code example throws and then catches an ex ## Examples The following example causes an exception and displays the result of calling on that exception. Note that the method is called implicitly when the Exception class instance appears in the argument list of the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.exception.tostring/cpp/ToStringEx1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Exception/ToString/ToStringEx1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Exception/ToString/ToStringEx1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.exception.tostring/vb/ToStringEx1.vb" id="Snippet1"::: diff --git a/xml/System/FlagsAttribute.xml b/xml/System/FlagsAttribute.xml index 4b4d17a8568..cffdd42d07f 100644 --- a/xml/System/FlagsAttribute.xml +++ b/xml/System/FlagsAttribute.xml @@ -111,14 +111,12 @@ ## Examples The following example defines a `PhoneService` enumeration that represents forms of communication provided by a telephone company. It initializes three variables representing the service provided to three different households, and then indicates which households have no service, which households have only cell phone service, and which households have both cell phone and land line service. Finally, it implicitly calls the method to display the types of service provided to each household. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.FlagsAttribute/CPP/flags1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/FlagsAttribute/Overview/flags1.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/FlagsAttribute/Overview/flags1.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.FlagsAttribute/VB/flags1.vb" id="Snippet2"::: The following example illustrates the use of the `FlagsAttribute` attribute and shows the effect on the method of using `FlagsAttribute` on an declaration. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.FlagsAttribute/CPP/flags.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/FlagsAttribute/Overview/flags.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/FlagsAttribute/Overview/flags.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.FlagsAttribute/VB/flags.vb" id="Snippet1"::: diff --git a/xml/System/Func`2.xml b/xml/System/Func`2.xml index e56571764b9..8dccd8c4841 100644 --- a/xml/System/Func`2.xml +++ b/xml/System/Func`2.xml @@ -97,48 +97,47 @@ Encapsulates a method that has one parameter and returns a value of the type specified by the parameter. The return value of the method that this delegate encapsulates. - [!NOTE] -> To reference a method that has one parameter and returns `void` (or in Visual Basic, that is declared as a `Sub` rather than as a `Function`), use the generic delegate instead. - - When you use the delegate, you do not have to explicitly define a delegate that encapsulates a method with a single parameter. For example, the following code explicitly declares a delegate named `ConvertMethod` and assigns a reference to the `UppercaseString` method to its delegate instance. - +> To reference a method that has one parameter and returns `void` (or in Visual Basic, that is declared as a `Sub` rather than as a `Function`), use the generic delegate instead. + + When you use the delegate, you do not have to explicitly define a delegate that encapsulates a method with a single parameter. For example, the following code explicitly declares a delegate named `ConvertMethod` and assigns a reference to the `UppercaseString` method to its delegate instance. + :::code language="csharp" source="~/snippets/csharp/System/FuncT,TResult/Overview/Delegate.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Func~2/fs/Delegate.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Func~2/vb/Delegate.vb" id="Snippet1"::: - - The following example simplifies this code by instantiating the delegate instead of explicitly defining a new delegate and assigning a named method to it. - + + The following example simplifies this code by instantiating the delegate instead of explicitly defining a new delegate and assigning a named method to it. + :::code language="csharp" source="~/snippets/csharp/System/FuncT,TResult/Overview/Func2_1.cs" interactive="try-dotnet-method" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Func~2/fs/Func2_1.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Func~2/vb/Func2_1.vb" id="Snippet2"::: - - You can also use the delegate with anonymous methods in C#, as the following example illustrates. (For an introduction to anonymous methods, see [Anonymous Methods](/dotnet/csharp/programming-guide/statements-expressions-operators/anonymous-methods).) - + + You can also use the delegate with anonymous methods in C#, as the following example illustrates. (For an introduction to anonymous methods, see [Anonymous Methods](/dotnet/csharp/programming-guide/statements-expressions-operators/anonymous-methods).) + :::code language="csharp" source="~/snippets/csharp/System/FuncT,TResult/Overview/Anon.cs" interactive="try-dotnet-method" id="Snippet3"::: - - You can also assign a lambda expression to a delegate, as the following example illustrates. (For an introduction to lambda expressions, see [Lambda Expressions (VB)](/dotnet/visual-basic/programming-guide/language-features/procedures/lambda-expressions), [Lambda Expressions (C#)](/dotnet/csharp/programming-guide/statements-expressions-operators/lambda-expressions) and [Lambda Expressions (F#)](/dotnet/fsharp/language-reference/functions/lambda-expressions-the-fun-keyword).) - + + You can also assign a lambda expression to a delegate, as the following example illustrates. (For an introduction to lambda expressions, see [Lambda Expressions (VB)](/dotnet/visual-basic/programming-guide/language-features/procedures/lambda-expressions), [Lambda Expressions (C#)](/dotnet/csharp/programming-guide/statements-expressions-operators/lambda-expressions) and [Lambda Expressions (F#)](/dotnet/fsharp/language-reference/functions/lambda-expressions-the-fun-keyword).) + :::code language="csharp" source="~/snippets/csharp/System/FuncT,TResult/Overview/Lambda.cs" interactive="try-dotnet-method" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Func~2/fs/Lambda.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Func~2/vb/Lambda.vb" id="Snippet4"::: - - The underlying type of a lambda expression is one of the generic `Func` delegates. This makes it possible to pass a lambda expression as a parameter without explicitly assigning it to a delegate. In particular, because many methods of types in the namespace have parameters, you can pass these methods a lambda expression without explicitly instantiating a delegate. - - - -## Examples - The following example demonstrates how to declare and use a delegate. This example declares a variable and assigns it a lambda expression that converts the characters in a string to uppercase. The delegate that encapsulates this method is subsequently passed to the method to change the strings in an array of strings to uppercase. + + The underlying type of a lambda expression is one of the generic `Func` delegates. This makes it possible to pass a lambda expression as a parameter without explicitly assigning it to a delegate. In particular, because many methods of types in the namespace have parameters, you can pass these methods a lambda expression without explicitly instantiating a delegate. + + + +## Examples + The following example demonstrates how to declare and use a delegate. This example declares a variable and assigns it a lambda expression that converts the characters in a string to uppercase. The delegate that encapsulates this method is subsequently passed to the method to change the strings in an array of strings to uppercase. :::code language="csharp" source="~/snippets/csharp/System/FuncT,TResult/Overview/Example.cs" interactive="try-dotnet-method" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Func~2/fs/Example.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Func~2/vb/Example.vb" id="Snippet5"::: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Func~2/cpp/Example.cpp" id="Snippet6"::: - + ]]> Lambda Expressions (C# Programming Guide) diff --git a/xml/System/GC.xml b/xml/System/GC.xml index 2ee79693b83..4eb5def36da 100644 --- a/xml/System/GC.xml +++ b/xml/System/GC.xml @@ -64,7 +64,6 @@ method to perform a collection on all generations of memory. The code generates a number of unused objects, and then calls the method to clean them from memory. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.GC.Collect Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/GC/Collect/class1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/GC/Collect/class1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.GC.Collect Example/VB/class1.vb" id="Snippet1"::: @@ -480,7 +477,6 @@ Skipping zero-initialization using this API only has a material performance bene ## Examples The following example demonstrates how to use the method to perform a collection on individual layers of memory. The code generates a number of unused objects, and then calls the method to clean them from memory. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.gc.collect int example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/GC/Overview/class1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/GC/Overview/class1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.gc.collect int example/VB/class1.vb" id="Snippet1"::: @@ -1101,7 +1097,6 @@ Starting in .NET 8, this method might return for ob The following example demonstrates how to use the method to determine the age of an object. The example then performs garbage collections to clean up memory and compare the pre and post collection memory totals in the console. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.gc.collect int example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/GC/Overview/class1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/GC/Overview/class1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.gc.collect int example/VB/class1.vb" id="Snippet1"::: @@ -1170,7 +1165,6 @@ Starting in .NET 8, this method might return for ob The following example demonstrates the use of the method to determine the age of a weak reference object. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.GC.GetGenerationWeak Example/CPP/systemgcgetgenerationweak.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/GC/GetGeneration/systemgcgetgenerationweak.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/GC/GetGeneration/systemgcgetgenerationweak.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.GC.GetGenerationWeak Example/VB/systemgcgetgenerationweak.vb" id="Snippet1"::: @@ -1284,7 +1278,6 @@ The following example demonstrates the use of the method to get and display the number of bytes currently allocated in managed memory. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.gc.collect int example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/GC/Overview/class1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/GC/Overview/class1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.gc.collect int example/VB/class1.vb" id="Snippet1"::: @@ -1395,7 +1388,6 @@ The following example demonstrates the use of the method is called. The object persists for the 30-second duration of the `Main` method, despite calls to the and methods. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.GC.KeepAlive Example2/CPP/gckeepalive.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/GC/KeepAlive/gckeepalive.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/GC/KeepAlive/gckeepalive.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.GC.KeepAlive Example2/VB/gckeepalive.vb" id="Snippet1"::: @@ -1470,7 +1462,6 @@ The following example demonstrates the use of the property to display the largest generation number currently in use. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.gc.collect int example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/GC/Overview/class1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/GC/Overview/class1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.gc.collect int example/VB/class1.vb" id="Snippet1"::: @@ -1612,7 +1603,6 @@ The following example demonstrates the use of the method to finalize an object a second time after garbage collection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.GC.ReRegisterForFinalize Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/GC/ReRegisterForFinalize/class1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/GC/ReRegisterForFinalize/class1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.GC.ReRegisterForFinalize Example/VB/class1.vb" id="Snippet1"::: @@ -2295,7 +2284,6 @@ If `obj` does not have a finalizer or the GC has already signaled the finalizer ## Examples The following example shows how to use this method to determine whether a full, blocking garbage collection is approaching. Whenever the status of the notification is , the user method `OnFullGCApproachNotify` is called to perform actions in response to the approaching collection. This code example is part of a larger example provided for [Garbage Collection Notifications](/dotnet/standard/garbage-collection/notifications) topic. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GCNotification/cpp/program.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/GC/CancelFullGCNotification/Program.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/GC/CancelFullGCNotification/Program.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GCNotification/vb/program.vb" id="Snippet3"::: @@ -2478,7 +2466,6 @@ If `obj` does not have a finalizer or the GC has already signaled the finalizer ## Examples The following example shows how to use this method to determine whether a full garbage collection has completed. Whenever the status of the notification is , the user method `OnFullGCCompletedNotify` is called to perform actions in response to the completed collection. This code example is part of a larger example provided for [Garbage Collection Notifications](/dotnet/standard/garbage-collection/notifications) topic. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GCNotification/cpp/program.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/GC/CancelFullGCNotification/Program.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/GC/CancelFullGCNotification/Program.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GCNotification/vb/program.vb" id="Snippet4"::: @@ -2651,7 +2638,6 @@ If `obj` does not have a finalizer or the GC has already signaled the finalizer ## Examples The following example demonstrates how to use the method to suspend the current thread until finalization of all the collected objects is complete. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.GC.WaitForPendingFinalizers Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/GC/WaitForPendingFinalizers/class1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/GC/WaitForPendingFinalizers/class1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.GC.WaitForPendingFinalizers Example/VB/class1.vb" id="Snippet1"::: diff --git a/xml/System/GCNotificationStatus.xml b/xml/System/GCNotificationStatus.xml index 24d2ebc8aea..f18a68f6349 100644 --- a/xml/System/GCNotificationStatus.xml +++ b/xml/System/GCNotificationStatus.xml @@ -49,21 +49,20 @@ Provides information about the current registration for notification of the next full garbage collection. - method to register for a full garbage collection notification. Then use the method or the method to return a enumeration that contains the status of the notification. + + + +## Examples + The following example obtains a enumeration from the method. If the enumeration returns Succeeded, it calls the custom method `OnFullGCApproachNotify` to perform actions in response to the approaching full garbage collection. This code example is part of a larger example provided for [Garbage Collection Notifications](/dotnet/standard/garbage-collection/notifications) topic. -## Remarks - Use the method to register for a full garbage collection notification. Then use the method or the method to return a enumeration that contains the status of the notification. - - - -## Examples - The following example obtains a enumeration from the method. If the enumeration returns Succeeded, it calls the custom method `OnFullGCApproachNotify` to perform actions in response to the approaching full garbage collection. This code example is part of a larger example provided for [Garbage Collection Notifications](/dotnet/standard/garbage-collection/notifications) topic. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/GCNotification/cpp/program.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System/GC/CancelFullGCNotification/Program.cs" id="Snippet8"::: :::code language="fsharp" source="~/snippets/fsharp/System/GC/CancelFullGCNotification/Program.fs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GCNotification/vb/program.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/GCNotification/vb/program.vb" id="Snippet8"::: + ]]> Garbage Collection Notifications diff --git a/xml/System/IAsyncResult.xml b/xml/System/IAsyncResult.xml index 44f763f5c26..8bdd3451f1f 100644 --- a/xml/System/IAsyncResult.xml +++ b/xml/System/IAsyncResult.xml @@ -75,10 +75,9 @@ For more information and more examples of calling methods asynchronously by using delegates, see [Calling Synchronous Methods Asynchronously](/dotnet/standard/asynchronous-programming-patterns/calling-synchronous-methods-asynchronously). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AsyncDelegateExamples/cpp/TestMethod.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/IAsyncResult/Overview/TestMethod.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AsyncDelegateExamples/VB/TestMethod.vb" id="Snippet1"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AsyncDelegateExamples/cpp/waithandle.cpp" id="Snippet3"::: + :::code language="csharp" source="~/snippets/csharp/System/IAsyncResult/Overview/waithandle.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AsyncDelegateExamples/VB/WaitHandle.vb" id="Snippet3"::: @@ -150,10 +149,8 @@ For more information about how this callback example works, and more examples of calling methods asynchronously by using delegates, see [Calling Synchronous Methods Asynchronously](/dotnet/standard/asynchronous-programming-patterns/calling-synchronous-methods-asynchronously). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AsyncDelegateExamples/cpp/TestMethod.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/IAsyncResult/Overview/TestMethod.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AsyncDelegateExamples/VB/TestMethod.vb" id="Snippet1"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AsyncDelegateExamples/cpp/callback.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/IAsyncResult/Overview/callback.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AsyncDelegateExamples/VB/callback.vb" id="Snippet5"::: @@ -227,10 +224,8 @@ For more information and more examples of calling methods asynchronously by using delegates, see [Calling Synchronous Methods Asynchronously](/dotnet/standard/asynchronous-programming-patterns/calling-synchronous-methods-asynchronously). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AsyncDelegateExamples/cpp/TestMethod.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/IAsyncResult/Overview/TestMethod.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AsyncDelegateExamples/VB/TestMethod.vb" id="Snippet1"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AsyncDelegateExamples/cpp/waithandle.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/IAsyncResult/Overview/waithandle.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AsyncDelegateExamples/VB/WaitHandle.vb" id="Snippet3"::: @@ -362,10 +357,8 @@ For more information and more examples of calling methods asynchronously by using delegates, see [Calling Synchronous Methods Asynchronously](/dotnet/standard/asynchronous-programming-patterns/calling-synchronous-methods-asynchronously). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AsyncDelegateExamples/cpp/TestMethod.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/IAsyncResult/Overview/TestMethod.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AsyncDelegateExamples/VB/TestMethod.vb" id="Snippet1"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AsyncDelegateExamples/cpp/polling.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/IAsyncResult/Overview/polling.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AsyncDelegateExamples/VB/polling.vb" id="Snippet4"::: diff --git a/xml/System/IComparable.xml b/xml/System/IComparable.xml index a0aa66f0126..6249a5bbcb8 100644 --- a/xml/System/IComparable.xml +++ b/xml/System/IComparable.xml @@ -74,7 +74,6 @@ ## Examples The following example illustrates the implementation of and the requisite method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IComparable Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/IComparable/Overview/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/IComparable/Overview/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IComparable Example/VB/source.vb" id="Snippet1"::: @@ -165,7 +164,6 @@ ## Examples The following example illustrates the use of to compare a `Temperature` object implementing with another object. The `Temperature` object implements by simply wrapping a call to the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IComparable Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/IComparable/Overview/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/IComparable/Overview/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IComparable Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System/IComparable`1.xml b/xml/System/IComparable`1.xml index f359a3dba4a..dde4cbe1db1 100644 --- a/xml/System/IComparable`1.xml +++ b/xml/System/IComparable`1.xml @@ -59,29 +59,28 @@ The type of object to compare. Defines a generalized comparison method that a value type or class implements to create a type-specific comparison method for ordering or sorting its instances. - , that indicates whether the position of the current instance in the sort order is before, after, or the same as a second object of the same type. Typically, the method is not called directly from developer code. Instead, it is called automatically by methods such as and . - - Typically, types that provide an implementation also implement the interface. The interface defines the method, which determines the equality of instances of the implementing type. - - The implementation of the method must return an that has one of three values, as shown in the following table. - -|Value|Meaning| -|-----------|-------------| -|Less than zero|This object precedes the object specified by the method in the sort order.| -|Zero|This current instance occurs in the same position in the sort order as the object specified by the method argument.| -|Greater than zero|This current instance follows the object specified by the method argument in the sort order.| - - All numeric types (such as and ) implement , as do , , and . Custom types should also provide their own implementation of to enable object instances to be ordered or sorted. - - - -## Examples - The following example illustrates the implementation of for a simple `Temperature` object. The example creates a collection of strings with `Temperature` object keys, and adds several pairs of temperatures and strings to the list out of sequence. In the call to the method, the collection uses the implementation to sort the list entries, which are then displayed in order of increasing temperature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IComparable`1 Example/CPP/source.cpp" id="Snippet1"::: + , that indicates whether the position of the current instance in the sort order is before, after, or the same as a second object of the same type. Typically, the method is not called directly from developer code. Instead, it is called automatically by methods such as and . + + Typically, types that provide an implementation also implement the interface. The interface defines the method, which determines the equality of instances of the implementing type. + + The implementation of the method must return an that has one of three values, as shown in the following table. + +|Value|Meaning| +|-----------|-------------| +|Less than zero|This object precedes the object specified by the method in the sort order.| +|Zero|This current instance occurs in the same position in the sort order as the object specified by the method argument.| +|Greater than zero|This current instance follows the object specified by the method argument in the sort order.| + + All numeric types (such as and ) implement , as do , , and . Custom types should also provide their own implementation of to enable object instances to be ordered or sorted. + + + +## Examples + The following example illustrates the implementation of for a simple `Temperature` object. The example creates a collection of strings with `Temperature` object keys, and adds several pairs of temperatures and strings to the list out of sequence. In the call to the method, the collection uses the implementation to sort the list entries, which are then displayed in order of increasing temperature. + :::code language="csharp" source="~/snippets/csharp/System/IComparableT/Overview/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/IComparableT/Overview/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IComparable`1 Example/VB/source.vb" id="Snippet1"::: @@ -89,8 +88,8 @@ ]]> - Replace the type parameter of the interface with the type that is implementing this interface. - + Replace the type parameter of the interface with the type that is implementing this interface. + If you implement , you should overload the , , , and operators to return values that are consistent with . In addition, you should also implement . See the article for complete information. @@ -149,41 +148,40 @@ An object to compare with this instance. Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object. - A value that indicates the relative order of the objects being compared. The return value has these meanings: - - Value - - Meaning - - Less than zero - - This instance precedes in the sort order. - - Zero - - This instance occurs in the same position in the sort order as . - - Greater than zero - - This instance follows in the sort order. - + A value that indicates the relative order of the objects being compared. The return value has these meanings: + + Value + + Meaning + + Less than zero + + This instance precedes in the sort order. + + Zero + + This instance occurs in the same position in the sort order as . + + Greater than zero + + This instance follows in the sort order. + - provides a strongly typed comparison method for ordering members of a generic collection object. Because of this, it is usually not called directly from developer code. Instead, it is called automatically by methods such as and . - - This method is only a definition and must be implemented by a specific class or value type to have effect. The meaning of the comparisons specified in the Return Values section ("precedes", "occurs in the same position as", and "follows) depends on the particular implementation. - - By definition, any object compares greater than `null`, and two null references compare equal to each other. - - - -## Examples - The following code example illustrates the implementation of for a simple `Temperature` object. The example creates a collection of strings with `Temperature` object keys, and adds several pairs of temperatures and strings to the list out of sequence. In the call to the method, the collection uses the implementation to sort the list entries, which are then displayed in order of increasing temperature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IComparable`1 Example/CPP/source.cpp" id="Snippet1"::: + provides a strongly typed comparison method for ordering members of a generic collection object. Because of this, it is usually not called directly from developer code. Instead, it is called automatically by methods such as and . + + This method is only a definition and must be implemented by a specific class or value type to have effect. The meaning of the comparisons specified in the Return Values section ("precedes", "occurs in the same position as", and "follows) depends on the particular implementation. + + By definition, any object compares greater than `null`, and two null references compare equal to each other. + + + +## Examples + The following code example illustrates the implementation of for a simple `Temperature` object. The example creates a collection of strings with `Temperature` object keys, and adds several pairs of temperatures and strings to the list out of sequence. In the call to the method, the collection uses the implementation to sort the list entries, which are then displayed in order of increasing temperature. + :::code language="csharp" source="~/snippets/csharp/System/IComparableT/Overview/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/IComparableT/Overview/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IComparable`1 Example/VB/source.vb" id="Snippet1"::: @@ -191,16 +189,16 @@ ]]> - For objects A, B, and C, the following must be true: - - A.CompareTo(A) is required to return zero. - - If A.CompareTo(B) returns zero, then B.CompareTo(A) is required to return zero. - - If A.CompareTo(B) returns zero and B.CompareTo(C) returns zero, then A.CompareTo(C) is required to return zero. - - If A.CompareTo(B) returns a value other than zero, then B.CompareTo(A) is required to return a value of the opposite sign. - + For objects A, B, and C, the following must be true: + + A.CompareTo(A) is required to return zero. + + If A.CompareTo(B) returns zero, then B.CompareTo(A) is required to return zero. + + If A.CompareTo(B) returns zero and B.CompareTo(C) returns zero, then A.CompareTo(C) is required to return zero. + + If A.CompareTo(B) returns a value other than zero, then B.CompareTo(A) is required to return a value of the opposite sign. + If A.CompareTo(B) returns a value that is not equal to zero, and B.CompareTo(C) returns a value of the same sign as , then A.CompareTo(C) is required to return a value of the same sign as and . diff --git a/xml/System/IConvertible.xml b/xml/System/IConvertible.xml index 2da2ab95fdf..456800d4bd8 100644 --- a/xml/System/IConvertible.xml +++ b/xml/System/IConvertible.xml @@ -56,23 +56,22 @@ Defines methods that convert the value of the implementing reference or value type to a common language runtime type that has an equivalent value. - , , , , , , , , , , , , , , and . - - If there is no meaningful conversion to a common language runtime type, then a particular interface method implementation throws . For example, if this interface is implemented on a Boolean type, the implementation of the method throws an exception because there is no meaningful equivalent to a Boolean type. - - The common language runtime typically exposes the interface through the class. The common language runtime also uses the interface internally, in explicit interface implementations, to simplify the code used to support conversions in the class and basic common language runtime types. - - In addition to the interface, the .NET Framework provides classes called type converters for converting user-defined data types to other data types. For more information, see the [Generalized Type Conversion](/previous-versions/visualstudio/visual-studio-2013/yy580hbd(v=vs.120)) topic. - - - -## Examples - The following code sample demonstrates an implementation of for a Complex number class, allowing it to be cast first as a and then calling the static members on that . + , , , , , , , , , , , , , , and . + + If there is no meaningful conversion to a common language runtime type, then a particular interface method implementation throws . For example, if this interface is implemented on a Boolean type, the implementation of the method throws an exception because there is no meaningful equivalent to a Boolean type. + + The common language runtime typically exposes the interface through the class. The common language runtime also uses the interface internally, in explicit interface implementations, to simplify the code used to support conversions in the class and basic common language runtime types. + + In addition to the interface, the .NET Framework provides classes called type converters for converting user-defined data types to other data types. For more information, see the [Generalized Type Conversion](/previous-versions/visualstudio/visual-studio-2013/yy580hbd(v=vs.120)) topic. + + + +## Examples + The following code sample demonstrates an implementation of for a Complex number class, allowing it to be cast first as a and then calling the static members on that . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IConvertible/CPP/iconvertible.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/IConvertible/Overview/iconvertible.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/IConvertible/Overview/iconvertible.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IConvertible/VB/iconvertible.vb" id="Snippet1"::: @@ -80,8 +79,8 @@ ]]> - If you implement the interface, your implementation will be called automatically by the method if the parameter is an instance of your implementing type and the parameter is a common language runtime type. - + If you implement the interface, your implementation will be called automatically by the method if the parameter is an instance of your implementing type and the parameter is a common language runtime type. + Most conversion methods have a parameter of type that represents either the current culture () or a specific culture. For the most part, the implementations of the base types ignore this parameter. However, you can choose whether to use it in your code. Type Conversion in the .NET Framework diff --git a/xml/System/IDisposable.xml b/xml/System/IDisposable.xml index bfa05e20f35..55081c9b0fa 100644 --- a/xml/System/IDisposable.xml +++ b/xml/System/IDisposable.xml @@ -58,7 +58,6 @@ interface. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IDisposable.Dispose Example/CPP/idisposabledispose.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/IDisposable/Overview/idisposabledispose.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/IDisposable/Overview/idisposabledispose.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IDisposable.Dispose Example/VB/idisposabledispose.vb" id="Snippet1":::id="Snippet1"::: @@ -122,7 +121,7 @@ When implementing this method, ensure that all held resources are freed by propagating the call through the containment hierarchy. For example, if an object A allocates an object B, and object B allocates an object C, then A's implementation must call on B, which must in turn call on C. > [!IMPORTANT] -> The C++ compiler supports deterministic disposal of resources and does not allow direct implementation of the method. +> The C++ compiler supports deterministic disposal of resources and doesn't allow direct implementation of the method. An object must also call the method of its base class if the base class implements . For more information about implementing on a base class and its subclasses, see the "IDisposable and the inheritance hierarchy" section in the topic. @@ -143,7 +142,6 @@ ## Examples The following example shows how you can implement the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IDisposable.Dispose Example/CPP/idisposabledispose.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/IDisposable/Overview/idisposabledispose.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/IDisposable/Overview/idisposabledispose.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IDisposable.Dispose Example/VB/idisposabledispose.vb" id="Snippet1"::: diff --git a/xml/System/Int16.xml b/xml/System/Int16.xml index 9048209a11d..5f39bdd7eb0 100644 --- a/xml/System/Int16.xml +++ b/xml/System/Int16.xml @@ -453,7 +453,6 @@ ## Examples The following code example demonstrates generic and nongeneric versions of the method for several value and reference types. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/T.CompareTo/CPP/cat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Boolean/CompareTo/cat.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/T.CompareTo/VB/cat.vb" id="Snippet1"::: @@ -926,7 +925,6 @@ ## Examples The following code example illustrates the use of `Equals` in the context of `Int16`, comparing two short values and returning `true` if they represent the same number, or `false` if they do not. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Int16_Equals/CPP/int16_equals.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Int16/Equals/int16_equals.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Int16_Equals/FS/int16_equals.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Int16_Equals/VB/int16_equals.vb" id="Snippet1"::: @@ -1494,7 +1492,6 @@ For this method matches the IEE ## Examples The following example uses the property to prevent an when converting to an value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Int16.MaxValue/cpp/minvalue.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Int16/MaxValue/MaxValue.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.MaxValue/fs/MaxValue.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Int16.MaxValue/vb/MaxValue.vb" id="Snippet1"::: @@ -1657,7 +1654,6 @@ For this method matches the IEE ## Examples The following example uses the property to prevent an when converting to an value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Int16.MaxValue/cpp/minvalue.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Int16/MaxValue/MaxValue.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.MaxValue/fs/MaxValue.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Int16.MaxValue/vb/MaxValue.vb" id="Snippet1"::: @@ -1752,7 +1748,6 @@ For this method matches the IEE ## Examples The following example demonstrates how to convert a string value into a 16-bit signed integer value using the method. The resulting integer value is then displayed to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Int16.Parse/cpp/parse1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Int16/Parse/Parse.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.Parse/fs/Parse.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Int16.Parse/vb/Parse.vb" id="Snippet1"::: @@ -1963,7 +1958,6 @@ For this method matches the IEE ## Examples The following example uses the method to parse the string representations of values using the en-US culture. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Int16.Parse/cpp/parse2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Int16/Parse/Parse2.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.Parse/fs/Parse2.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Int16.Parse/vb/Parse2.vb" id="Snippet2"::: @@ -2077,7 +2071,6 @@ For this method matches the IEE ## Examples The following example parses string representations of values with the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Int16.Parse/cpp/parse4.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Int16/Parse/Parse.cs" interactive="try-dotnet-method" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.Parse/fs/Parse.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Int16.Parse/vb/Parse.vb" id="Snippet4"::: @@ -2310,7 +2303,6 @@ For this method matches the IEE ## Examples The following example uses a variety of `style` and `provider` parameters to parse the string representations of values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Int16.Parse/cpp/parse3.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Int16/Parse/Parse.cs" interactive="try-dotnet-method" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Int16.Parse/fs/Parse.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Int16.Parse/vb/Parse.vb" id="Snippet3"::: diff --git a/xml/System/Int32.xml b/xml/System/Int32.xml index f45bc195dfa..45ab67c50fb 100644 --- a/xml/System/Int32.xml +++ b/xml/System/Int32.xml @@ -966,7 +966,6 @@ ## Examples The following example illustrates the use of `Equals` in the context of `Int32`, comparing two `int` values and returning `true` if they represent the same number, or `false` if they do not. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Int32_Equals/CPP/int32_equals.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Int32/Equals/int32_equals.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Int32_Equals/FS/int32_equals.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Int32_Equals/VB/int32_equals.vb" id="Snippet1"::: @@ -1547,7 +1546,6 @@ For this method matches the IEE ## Examples The following example uses the property to prevent an when converting to an value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.int32.maxvalue/cpp/maxvalue1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Int32/MaxValue/maxvalue1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.int32.maxvalue/fs/maxvalue1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.int32.maxvalue/vb/maxvalue1.vb" id="Snippet1"::: @@ -1708,7 +1706,6 @@ For this method matches the IEE ## Examples The following example uses the property to prevent an when converting to an value. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.int32.maxvalue/cpp/maxvalue1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Int32/MaxValue/maxvalue1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.int32.maxvalue/fs/maxvalue1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.int32.maxvalue/vb/maxvalue1.vb" id="Snippet1"::: @@ -1803,7 +1800,6 @@ For this method matches the IEE ## Examples The following example demonstrates how to convert a string value into a 32-bit signed integer value using the method. The resulting integer value is then displayed to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Int32.Parse/cpp/parse1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Int32/Parse/Parse1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Int32.Parse/fs/Parse1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Int32.Parse/vb/Parse1.vb" id="Snippet1"::: @@ -2017,7 +2013,6 @@ For this method matches the IEE ## Examples The following example uses the method to parse the string representations of several values. The current culture for the example is en-US. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Int32.Parse/cpp/parse2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Int32/Parse/Parse2.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Int32.Parse/fs/Parse2.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Int32.Parse/vb/Parse2.vb" id="Snippet2"::: @@ -2374,7 +2369,6 @@ For this method matches the IEE ## Examples The following example uses a variety of `style` and `provider` parameters to parse the string representations of values. It also illustrates some of the different ways the same string can be interpreted depending on the culture whose formatting information is used for the parsing operation. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Int32.Parse/cpp/parse3.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Int32/Parse/Parse3.cs" interactive="try-dotnet" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Int32.Parse/fs/Parse3.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Int32.Parse/vb/Parse3.vb" id="Snippet3"::: @@ -6227,7 +6221,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example displays an value using the default method. It also displays the string representations of the value that results from using a number of standard format specifiers. The examples are displayed using the formatting conventions of the en-US culture. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Int32.ToString/cpp/ToString1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Int32/ToString/ToString.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Int32.ToString/fs/ToString.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Int32.ToString/vb/ToString.vb" id="Snippet1"::: @@ -6341,7 +6334,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example displays the string representation of an value using objects that represent several different cultures. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Int32.ToString/cpp/ToString2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Int32/ToString/ToString.cs" interactive="try-dotnet-method" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Int32.ToString/fs/ToString.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Int32.ToString/vb/ToString.vb" id="Snippet2"::: @@ -6448,7 +6440,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example displays an value using each of the supported standard numeric format specifiers, together with two custom numeric format strings. In converting the numeric values to strings, the example uses the formatting conventions of the en-US culture. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Int32.ToString/cpp/ToString3.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Int32/ToString/ToString.cs" interactive="try-dotnet-method" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Int32.ToString/fs/ToString.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Int32.ToString/vb/ToString.vb" id="Snippet3"::: @@ -6565,7 +6556,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example displays a positive and a negative value using each of the supported standard numeric format specifiers for three different cultures. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Int32.ToString/cpp/ToString4.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Int32/ToString/ToString.cs" interactive="try-dotnet-method" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Int32.ToString/fs/ToString.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Int32.ToString/vb/ToString.vb" id="Snippet4"::: @@ -6923,7 +6913,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example calls the method with a number of different string values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Int32.TryParse/cpp/int32.tryparse1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Int32/TryParse/TryParse1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Int32.TryParse/fs/TryParse1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Int32.TryParse/vb/TryParse1.vb" id="Snippet1"::: @@ -7316,7 +7305,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example calls the method with a number of different string and values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Int32.TryParse/cpp/int32.tryparse2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Int32/TryParse/TryParse2.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Int32.TryParse/fs/TryParse2.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Int32.TryParse/vb/TryParse2.vb" id="Snippet2"::: diff --git a/xml/System/Int64.xml b/xml/System/Int64.xml index 72a56423a2a..b4116894319 100644 --- a/xml/System/Int64.xml +++ b/xml/System/Int64.xml @@ -474,7 +474,6 @@ ## Examples The following code example demonstrates generic and nongeneric versions of the method for several value and reference types. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/T.CompareTo/CPP/cat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Boolean/CompareTo/cat.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/T.CompareTo/VB/cat.vb" id="Snippet1"::: @@ -946,7 +945,6 @@ ## Examples The following code example illustrates the use of `Equals` in the context of `Int64`, comparing two long values and returning `true` if they represent the same number, or `false` if they do not. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Int64_Equals/CPP/int64_equals.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Int64/Equals/int64_equals.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR/Int64_Equals/FS/int64_equals.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Int64_Equals/VB/int64_equals.vb" id="Snippet1"::: diff --git a/xml/System/IntPtr.xml b/xml/System/IntPtr.xml index ca7987b3b28..81bd4b8b7bf 100644 --- a/xml/System/IntPtr.xml +++ b/xml/System/IntPtr.xml @@ -285,23 +285,23 @@ The following example uses managed pointers to reverse the characters in an array. After it initializes a object and gets its length, it does the following: -1. Calls the method to copy the Unicode string to unmanaged memory as an ANSI (one-byte) character. The method returns an object that points to the beginning of the unmanaged string. The Visual Basic example uses this pointer directly; in the C++, F# and C# examples, it is cast to a pointer to a byte. +1. Calls the method to copy the Unicode string to unmanaged memory as an ANSI (one-byte) character. The method returns an object that points to the beginning of the unmanaged string. The Visual Basic example uses this pointer directly; in the C++, F# and C# examples, it is cast to a pointer to a byte. -2. Calls the method to allocate the same number of bytes as the unmanaged string occupies. The method returns an object that points to the beginning of the unmanaged block of memory. The Visual Basic example uses this pointer directly; in the C++, F# and C# examples, it is cast to a pointer to a byte. +2. Calls the method to allocate the same number of bytes as the unmanaged string occupies. The method returns an object that points to the beginning of the unmanaged block of memory. The Visual Basic example uses this pointer directly; in the C++, F# and C# examples, it is cast to a pointer to a byte. -3. The Visual Basic example defines a variable named `offset` that is equal to the length of the ANSI string. It is used to determine the offset into unmanaged memory to which the next character in the ANSI string is copied. Because its starting value is the length of the string, the copy operation will copy a character from the start of the string to the end of the memory block. +3. The Visual Basic example defines a variable named `offset` that is equal to the length of the ANSI string. It is used to determine the offset into unmanaged memory to which the next character in the ANSI string is copied. Because its starting value is the length of the string, the copy operation will copy a character from the start of the string to the end of the memory block. The C#, F# and C++ examples call the method to get an unmanaged pointer to the starting address of the string and the unmanaged block of memory, and they add one less than the length of the string to the starting address of the ANSI string. Because the unmanaged string pointer now points to the end of the string, the copy operation will copy a character from the end of the string to the start of the memory block. -4. Uses a loop to copy each character from the string to the unmanaged block of memory. +4. Uses a loop to copy each character from the string to the unmanaged block of memory. The Visual Basic example calls the method to read the byte (or one-byte character) at a specified offset from the managed pointer to the ANSI string. The offset is incremented with each iteration of the loop. It then calls the method to write the byte to the memory address defined by the starting address of the unmanaged block of memory plus `offset`. It then decrements `offset`. The C#, F# and C++ examples perform the copy operation, then decrement the pointer to the address of the next location in the unmanaged ANSI string and increment the pointer to the next address in the unmanaged block. -5. All examples call the to convert the unmanaged memory block containing the copied ANSI string to a managed Unicode object. +5. All examples call the to convert the unmanaged memory block containing the copied ANSI string to a managed Unicode object. -6. After displaying the original and reversed strings, all examples call the method to free the memory allocated for the unmanaged ANSI string and the unmanaged block of memory. +6. After displaying the original and reversed strings, all examples call the method to free the memory allocated for the unmanaged ANSI string and the unmanaged block of memory. :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.intptr/cpp/topointer.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/IntPtr/ToPointer/topointer.cs" id="Snippet1"::: diff --git a/xml/System/MTAThreadAttribute.xml b/xml/System/MTAThreadAttribute.xml index 6f427a53914..1bd7ac360bd 100644 --- a/xml/System/MTAThreadAttribute.xml +++ b/xml/System/MTAThreadAttribute.xml @@ -60,32 +60,31 @@ Indicates that the COM threading model for an application is multithreaded apartment (MTA). - or method before starting the thread. - + or method before starting the thread. + > [!NOTE] -> For an overview of COM threading models, see [Understanding and Using COM Threading Models](https://learn.microsoft.com/previous-versions/ms809971(v=msdn.10)). - - COM threading models only apply to applications that use COM interop. The COM threading model can be set to single-threaded apartment or multithreaded apartment. The application thread is only initialized for COM interop if the thread actually makes a call to a COM component. If COM interop is not used, then the thread is not initialized, and the attribute, if it is present, has no effect. - - Starting with the .NET Framework version 2.0, the default threading model for COM interop depends on the language in which you are developing your application, as the following table shows. - -|Language|COM apartment model| -|--------------|-------------------------| -|C#|Multithreaded apartment| -|C++|Multithreaded apartment| -|Visual Basic|Single-threaded apartment| - - To change these defaults, you use the attribute to set the threading model for the application, or call the or method before starting the thread to set the threading model for a particular thread. In C++, you can also use the [/CLRTHREADATTRIBUTE (Set CLR Thread Attribute)](/cpp/build/reference/clrthreadattribute-set-clr-thread-attribute) linker option to specify the apartment model. - - Some of the cases in which you want to use the attribute to explicitly set the threading model to multithreaded apartment include the following: - -- You're developing a Visual Basic app that calls to a C# library that in turn relies on COM interop. Because the multithreaded apartment model is the default for C#, you should change your app's threading model to multithreaded by using the attribute. - -- Your application makes calls to COM components that use the multithreaded apartment model. - +> For an overview of COM threading models, see [Understanding and Using COM Threading Models](https://learn.microsoft.com/previous-versions/ms809971(v=msdn.10)). + + COM threading models only apply to applications that use COM interop. The COM threading model can be set to single-threaded apartment or multithreaded apartment. The application thread is only initialized for COM interop if the thread actually makes a call to a COM component. If COM interop is not used, then the thread is not initialized, and the attribute, if it is present, has no effect. + + Starting with the .NET Framework version 2.0, the default threading model for COM interop depends on the language in which you are developing your application, as the following table shows. + +|Language|COM apartment model| +|--------------|-------------------------| +|C#|Multithreaded apartment| +|C++|Multithreaded apartment| +|Visual Basic|Single-threaded apartment| + + To change these defaults, you use the attribute to set the threading model for the application, or call the or method before starting the thread to set the threading model for a particular thread. In C++, you can also use the [/CLRTHREADATTRIBUTE (Set CLR Thread Attribute)](/cpp/build/reference/clrthreadattribute-set-clr-thread-attribute) linker option to specify the apartment model. + +Use the attribute to explicitly set the threading model to multithreaded apartment in the following cases: + +- You're developing a Visual Basic app that calls to a C# library that in turn relies on COM interop. Because the multithreaded apartment model is the default for C#, you should change your app's threading model to multithreaded by using the attribute. +- Your application makes calls to COM components that use the multithreaded apartment model. + ]]> diff --git a/xml/System/Math.xml b/xml/System/Math.xml index bb9a4cead23..f8c1d4c0409 100644 --- a/xml/System/Math.xml +++ b/xml/System/Math.xml @@ -67,7 +67,6 @@ ## Examples The following example uses several mathematical and trigonometric functions from the class to calculate the inner angles of a trapezoid. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MathSample/CPP/mathsample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Math/Overview/mathsample.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Math/Overview/mathsample.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MathSample/VB/mathsample.vb" id="Snippet1"::: @@ -729,7 +728,6 @@ ## Examples The following example uses the method to assist in the computation of the inner angles of a given trapezoid. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MathSample/CPP/mathsample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Math/Overview/mathsample.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Math/Overview/mathsample.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MathSample/VB/mathsample.vb" id="Snippet1"::: @@ -866,7 +864,6 @@ ## Examples The following example uses to assist in the computation of the inner angles of a given trapezoid. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MathSample/CPP/mathsample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Math/Overview/mathsample.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Math/Overview/mathsample.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MathSample/VB/mathsample.vb" id="Snippet1"::: @@ -1003,7 +1000,6 @@ ## Examples The following example demonstrates how to calculate the arctangent of a value and display it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/math.atanx/CPP/atan.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Math/Atan/atan.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Math/Atan/atan.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/math.atanx/VB/atan.vb" id="Snippet1"::: @@ -1103,7 +1099,6 @@ ## Examples The following example demonstrates how to calculate the arctangent of an angle and a vector. The resulting value is displayed in the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/math.atanx/CPP/atan.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Math/Atan/atan.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Math/Atan/atan.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/math.atanx/VB/atan.vb" id="Snippet1"::: @@ -1226,7 +1221,6 @@ ## Examples The following example demonstrates the use of the method to calculate the product of two integer values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/math.bigmul/CPP/bigmul.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Math/BigMul/bigmul.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Math/BigMul/bigmul.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/math.bigmul/VB/bigmul.vb" id="Snippet1"::: @@ -2706,7 +2700,6 @@ Dim i2 As Integer = CInt(Math.Ceiling(d2)) ' Result: 7969 ## Examples The following example uses to evaluate certain trigonometric identities for selected angles. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Math.SinCos/CPP/sincos.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Math/Cos/sincos.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Math/Cos/sincos.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Math.SinCos/VB/sincos.vb" id="Snippet1"::: @@ -2782,7 +2775,6 @@ Dim i2 As Integer = CInt(Math.Ceiling(d2)) ' Result: 7969 ## Examples The following example uses to evaluate certain hyperbolic identities for selected values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Math.SinhCosh/CPP/sinhcosh.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Math/Cosh/sinhcosh.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Math/Cosh/sinhcosh.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Math.SinhCosh/VB/sinhcosh.vb" id="Snippet1"::: @@ -3526,7 +3518,6 @@ Dim i2 As Integer = CInt(Math.Ceiling(d2)) ' Result: 7969 ## Examples The following example compares with the value calculated from a power series. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Math.E/CPP/efield.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Math/E/efield.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Math/E/efield.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Math.E/VB/efield.vb" id="Snippet1"::: @@ -3606,7 +3597,6 @@ Dim i2 As Integer = CInt(Math.Ceiling(d2)) ' Result: 7969 ## Examples The following example uses to evaluate certain exponential and logarithmic identities for selected values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Math.Exp/CPP/exp.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Math/Exp/exp.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Math/Exp/exp.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Math.Exp/VB/exp.vb" id="Snippet1"::: @@ -4246,7 +4236,6 @@ Remainder = (Math.Abs(dividend) - (Math.Abs(divisor) * ## Examples The following example uses to evaluate certain logarithmic identities for selected values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Math.Log_Overloads/CPP/loggen.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Math/LogMethod/loggen.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Math/LogMethod/loggen.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Math.Log_Overloads/VB/loggen.vb" id="Snippet1"::: @@ -4425,7 +4414,6 @@ Remainder = (Math.Abs(dividend) - (Math.Abs(divisor) * The following example demonstrates how to use the method to return and display the greater of two variables: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/math.max/CPP/max.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Math/Max/max.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Math/Max/max.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/math.max/VB/max.vb" id="Snippet1"::: @@ -5319,7 +5307,6 @@ The following example demonstrates how to use the meth The following example demonstrates how to use the method to return and display the smaller of two variables: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/math.min/CPP/min.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Math/Min/min.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Math/Min/min.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/math.min/VB/min.vb" id="Snippet1"::: @@ -6251,7 +6238,6 @@ The following example demonstrates how to use the meth ## Examples The following example uses to assist in the computation of the inner angles of a given trapezoid. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MathSample/CPP/mathsample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Math/Overview/mathsample.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Math/Overview/mathsample.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MathSample/VB/mathsample.vb" id="Snippet1"::: @@ -6760,7 +6746,6 @@ Dim i2 As Integer = CInt(Math.Ceiling(d2)) ' Result: 7968 The following example demonstrates rounding to the nearest integer value. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Math.Round Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Math/Round/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Math/Round/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Math.Round Example/VB/source.vb" id="Snippet1"::: @@ -7012,7 +6997,6 @@ If the value of the `value` argument is method to determine the sign of a value and display it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/math.sign/CPP/sign.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Math/Sign/sign.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Math/Sign/sign.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/math.sign/VB/sign.vb" id="Snippet1"::: @@ -7531,7 +7514,6 @@ The following example demonstrates how to use the method to determine the sign of a value and display it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/math.sign/CPP/sign.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Math/Sign/sign.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Math/Sign/sign.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/math.sign/VB/sign.vb" id="Snippet1"::: @@ -7620,7 +7602,6 @@ The following example demonstrates how to use the method to determine the sign of an value and display it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/math.sign/CPP/sign.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Math/Sign/sign.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Math/Sign/sign.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/math.sign/VB/sign.vb" id="Snippet1"::: @@ -7707,7 +7688,6 @@ The following example demonstrates how to use the method to determine the sign of an value and display it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/math.sign/CPP/sign.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Math/Sign/sign.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Math/Sign/sign.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/math.sign/VB/sign.vb" id="Snippet1"::: @@ -7794,7 +7774,6 @@ The following example demonstrates how to use the method to determine the sign of an value and display it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/math.sign/CPP/sign.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Math/Sign/sign.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Math/Sign/sign.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/math.sign/VB/sign.vb" id="Snippet1"::: @@ -7959,7 +7938,6 @@ The following example demonstrates how to use the method to determine the sign of an value and display it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/math.sign/CPP/sign.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Math/Sign/sign.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Math/Sign/sign.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/math.sign/VB/sign.vb" id="Snippet1"::: @@ -8046,7 +8024,6 @@ The following example demonstrates how to use the method to determine the sign of a value and display it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/math.sign/CPP/sign.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Math/Sign/sign.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Math/Sign/sign.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/math.sign/VB/sign.vb" id="Snippet1"::: @@ -8124,7 +8101,6 @@ The following example demonstrates how to use the to evaluate certain trigonometric identities for selected angles. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Math.SinCos/CPP/sincos.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Math/Cos/sincos.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Math/Cos/sincos.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Math.SinCos/VB/sincos.vb" id="Snippet1"::: @@ -8261,7 +8237,6 @@ The following example demonstrates how to use the to evaluate certain hyperbolic identities for selected values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Math.SinhCosh/CPP/sinhcosh.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Math/Cosh/sinhcosh.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Math/Cosh/sinhcosh.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Math.SinhCosh/VB/sinhcosh.vb" id="Snippet1"::: @@ -8423,7 +8398,6 @@ The following example demonstrates how to use the to evaluate certain hyperbolic tangent identities for selected values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Math.Tanh/CPP/tanh.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Math/Tanh/tanh.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Math/Tanh/tanh.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Math.Tanh/VB/tanh.vb" id="Snippet1"::: diff --git a/xml/System/MissingFieldException.xml b/xml/System/MissingFieldException.xml index a740717dc63..dd667e70991 100644 --- a/xml/System/MissingFieldException.xml +++ b/xml/System/MissingFieldException.xml @@ -83,7 +83,6 @@ ## Examples This example shows what happens if you attempt to use reflection to call a method that does not exist and access a field that does not exist. The application recovers by catching the , , and . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MissingMethodException/cpp/MissingMethodException.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/MissingFieldException/Overview/MissingMethodException.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/MissingFieldException/Overview/MissingMethodException.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MissingMethodException/vb/missingmethodexception.vb" id="Snippet1"::: @@ -443,7 +442,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/MissingMethodException/cpp/MissingMethodException.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/MissingFieldException/Overview/MissingMethodException.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/MissingFieldException/Overview/MissingMethodException.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MissingMethodException/vb/missingmethodexception.vb" id="Snippet3"::: diff --git a/xml/System/MissingMemberException.xml b/xml/System/MissingMemberException.xml index 019557a71c2..b0e5b1b47a7 100644 --- a/xml/System/MissingMemberException.xml +++ b/xml/System/MissingMemberException.xml @@ -87,7 +87,6 @@ ## Examples This example shows what happens if you attempt to use reflection to call a method that does not exist and access a field that does not exist. The application recovers by catching the , , and . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MissingMethodException/cpp/MissingMethodException.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/MissingFieldException/Overview/MissingMethodException.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/MissingFieldException/Overview/MissingMethodException.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MissingMethodException/vb/missingmethodexception.vb" id="Snippet1"::: @@ -625,7 +624,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/MissingMethodException/cpp/MissingMethodException.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/MissingFieldException/Overview/MissingMethodException.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/MissingFieldException/Overview/MissingMethodException.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MissingMethodException/vb/missingmethodexception.vb" id="Snippet4"::: diff --git a/xml/System/MissingMethodException.xml b/xml/System/MissingMethodException.xml index a890bb97a84..9d5982ff7ee 100644 --- a/xml/System/MissingMethodException.xml +++ b/xml/System/MissingMethodException.xml @@ -88,7 +88,6 @@ The exact timing of when statically referenced methods are loaded is unspecified ## Examples This example shows what happens if you attempt to use reflection to call a method that does not exist and access a field that does not exist. The application recovers by catching the , , and . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MissingMethodException/cpp/MissingMethodException.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/MissingFieldException/Overview/MissingMethodException.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/MissingFieldException/Overview/MissingMethodException.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MissingMethodException/vb/missingmethodexception.vb" id="Snippet1"::: @@ -452,7 +451,6 @@ The exact timing of when statically referenced methods are loaded is unspecified ## 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/MissingMethodException/cpp/MissingMethodException.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/MissingFieldException/Overview/MissingMethodException.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/MissingFieldException/Overview/MissingMethodException.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MissingMethodException/vb/missingmethodexception.vb" id="Snippet2"::: diff --git a/xml/System/MulticastDelegate.xml b/xml/System/MulticastDelegate.xml index 8c90ef3831b..3e31888cdc5 100644 --- a/xml/System/MulticastDelegate.xml +++ b/xml/System/MulticastDelegate.xml @@ -89,7 +89,6 @@ The `Test.Main` method is the application entry point. It instantiates a `StringContainer` object, populates it with strings, and creates two `CheckAndDisplayDelegate` delegates, `conStart` and `vowelStart`, that invoke a single method. It then calls the method to create the `multipleDelegates` delegate, which initially contains the `ConStart` and `VowelStart` delegates. Note that when the `multipleDelegates` delegate is invoked, it displays all the strings in the collection in their original order. This is because each letter is passed separately to each delegate, and each letter meets the filtering criteria of only one of the two delegates. Finally, after calls to and , `multipleDelegates` contains two `conStart` delegates. When it is invoked, each string in the `StringContainer` object is displayed twice. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Multicast Delegate Introduction/CPP/delegatestring.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/MulticastDelegate/Overview/delegatestring.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/MulticastDelegate/Overview/delegatestring.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Multicast Delegate Introduction/VB/delegatestring.vb" id="Snippet1"::: diff --git a/xml/System/NonSerializedAttribute.xml b/xml/System/NonSerializedAttribute.xml index a71f9bcbc83..d7047ce1383 100644 --- a/xml/System/NonSerializedAttribute.xml +++ b/xml/System/NonSerializedAttribute.xml @@ -77,38 +77,37 @@ Indicates that a field of a serializable class should not be serialized. This class cannot be inherited. - or classes to serialize an object, use the attribute to prevent a field from being serialized. For example, you can use this attribute to prevent the serialization of sensitive data. - - The target objects for the attribute are public and private fields of a serializable class. By default, classes are not serializable unless they are marked with . During the serialization process all the public and private fields of a class are serialized by default. Fields marked with are excluded during serialization. If you are using the class to serialize an object, use the class to get the same functionality. Alternatively, implement the interface to explicitly control the serialization process. Note that classes that implement must still be marked with . - - To apply the class to an event, set the attribute location to field, as shown in the following C# code. - -```csharp -[field:NonSerializedAttribute()] -public event ChangedEventHandler Changed; -``` - - If a field is not serialized, but it still requires a default value that must be supplied after deserialization, you can create a method that supplies the field with a value, then apply the to the method. - + or classes to serialize an object, use the attribute to prevent a field from being serialized. For example, you can use this attribute to prevent the serialization of sensitive data. + + The target objects for the attribute are public and private fields of a serializable class. By default, classes are not serializable unless they are marked with . During the serialization process all the public and private fields of a class are serialized by default. Fields marked with are excluded during serialization. If you are using the class to serialize an object, use the class to get the same functionality. Alternatively, implement the interface to explicitly control the serialization process. Note that classes that implement must still be marked with . + + To apply the class to an event, set the attribute location to field, as shown in the following C# code. + +```csharp +[field:NonSerializedAttribute()] +public event ChangedEventHandler Changed; +``` + + If a field is not serialized, but it still requires a default value that must be supplied after deserialization, you can create a method that supplies the field with a value, then apply the to the method. + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). > [!NOTE] > This attribute does not apply to JSON serialization using . - -## Examples - The following example demonstrates SOAP serialization of an object marked with the attribute, and the behavior of a field marked with the in the serialized object. - + +## Examples + The following example demonstrates SOAP serialization of an object marked with the attribute, and the behavior of a field marked with the in the serialized object. + > [!NOTE] -> The code uses the class to serialize the object. The class is found in the system.runtime.serialization.formatters.soap.dll file, which is not loaded by default into a project. To run the code, you must add a reference to the DLL to your project. +> The code uses the class to serialize the object. The class is found in the system.runtime.serialization.formatters.soap.dll file, which is not loaded by default into a project. To run the code, you must add a reference to the DLL to your project. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SerializationAttributes/CPP/s.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/NonSerializedAttribute/Overview/s.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/NonSerializedAttribute/Overview/s.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SerializationAttributes/VB/s.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SerializationAttributes/VB/s.vb" id="Snippet1"::: + ]]> diff --git a/xml/System/Nullable`1.xml b/xml/System/Nullable`1.xml index cb52029dd56..1f0ec33bc6d 100644 --- a/xml/System/Nullable`1.xml +++ b/xml/System/Nullable`1.xml @@ -70,7 +70,6 @@ :::code language="csharp" source="~/snippets/csharp/System/Object/Overview/ObjectX.cs" interactive="try-dotnet" id="snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Object/Overview/ObjectX.fs" id="snippet1"::: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ObjectX/cpp/ObjectX.cpp" id="snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ObjectX/vb/objectX.vb" id="snippet1"::: ]]> @@ -538,7 +537,6 @@ For an additional example that overrides the me The following code example demonstrates that returns the runtime type of the current instance. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ECMA-System.Object.GetType/CPP/gettype.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Object/GetType/gettype.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Object/GetType/gettype.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ECMA-System.Object.GetType/VB/gettype.vb" id="Snippet1"::: @@ -715,7 +713,6 @@ To illustrate the difference between a shallow and a deep copy operation, consid The following example uses to determine if two objects are the same instance. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ECMA-System.Object.ReferenceEquals/CPP/referenceequals.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Object/ReferenceEquals/referenceequals.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Object/ReferenceEquals/referenceequals.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ECMA-System.Object.ReferenceEquals/vb/referenceequals.vb" id="Snippet1"::: diff --git a/xml/System/ObjectDisposedException.xml b/xml/System/ObjectDisposedException.xml index 3597c4ae365..e01f9ef315a 100644 --- a/xml/System/ObjectDisposedException.xml +++ b/xml/System/ObjectDisposedException.xml @@ -87,7 +87,6 @@ ## Examples The following example demonstrates an error that causes the `ObjectDisposedException` exception to be thrown. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ObjDispEx/CPP/objdispexc.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/ObjectDisposedException/Overview/objdispexc.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/ObjectDisposedException/Overview/objdispexc.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ObjDispEx/VB/objdispexc.vb" id="Snippet1"::: diff --git a/xml/System/OperatingSystem.xml b/xml/System/OperatingSystem.xml index a9b63d2aa77..b39dc3f722b 100644 --- a/xml/System/OperatingSystem.xml +++ b/xml/System/OperatingSystem.xml @@ -206,7 +206,6 @@ ## Examples The following code example illustrates the use of the method to make a copy of an object. The clone is compared with the original object to show that they are not the same object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.OperatingSystem.Clone/CPP/clone.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/OperatingSystem/Clone/clone.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/OperatingSystem/Clone/clone.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.OperatingSystem.Clone/VB/clone.vb" id="Snippet1"::: @@ -1125,7 +1124,6 @@ ## Examples The following code example creates several objects and displays the property for each. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.OperatingSystem.Platform_Version/CPP/plat_ver.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/OperatingSystem/Platform/plat_ver.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/OperatingSystem/Platform/plat_ver.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.OperatingSystem.Platform_Version/VB/plat_ver.vb" id="Snippet1"::: @@ -1187,7 +1185,6 @@ ## Examples The following code example demonstrates the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/OperatingSystem.ServicePack/CPP/sp.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/OperatingSystem/ServicePack/sp.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/OperatingSystem/ServicePack/sp.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/OperatingSystem.ServicePack/VB/sp.vb" id="Snippet1"::: @@ -1251,7 +1248,6 @@ For a list of Windows operating system versions and their corresponding version ## Examples The following code example illustrates the use of the method to display objects. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.OperatingSystem.Ctor_ToString/CPP/ctor_tostr.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/OperatingSystem/ToString/ctor_tostr.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/OperatingSystem/ToString/ctor_tostr.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.OperatingSystem.Ctor_ToString/VB/ctor_tostr.vb" id="Snippet1"::: @@ -1314,7 +1310,6 @@ For a list of Windows operating system versions and their corresponding version ## Examples The following code example creates several objects and displays the property for each. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.OperatingSystem.Platform_Version/CPP/plat_ver.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/OperatingSystem/Platform/plat_ver.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/OperatingSystem/Platform/plat_ver.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.OperatingSystem.Platform_Version/VB/plat_ver.vb" id="Snippet1"::: @@ -1376,7 +1371,6 @@ For a list of Windows operating system versions and their corresponding version ## Examples The following code example demonstrates the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/OperatingSystem.VersionString/CPP/osvs.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/OperatingSystem/VersionString/osvs.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/OperatingSystem/VersionString/osvs.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/OperatingSystem.VersionString/VB/osvs.vb" id="Snippet1"::: diff --git a/xml/System/PlatformID.xml b/xml/System/PlatformID.xml index cc45e4e6207..9b80370990e 100644 --- a/xml/System/PlatformID.xml +++ b/xml/System/PlatformID.xml @@ -63,21 +63,20 @@ Identifies the operating system, or platform, supported by an assembly. - and properties to obtain the `PlatformID` enumeration for the currently executing operating system or development platform. Use the `PlatformID` enumeration to help determine whether the current operating system or development platform supports your application. - - You can use the underlying integer value of each `PlatformID` enumeration member as the `PlatformId` argument for the [SignTool.exe (Sign Tool)](/dotnet/framework/tools/signtool-exe) utility. - -## Examples + and properties to obtain the `PlatformID` enumeration for the currently executing operating system or development platform. Use the `PlatformID` enumeration to help determine whether the current operating system or development platform supports your application. + + You can use the underlying integer value of each `PlatformID` enumeration member as the `PlatformId` argument for the [SignTool.exe (Sign Tool)](/dotnet/framework/tools/signtool-exe) utility. + +## Examples The following example demonstrates using the `PlatformID` class to identify the currently executing operating system: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/platformID.class/CPP/pid.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/PlatformID/Overview/pid.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/PlatformID/Overview/pid.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/platformID.class/VB/pid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/platformID.class/VB/pid.vb" id="Snippet1"::: + ]]> diff --git a/xml/System/Random.xml b/xml/System/Random.xml index 274ec708bea..354f4df0fcd 100644 --- a/xml/System/Random.xml +++ b/xml/System/Random.xml @@ -77,14 +77,12 @@ , , and methods to generate sequences of random numbers within different ranges. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Random/cpp/random2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Random/Overview/Random2.cs" interactive="try-dotnet-method" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Random/fs/Random2.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Random/vb/Random2.vb" id="Snippet2"::: The following example generates a random integer that it uses as an index to retrieve a string value from an array. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next1.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Random/Overview/next1.cs" interactive="try-dotnet-method" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Random.Next/FS/next1.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Next/VB/next1.vb" id="Snippet3"::: @@ -239,7 +237,6 @@ The following example uses the parameterless constructor to instantiate three objects with the class constructor that takes a seed parameter and generates a sequence of random integers and doubles. The example illustrates that the same sequence is generated when the object is created again with the constructor and seed parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Random.Ctor/CPP/ctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Random/.ctor/ctor.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Random.Ctor/FS/ctor.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Ctor/VB/ctor.vb" id="Snippet1"::: @@ -604,14 +601,12 @@ The following example uses the parameterless constructor to instantiate three method to generate 10 random numbers. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next3.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/Random/Overview/next3.cs" interactive="try-dotnet-method" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Random.Next/FS/next3.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Next/VB/next3.vb" id="Snippet5"::: The following example derives a class from to generate a sequence of random numbers whose distribution differs from the uniform distribution generated by the method of the base class. It overrides the method to provide the distribution of random numbers, and overrides the method to use series of random numbers. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Random.Sample/cpp/sampleex.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Random/Next/sample.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Sample/VB/sample.vb" id="Snippet1"::: @@ -682,14 +677,12 @@ The following example uses the parameterless constructor to instantiate three method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Random/Overview/next.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Random.Next/FS/next.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Next/VB/next.vb" id="Snippet1"::: The following example generates a random integer that it uses as an index to retrieve a string value from an array. Because the highest index of the array is one less than its length, the value of the property is supplied as a the `maxValue` parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next1.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Random/Overview/next1.cs" interactive="try-dotnet-method" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Random.Next/FS/next1.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Next/VB/next1.vb" id="Snippet3"::: @@ -764,14 +757,12 @@ The following example uses the parameterless constructor to instantiate three method to generate random integers with three distinct ranges. Note that the exact output from the example depends on the system-supplied seed value passed to the class constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Random/Overview/Next2.cs" interactive="try-dotnet-method" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Random.Next/FS/Next2.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Next/VB/next2.vb" id="Snippet2"::: The following example generates a random integer that it uses as an index to retrieve a string value from an array. Because the highest index of the array is one less than its length, the value of the property is supplied as a the `maxValue` parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Random.Next/CPP/next4.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Random/Overview/next4.cs" interactive="try-dotnet-method" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Random.Next/FS/next4.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Next/VB/next4.vb" id="Snippet4"::: @@ -847,7 +838,6 @@ The following example uses the parameterless constructor to instantiate three method to fill an array of bytes with random byte values. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Random.NextBytes Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Random/NextBytes/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Random.NextBytes Example/VB/source.vb" id="Snippet1"::: @@ -977,7 +967,6 @@ Each element of the span of bytes is set to a random number greater than or equa The following example uses the method to generate sequences of random doubles. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Random.Ctor/CPP/ctor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Random/.ctor/ctor.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Random.Ctor/FS/ctor.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Ctor/VB/ctor.vb" id="Snippet1"::: @@ -1209,7 +1198,6 @@ Each element of the span of bytes is set to a random number greater than or equa ## Examples The following example derives a class from and overrides the method to generate a distribution of random numbers. This distribution is different than the uniform distribution generated by the method of the base class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Random.Sample/cpp/sampleex.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Random/Next/sample.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/VS_Snippets_CLR_System/system.Random.Sample/FS/sample.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Random.Sample/VB/sample.vb" id="Snippet1"::: diff --git a/xml/System/ResolveEventHandler.xml b/xml/System/ResolveEventHandler.xml index 5fa07435b4a..84b98232489 100644 --- a/xml/System/ResolveEventHandler.xml +++ b/xml/System/ResolveEventHandler.xml @@ -81,16 +81,16 @@ Represents a method that handles the , , or event of an . The assembly that resolves the type, assembly, or resource; or if the assembly cannot be resolved. - to return the assembly that resolves the type, assembly, or resource, or to return null if the assembly is not recognized. For more information, see [Resolving Assembly Loads](/dotnet/standard/assembly/resolve-loads) and the , , and events. - + to return the assembly that resolves the type, assembly, or resource, or to return null if the assembly is not recognized. For more information, see [Resolving Assembly Loads](/dotnet/standard/assembly/resolve-loads) and the , , and events. + > [!IMPORTANT] -> Beginning with the .NET Framework 4, the event is raised for all assemblies, including resource assemblies. In earlier versions, the event was not raised for resource assemblies. If the operating system is localized, the handler might be called multiple times: once for each culture in the fallback chain. - - Every derived class of and has a constructor and an `Invoke` method. See the C++ code example in the description for the class. - +> Beginning with .NET Framework 4, the event is raised for all assemblies, including resource assemblies. In earlier versions, the event was not raised for resource assemblies. If the operating system is localized, the handler might be called multiple times: once for each culture in the fallback chain. + + Every derived class of and has a constructor and an `Invoke` method. + ]]> diff --git a/xml/System/RuntimeTypeHandle.xml b/xml/System/RuntimeTypeHandle.xml index 56126d50150..deee6649b87 100644 --- a/xml/System/RuntimeTypeHandle.xml +++ b/xml/System/RuntimeTypeHandle.xml @@ -86,7 +86,6 @@ ## Examples The following example demonstrates how to obtain a from a type or from an object, and how to turn the handle back into a type. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetTypeHandle/CPP/Type_GetTypeHandle.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/RuntimeTypeHandle/Overview/type_gettypehandle.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/RuntimeTypeHandle/Overview/type_gettypehandle.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetTypeHandle/VB/type_gettypehandle.vb" id="Snippet1"::: diff --git a/xml/System/SByte.xml b/xml/System/SByte.xml index 0406727fc52..3fcd1ee0b8f 100644 --- a/xml/System/SByte.xml +++ b/xml/System/SByte.xml @@ -536,7 +536,6 @@ ## Examples The following example demonstrates generic and nongeneric versions of the method for several value and reference types. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/T.CompareTo/CPP/cat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Boolean/CompareTo/cat.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Boolean/CompareTo/cat.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/T.CompareTo/VB/cat.vb" id="Snippet1"::: diff --git a/xml/System/SerializableAttribute.xml b/xml/System/SerializableAttribute.xml index 0b9a0d5a856..7dde21553eb 100644 --- a/xml/System/SerializableAttribute.xml +++ b/xml/System/SerializableAttribute.xml @@ -73,30 +73,29 @@ Indicates that a class can be serialized using binary or XML serialization. This class cannot be inherited. - attribute to a type to indicate that instances of this type can be serialized using binary or XML serialization. The common language runtime throws if any type in the graph of objects being serialized does not have the attribute applied. - - Apply the attribute even if the class also implements the interface to control the binary serialization process. - - When you apply the attribute to a type, all private and public fields are serialized by default. You can control binary serialization more granularly by implementing the interface to override the serialization process. - - Or you can exclude fields from serialization by applying the attribute to the field. If a field of a binary-serializable type contains a pointer, a handle, or some other data structure that is specific to a particular environment, and cannot be meaningfully reconstituted in a different environment, then you might want to apply the attribute to that field. - + attribute to a type to indicate that instances of this type can be serialized using binary or XML serialization. The common language runtime throws if any type in the graph of objects being serialized does not have the attribute applied. + + Apply the attribute even if the class also implements the interface to control the binary serialization process. + + When you apply the attribute to a type, all private and public fields are serialized by default. You can control binary serialization more granularly by implementing the interface to override the serialization process. + + Or you can exclude fields from serialization by applying the attribute to the field. If a field of a binary-serializable type contains a pointer, a handle, or some other data structure that is specific to a particular environment, and cannot be meaningfully reconstituted in a different environment, then you might want to apply the attribute to that field. + For more information about using attributes, see [Attributes](/dotnet/standard/attributes/). For more information about binary serialization, see . > [!NOTE] > This attribute does not apply to JSON serialization using . + +## Examples + The following example demonstrates SOAP serialization of an object that's marked with the attribute. -## Examples - The following example demonstrates SOAP serialization of an object that's marked with the attribute. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/SerializationAttributes/CPP/s.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/NonSerializedAttribute/Overview/s.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/NonSerializedAttribute/Overview/s.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SerializationAttributes/VB/s.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/SerializationAttributes/VB/s.vb" id="Snippet1"::: + ]]> diff --git a/xml/System/Single.xml b/xml/System/Single.xml index c44df155936..67f14363b1a 100644 --- a/xml/System/Single.xml +++ b/xml/System/Single.xml @@ -1147,7 +1147,6 @@ This computes `arctan(x) / π` in the interval `[-0.5, +0.5]`. method. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Single/CPP/singlesample.cpp" id="Snippet16"::: :::code language="csharp" source="~/snippets/csharp/System/Single/CompareTo/singlesample.cs" id="Snippet16"::: :::code language="fsharp" source="~/snippets/fsharp/System/Single/CompareTo/singlesample.fs" id="Snippet16"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Single/VB/singlesample.vb" id="Snippet16"::: @@ -1229,7 +1228,6 @@ The following code example demonstrates the me method for several value and reference types. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/T.CompareTo/CPP/cat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Boolean/CompareTo/cat.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Boolean/CompareTo/cat.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/T.CompareTo/VB/cat.vb" id="Snippet1"::: @@ -1882,7 +1880,6 @@ This is known as Euler's number and is approximately 2.7182818284590452354. ## Examples The following code example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Single/CPP/singlesample.cpp" id="Snippet17"::: :::code language="csharp" source="~/snippets/csharp/System/Single/CompareTo/singlesample.cs" id="Snippet17"::: :::code language="fsharp" source="~/snippets/fsharp/System/Single/CompareTo/singlesample.fs" id="Snippet17"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Single/VB/singlesample.vb" id="Snippet17"::: @@ -2656,7 +2653,6 @@ A return value of `false` does not imply that method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Single/CPP/singlesample.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System/Single/CompareTo/singlesample.cs" interactive="try-dotnet-method" id="Snippet11"::: :::code language="fsharp" source="~/snippets/fsharp/System/Single/CompareTo/singlesample.fs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Single/VB/singlesample.vb" id="Snippet11"::: @@ -2791,7 +2787,6 @@ This method correctly handles floating-point values and so `2.0` and `3.0` will ## Examples The following code example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Single/CPP/singlesample.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System/Single/CompareTo/singlesample.cs" id="Snippet8"::: :::code language="fsharp" source="~/snippets/fsharp/System/Single/CompareTo/singlesample.fs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Single/VB/singlesample.vb" id="Snippet8"::: @@ -2913,7 +2908,6 @@ This method correctly handles floating-point values and so `2.0` and `3.0` will ## Examples The following code example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Single/CPP/singlesample.cpp" id="Snippet13"::: :::code language="csharp" source="~/snippets/csharp/System/Single/CompareTo/singlesample.cs" interactive="try-dotnet-method" id="Snippet13"::: :::code language="fsharp" source="~/snippets/fsharp/System/Single/CompareTo/singlesample.fs" id="Snippet13"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Single/VB/singlesample.vb" id="Snippet13"::: @@ -3134,7 +3128,6 @@ A return value of `false` does not imply that method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Single/CPP/singlesample.cpp" id="Snippet12"::: :::code language="csharp" source="~/snippets/csharp/System/Single/CompareTo/singlesample.cs" interactive="try-dotnet-method" id="Snippet12"::: :::code language="fsharp" source="~/snippets/fsharp/System/Single/CompareTo/singlesample.fs" id="Snippet12"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Single/VB/singlesample.vb" id="Snippet12"::: @@ -3885,7 +3878,6 @@ For this method matches the IEEE 754:2 ## Examples The following code example demonstrates the constant. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Single/CPP/singlesample.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Single/CompareTo/singlesample.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/Single/CompareTo/singlesample.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Single/VB/singlesample.vb" id="Snippet4"::: @@ -4186,7 +4178,6 @@ For this method matches the IEEE 754:2 ## Examples The following code example demonstrates the constant. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Single/CPP/singlesample.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/Single/CompareTo/singlesample.cs" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System/Single/CompareTo/singlesample.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Single/VB/singlesample.vb" id="Snippet5"::: @@ -4305,7 +4296,6 @@ For this method matches the IEEE 754:2 ## Examples The following example demonstrates the constant. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Single/CPP/singlesample.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System/Single/CompareTo/singlesample.cs" interactive="try-dotnet-method" id="Snippet7"::: :::code language="fsharp" source="~/snippets/fsharp/System/Single/CompareTo/singlesample.fs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Single/VB/singlesample.vb" id="Snippet7"::: @@ -4372,7 +4362,6 @@ For this method matches the IEEE 754:2 ## Examples The following code example demonstrates the constant. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Single/CPP/singlesample.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System/Single/CompareTo/singlesample.cs" interactive="try-dotnet-method" id="Snippet9"::: :::code language="fsharp" source="~/snippets/fsharp/System/Single/CompareTo/singlesample.fs" id="Snippet9"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Single/VB/singlesample.vb" id="Snippet9"::: @@ -5622,7 +5611,6 @@ Pi is approximately 3.1415926535897932385. ## Examples The following code example demonstrates the constant. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Single/CPP/singlesample.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System/Single/CompareTo/singlesample.cs" interactive="try-dotnet-method" id="Snippet10"::: :::code language="fsharp" source="~/snippets/fsharp/System/Single/CompareTo/singlesample.fs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Single/VB/singlesample.vb" id="Snippet10"::: @@ -9390,7 +9378,6 @@ Tau is approximately 6.2831853071795864769. The following code example illustrates the use of the method along with the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Single/CPP/singlesample.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Single/CompareTo/singlesample.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/Single/CompareTo/singlesample.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Single/VB/singlesample.vb" id="Snippet3"::: diff --git a/xml/System/String.xml b/xml/System/String.xml index 2bbfc51f2d7..9226df9fb58 100644 --- a/xml/System/String.xml +++ b/xml/System/String.xml @@ -826,7 +826,6 @@ In C#, the property is an indexer. In Visual Basic ## Examples The following example demonstrates how you can use this indexer in a routine to validate a string. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Uri_IsHexDigit/CPP/uri_ishexdigit.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Chars/uri_ishexdigit.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Chars/uri_ishexdigit.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Uri_IsHexDigit/VB/uri_ishexdigit.vb" id="Snippet1"::: @@ -1016,14 +1015,12 @@ The comparison terminates when an inequality is discovered or both strings have Unexpected results can occur when comparisons are affected by culture-specific casing rules. For example, in Turkish, the following example yields the wrong results because the file system in Turkish does not use linguistic casing rules for the letter "i" in "file". -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/remarks.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/remarks.cs" id="Snippet10"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/remarks.fs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Compare/vb/remarks.vb" id="Snippet10"::: Compare the path name to "file" using an ordinal comparison. The correct code to do this is as follows: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/remarks.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/remarks.cs" id="Snippet11"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/remarks.fs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Compare/vb/remarks.vb" id="Snippet11"::: @@ -1031,14 +1028,12 @@ Compare the path name to "file" using an ordinal comparison. The correct code to ## Examples The following example calls the method to compare three sets of strings. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/compare02.cpp" id="Snippet18"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/compare02.cs" interactive="try-dotnet-method" id="Snippet18"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/compare02.fs" id="Snippet18"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Compare/vb/compare02.vb" id="Snippet18"::: In the following example, the `ReverseStringComparer` class demonstrates how you can evaluate two strings with the method. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ArrayList/CPP/ArrayListSample.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/ArrayListSample.cs" interactive="try-dotnet" id="Snippet7"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/ArrayListSample.fs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ArrayList/VB/ArrayListSample.vb" id="Snippet7"::: @@ -1150,14 +1145,12 @@ The comparison terminates when an inequality is discovered or both strings have Unexpected results can occur when comparisons are affected by culture-specific casing rules. For example, in Turkish, the following example yields the wrong results because the file system in Turkish does not use linguistic casing rules for the letter "i" in "file". -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/remarks.cpp" id="Snippet12"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/remarks.cs" id="Snippet12"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/remarks.fs" id="Snippet12"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Compare/vb/remarks.vb" id="Snippet12"::: Compare the path name to "file" using an ordinal comparison. The correct code to do this is as follows: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/remarks.cpp" id="Snippet13"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/remarks.cs" id="Snippet13"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/remarks.fs" id="Snippet13"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Compare/vb/remarks.vb" id="Snippet13"::: @@ -1165,7 +1158,6 @@ Compare the path name to "file" using an ordinal comparison. The correct code to ## Examples The following example demonstrates that the method is equivalent to using or when comparing strings. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/compare02.cpp" id="Snippet18"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/compare02.cs" interactive="try-dotnet-method" id="Snippet18"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/compare02.fs" id="Snippet18"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Compare/vb/compare02.vb" id="Snippet18"::: @@ -1273,14 +1265,12 @@ The comparison terminates when an inequality is discovered or both strings have Unexpected results can occur when comparisons are affected by culture-specific casing rules. For example, in Turkish, the following example yields the wrong results because the file system in Turkish does not use linguistic casing rules for the letter "i" in "file". -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/remarks.cpp" id="Snippet16"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/remarks.cs" id="Snippet16"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/remarks.fs" id="Snippet16"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Compare/vb/remarks.vb" id="Snippet16"::: Compare the path name to "file" using an ordinal comparison. The correct code to do this is as follows: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/remarks.cpp" id="Snippet17"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/remarks.cs" id="Snippet17"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/remarks.fs" id="Snippet17"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Compare/vb/remarks.vb" id="Snippet17"::: @@ -1288,7 +1278,6 @@ Compare the path name to "file" using an ordinal comparison. The correct code to ## Examples The following example compares three versions of the letter "I". The results are affected by the choice of culture, whether case is ignored, and whether an ordinal comparison is performed. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.CompareCmp/cpp/cmpcmp.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/cmpcmp.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/cmpcmp.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.CompareCmp/vb/cmpcmp.vb" id="Snippet1"::: @@ -1396,14 +1385,12 @@ The comparison terminates when an inequality is discovered or both strings have Unexpected results can occur when comparisons are affected by culture-specific casing rules. For example, in Turkish, the following example yields the wrong results because the file system in Turkish does not use linguistic casing rules for the letter "i" in "file". -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/remarks.cpp" id="Snippet14"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/remarks.cs" id="Snippet14"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/remarks.fs" id="Snippet14"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Compare/vb/remarks.vb" id="Snippet14"::: Compare the path name to "file" using an ordinal comparison. The correct code to do this is as follows: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/remarks.cpp" id="Snippet15"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/remarks.cs" id="Snippet15"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/remarks.fs" id="Snippet15"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Compare/vb/remarks.vb" id="Snippet15"::: @@ -1411,7 +1398,6 @@ Compare the path name to "file" using an ordinal comparison. The correct code to ## Examples The following example demonstrates how culture can affect a comparison. In Czech - Czech Republic culture, "ch" is a single character that is greater than "d". However, in English - United States culture, "ch" consists of two characters, and "c" is less than "d". -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.comp4/CPP/string.comp4.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/string.comp4.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/string.comp4.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.comp4/VB/string.comp4.vb" id="Snippet1"::: @@ -1524,7 +1510,6 @@ The comparison terminates when an inequality is discovered or both strings have ## Examples The following example compares two strings in three different ways: Use linguistic comparison for the en-US culture; using linguistic case-sensitive comparison for the en-US culture; and using an ordinal comparison. It illustrates how the three methods of comparison produce three different results. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/Example.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/Example.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Compare/vb/Example.vb" id="Snippet1"::: @@ -1635,14 +1620,12 @@ The comparison terminates when an inequality is discovered or both substrings ha Unexpected results can occur when comparisons are affected by culture-specific casing rules. For example, in Turkish, the following example yields the wrong results because the file system in Turkish does not use linguistic casing rules for the letter "i" in "file". -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/remarks.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/remarks.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/remarks.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Compare/vb/remarks.vb" id="Snippet2"::: Compare the path name to "file" using an ordinal comparison. The correct code to do this is as follows: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/remarks.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/remarks.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/remarks.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Compare/vb/remarks.vb" id="Snippet3"::: @@ -1650,7 +1633,6 @@ Compare the path name to "file" using an ordinal comparison. The correct code to ## Examples The following example compares two substrings. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.compare3/CPP/comp3.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/comp3.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/comp3.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.compare3/VB/comp3.vb" id="Snippet1"::: @@ -1772,14 +1754,12 @@ The comparison terminates when an inequality is discovered or both substrings ha Unexpected results can occur when comparisons are affected by culture-specific casing rules. For example, in Turkish, the following example yields the wrong results because the file system in Turkish does not use linguistic casing rules for the letter "i" in "file". -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/remarks.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/remarks.cs" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/remarks.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Compare/vb/remarks.vb" id="Snippet4"::: The path name needs to be compared in an invariant manner. The correct code to do this is as follows. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/remarks.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/remarks.cs" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/remarks.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Compare/vb/remarks.vb" id="Snippet5"::: @@ -1787,7 +1767,6 @@ The path name needs to be compared in an invariant manner. The correct code to d ## Examples The following example performs two comparisons of two substrings that only differ in case. The first comparison ignores case and the second comparison considers case. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.compare4/CPP/comp4.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/comp4.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/comp4.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.compare4/VB/comp4.vb" id="Snippet1"::: @@ -1912,14 +1891,12 @@ The comparison terminates when an inequality is discovered or both substrings ha Unexpected results can occur when comparisons are affected by culture-specific casing rules. For example, in Turkish, the following example yields the wrong results because the file system in Turkish does not use linguistic casing rules for the letter "i" in "file". -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/remarks.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/remarks.cs" id="Snippet8"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/remarks.fs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Compare/vb/remarks.vb" id="Snippet8"::: Compare the path name to "file" using an ordinal comparison. The correct code to do this is as follows: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/remarks.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/remarks.cs" id="Snippet9"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/remarks.fs" id="Snippet9"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Compare/vb/remarks.vb" id="Snippet9"::: @@ -1927,7 +1904,6 @@ Compare the path name to "file" using an ordinal comparison. The correct code to ## Examples The following example compares two substrings. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.compare3/CPP/comp3.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/comp3.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/comp3.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.compare3/VB/comp3.vb" id="Snippet1"::: @@ -2050,14 +2026,12 @@ The comparison terminates when an inequality is discovered or both substrings ha Unexpected results can occur when comparisons are affected by culture-specific casing rules. For example, in Turkish, the following example yields the wrong results because the file system in Turkish does not use linguistic casing rules for the letter "i" in "file". -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/remarks.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/remarks.cs" id="Snippet6"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/remarks.fs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Compare/vb/remarks.vb" id="Snippet6"::: Compare the path name to "file" using an ordinal comparison. The correct code to do this is as follows: -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Compare/cpp/remarks.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/remarks.cs" id="Snippet7"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/remarks.fs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Compare/vb/remarks.vb" id="Snippet7"::: @@ -2065,7 +2039,6 @@ Compare the path name to "file" using an ordinal comparison. The correct code to ## Examples The following example compares two substrings using different cultures and ignoring the case of the substrings. The choice of culture affects how the letter "I" is compared. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.compare5/CPP/comp5.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Compare/comp5.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Compare/comp5.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.compare5/VB/comp5.vb" id="Snippet1"::: @@ -2313,7 +2286,6 @@ Because is a ## Examples The following example performs and ordinal comparison of two strings that only differ in case. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.compareordinal/CPP/comp0.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/CompareOrdinal/comp0.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/CompareOrdinal/comp0.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.compareordinal/VB/comp0.vb" id="Snippet1"::: @@ -2423,7 +2395,6 @@ Because is a ## Examples This following example demonstrates that and use different sort orders. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StringCompareOrdinal/CPP/stringcompareordinal.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/CompareOrdinal/stringcompareordinal.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/CompareOrdinal/stringcompareordinal.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StringCompareOrdinal/VB/stringcompareordinal.vb" id="Snippet1"::: @@ -2553,7 +2524,6 @@ For more information about the behavior of this method, see the Remarks section ## Examples The following example uses the method with an . Because it attempts to compare a instance to a `TestClass` object, the method throws an . -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ExToString/CPP/extostring.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/CompareTo/extostring.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/CompareTo/extostring.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ExToString/VB/extostring.vb" id="Snippet1"::: @@ -2672,14 +2642,12 @@ This method implements the method to compare the current string instance with another string. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/StringCompareTo/CPP/stringcompareto.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/CompareTo/stringcompareto.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/CompareTo/stringcompareto.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/StringCompareTo/VB/stringcompareto.vb" id="Snippet1"::: The following example demonstrates generic and non-generic versions of the CompareTo method for several value and reference types. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/T.CompareTo/CPP/cat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Boolean/CompareTo/cat.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Boolean/CompareTo/cat.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/T.CompareTo/VB/cat.vb" id="Snippet1"::: @@ -2870,7 +2838,6 @@ The method represents `arg0` as a str ## Examples The following example demonstrates the method. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.concat5/CPP/string.concat5.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Concat/string.concat5.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Concat/string.concat5.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.concat5/VB/string.concat5.vb" id="Snippet1"::: @@ -3135,7 +3102,6 @@ An string is used in pla ## Examples The following example demonstrates the use of the method with a array. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringconcat3/CPP/stringconcat3.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Concat/stringconcat3.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Concat/stringconcat3.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringconcat3/VB/stringconcat3.vb" id="Snippet1"::: @@ -3210,7 +3176,6 @@ If either of the arguments is an array reference, the method concatenates a stri ## Examples The following example demonstrates the method. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.concat5/CPP/string.concat5.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Concat/string.concat5.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Concat/string.concat5.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.concat5/VB/string.concat5.vb" id="Snippet1"::: @@ -3333,7 +3298,6 @@ An string is used in pla ## Examples The following example concatenates a person's first, middle, and last name. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringconcat4/CPP/stringconcat4.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Concat/stringconcat4.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Concat/stringconcat4.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringconcat4/VB/stringconcat4.vb" id="Snippet1"::: @@ -3405,7 +3369,6 @@ The method concatenates `arg0`, `arg1`, and `arg2` by calling the parameterless ## Examples The following example demonstrates the method. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.concat5/CPP/string.concat5.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Concat/string.concat5.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Concat/string.concat5.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.concat5/VB/string.concat5.vb" id="Snippet1"::: @@ -3530,7 +3493,6 @@ The method concatenates `str0`, `str1`, and `str2`; it does not add any delimite ## Examples The following example uses the method to concatenate three strings and displays the result. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.string.concat/cpp/Concat6.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System/String/Concat/Concat6.cs" interactive="try-dotnet" id="Snippet6"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Concat/Concat6.fs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.string.concat/vb/Concat6.vb" id="Snippet6"::: @@ -3949,7 +3911,6 @@ If you are interested in the position of the substring `value` in the current in ## Examples The following example determines whether the string "fox" is a substring of a familiar quotation. If "fox" is found in the string, it also displays its starting position. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.contains/CPP/cont.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Contains/cont.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Contains/cont.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.contains/VB/cont.vb" id="Snippet1"::: @@ -4242,7 +4203,6 @@ This method copies `count` characters from the `sourceIndex` position of this in ## Examples The following example demonstrates the method. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringcopyto/CPP/stringcopyto.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/CopyTo/stringcopyto.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/CopyTo/stringcopyto.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringcopyto/VB/stringcopyto.vb" id="Snippet1"::: @@ -4627,7 +4587,6 @@ The following example indicates whether each string in an array ends with a peri The following example defines a `StripEndTags` method that uses the method to remove HTML end tags from the end of a line. Note that the `StripEndTags` method is called recursively to ensure that multiple HTML end tags at the end of the line are removed. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringendswith/CPP/stringendswith.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/EndsWith/stringendswith.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/EndsWith/stringendswith.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringendswith/VB/stringendswith.vb" id="Snippet1"::: @@ -4710,7 +4669,6 @@ The method compares the `value` parameter to th ## Examples The following example determines whether a string ends with a particular substring. The results are affected by the choice of culture, whether case is ignored, and whether an ordinal comparison is performed. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.EndsWithCmp/cpp/ewcmp.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/EndsWith/ewcmp.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/EndsWith/ewcmp.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.EndsWithCmp/vb/ewcmp.vb" id="Snippet1"::: @@ -4927,7 +4885,6 @@ This method performs an ordinal (case-sensitive and culture-insensitive) compari ## Examples The following example demonstrates the method. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.equals/CPP/equals.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Equals/equals.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Equals/equals.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.equals/VB/equals.vb" id="Snippet1"::: @@ -5091,7 +5048,6 @@ This method performs an ordinal (case-sensitive and culture-insensitive) compari ## Examples The following example demonstrates the method. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.equals/CPP/equals.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Equals/equals.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Equals/equals.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.equals/VB/equals.vb" id="Snippet1"::: @@ -5358,7 +5314,6 @@ This method uses the [composite formatting feature](/dotnet/standard/base-types/ The following example uses the method to embed an individual's age in the middle of a string. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/format7.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System/FormatException/Overview/format7.cs" interactive="try-dotnet-method" id="Snippet7"::: :::code language="fsharp" source="~/snippets/fsharp/System/FormatException/Overview/format7.fs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Format/vb/format7.vb" id="Snippet7"::: @@ -5465,14 +5420,12 @@ This method uses the [composite formatting feature](/dotnet/standard/base-types/ This example creates a string that contains data on the high and low temperature on a particular date. The composite format string has five format items in the C# example and six in the Visual Basic example. Two of the format items define the width of their corresponding value's string representation, and the first format item also includes a standard date and time format string. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/format5.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/FormatException/Overview/format5.cs" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System/FormatException/Overview/format5.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Format/vb/format5.vb" id="Snippet5"::: You can also pass the objects to be formatted as an array rather than as an argument list. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/format_paramarray1.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System/FormatException/Overview/format_paramarray1.cs" interactive="try-dotnet" id="Snippet10"::: :::code language="fsharp" source="~/snippets/fsharp/System/FormatException/Overview/format_paramarray1.fs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Format/vb/format_paramarray1.vb" id="Snippet10"::: @@ -6045,7 +5998,6 @@ This method uses the [composite formatting feature](/dotnet/standard/base-types/ This example uses the method to display time and temperature data stored in a generic object. Note that the format string has three format items, although there are only two objects to format. This is because the first object in the list (a date and time value) is used by two format items: The first format item displays the time, and the second displays the date. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/formatexample4.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System/FormatException/Overview/formatexample4.cs" id="Snippet6"::: :::code language="fsharp" source="~/snippets/fsharp/System/FormatException/Overview/formatexample4.fs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Format/vb/formatexample4.vb" id="Snippet6"::: @@ -6231,7 +6183,6 @@ This method uses the [composite formatting feature](/dotnet/standard/base-types/ This example uses the method to create a string that illustrates the result of a Boolean `And` operation with two integer values. Note that the format string includes six format items, but the method has only three items in its parameter list, because each item is formatted in two different ways. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Format/cpp/format4.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/FormatException/Overview/format4.cs" interactive="try-dotnet-method" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/FormatException/Overview/format4.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Format/vb/format4.vb" id="Snippet4"::: @@ -6587,14 +6538,13 @@ The index of a format item is less than zero, or greater than two. ## Remarks > [!TIP] -> Rather than calling the method to retrieve a object that you then use to enumerate a string, you should instead use your language's iteration construct (in C#, in F#, in C++/CLR, and in Visual Basic). [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) in C#, [for..in](/dotnet/fsharp/language-reference/loops-for-in-expression) in F#, [for each](/cpp/dotnet/for-each-in) in C++/CLR, and [For Each](/dotnet/visual-basic/language-reference/statements/for-each-next-statement) in Visual Basic). +> Rather than calling the method to retrieve a object that you then use to enumerate a string, you should instead use your language's iteration construct. Examples include [foreach](/dotnet/csharp/language-reference/keywords/foreach-in) in C#, [for..in](/dotnet/fsharp/language-reference/loops-for-in-expression) in F#, and [For Each](/dotnet/visual-basic/language-reference/statements/for-each-next-statement) in Visual Basic). This method enables you to iterate the individual characters in a string. For example, the Visual Basic `For Each`, the F# `for..in` expression, and C# `foreach` statements invoke this method to return a object that can provide read-only access to the characters in this string instance. ## Examples The following example iterates the characters in several strings and displays information about their individual characters. It uses the language iteration construct rather than a call to the method. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.GetEnumerator/CPP/getenumerator.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/GetEnumerator/getenumerator.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/GetEnumerator/getenumerator.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.GetEnumerator/VB/getenumerator.vb" id="Snippet1"::: @@ -6715,7 +6665,6 @@ For additional information about the use of hash codes and the `GetHashCode` met ## Examples The following example demonstrates the method using various input strings. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.GetHashCode/CPP/gethashcode.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/GetHashCode/gethashcode.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/GetHashCode/gethashcode.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.GetHashCode/VB/gethashcode.vb" id="Snippet1"::: @@ -6959,7 +6908,6 @@ The `GetPinnableReference` method returns a character that can be used for pinni ## Examples The following example displays the enumerated constant for the type. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.gettypecode/CPP/gtc.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/GetTypeCode/gtc.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/GetTypeCode/gtc.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.gettypecode/VB/gtc.vb" id="Snippet1"::: @@ -7044,7 +6992,6 @@ This method performs an ordinal (culture-insensitive) search, where a character ## Examples The following example demonstrates how you can search a for a character using the method. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.IndexOf/CPP/indexof_c.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/String/IndexOf/indexof_c.cs" interactive="try-dotnet-method" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/IndexOf/indexof_c.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.IndexOf/VB/indexof_c.vb" id="Snippet5"::: @@ -7120,14 +7067,12 @@ Character sets include ignorable characters, which are characters that are not c ## Examples The following example searches for the "n" in "animal". Because string indexes begin at zero rather than one, the method indicates that the "n" is at position 1. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.IndexOf/CPP/simple1.cpp" id="Snippet12"::: :::code language="csharp" source="~/snippets/csharp/System/String/IndexOf/simple1.cs" interactive="try-dotnet-method" id="Snippet12"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/IndexOf/simple1.fs" id="Snippet12"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.IndexOf/VB/simple1.vb" id="Snippet12"::: The following example uses the method to determine the starting position of an animal name in a sentence. It then uses this position to insert an adjective that describes the animal into the sentence. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringinsert/CPP/stringinsert.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/IndexOf/stringinsert.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/IndexOf/stringinsert.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringinsert/VB/stringinsert.vb" id="Snippet1"::: @@ -7213,7 +7158,6 @@ This method performs an ordinal (culture-insensitive) search, where a character ## Examples The following example demonstrates the method. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.indexof1/CPP/ixof1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/IndexOf/ixof1.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/IndexOf/ixof1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.indexof1/VB/ixof1.vb" id="Snippet1"::: @@ -7347,7 +7291,6 @@ Character sets include ignorable characters, which are characters that are not c ## Examples The following example searches for all occurrences of a specified string within a target string. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringindexof4/CPP/stringindexof4.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/IndexOf/stringindexof4.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/IndexOf/stringindexof4.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringindexof4/VB/stringindexof4.vb" id="Snippet1"::: @@ -7526,7 +7469,6 @@ This method performs an ordinal (culture-insensitive) search, where a character ## Examples The following example demonstrates the method. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.IndexOf/CPP/indexofcii.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/IndexOf/indexofcii.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/IndexOf/indexofcii.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.IndexOf/VB/indexofcii.vb" id="Snippet1"::: @@ -7617,7 +7559,6 @@ Character sets include ignorable characters, which are characters that are not c ## Examples The following example finds the index of all occurrences of the string "he" within a substring of another string. Note that the number of characters to be searched must be recalculated for each search iteration. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.indexof8/CPP/ixof8.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/IndexOf/ixof8.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/IndexOf/ixof8.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.indexof8/VB/ixof8.vb" id="Snippet1"::: @@ -7996,7 +7937,6 @@ This method performs an ordinal (culture-insensitive) search, where a character ## Examples The following example finds the index of the occurrence of any character of the string "is" within a substring of another string. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.indexofany2/CPP/ixany2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/IndexOfAny/ixany2.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/IndexOfAny/ixany2.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.indexofany2/VB/ixany2.vb" id="Snippet1"::: @@ -8090,7 +8030,6 @@ This method performs an ordinal (culture-insensitive) search, where a character ## Examples The following example finds the index of the occurrence of any character of the string "aid" within a substring of another string. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.indexofany3/CPP/ixany3.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/IndexOfAny/ixany3.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/IndexOfAny/ixany3.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.indexofany3/VB/ixany3.vb" id="Snippet1"::: @@ -8187,7 +8126,6 @@ The following example inserts a space character in the fourth character position The following console application prompts the users to enter one or more adjectives to describe two animals. It then calls the method to insert the text entered by the user into a string. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringinsert/CPP/stringinsert.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/IndexOf/stringinsert.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/IndexOf/stringinsert.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringinsert/VB/stringinsert.vb" id="Snippet1"::: @@ -8267,7 +8205,6 @@ The following console application prompts the users to enter one or more adjecti method. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringjoin/CPP/stringjoin.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Join/stringjoin.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Join/stringjoin.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringjoin/VB/stringjoin.vb" id="Snippet1"::: @@ -9474,7 +9407,6 @@ If `separator` is `null`, an empty string ( method is used ## Examples The following example finds the index of all occurrences of a string in substring, working from the end of the substring to the start of the substring. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.LastIndexOf8/CPP/lastixof8.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/LastIndexOf/lastixof8.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/LastIndexOf/lastixof8.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.LastIndexOf8/VB/lastixof8.vb" id="Snippet1"::: @@ -10574,7 +10502,6 @@ This method performs an ordinal (culture-insensitive) search, where a character ## Examples The following example finds the index of the last occurrence of any character in the string "is" within another string. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.LastIndexOfAny1/CPP/lastixany1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/LastIndexOfAny/lastixany1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/LastIndexOfAny/lastixany1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.LastIndexOfAny1/VB/lastixany1.vb" id="Snippet1"::: @@ -10652,7 +10579,6 @@ This method performs an ordinal (culture-insensitive) search, where a character ## Examples The following example finds the index of the last occurrence of any character in the string "is" within a substring of another string. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.LastIndexOfAny2/CPP/lastixany2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/LastIndexOfAny/lastixany2.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/LastIndexOfAny/lastixany2.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.LastIndexOfAny2/VB/lastixany2.vb" id="Snippet1"::: @@ -10739,7 +10665,6 @@ This method performs an ordinal (culture-insensitive) search, where a character ## Examples The following example finds the index of the last occurrence of any character in the string "aid" within a substring of another string. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.LastIndexOfAny3/CPP/lastixany3.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/LastIndexOfAny/lastixany3.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/LastIndexOfAny/lastixany3.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.LastIndexOfAny3/VB/lastixany3.vb" id="Snippet1"::: @@ -10817,7 +10742,6 @@ The property returns the number of property returns 7, which indicates that it includes the six alphabetic characters as well as the null character. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Class/cpp/system.string.class.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Overview/System.String.Class.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Overview/System.String.Class.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Class/vb/System.String.Class.vb" id="Snippet1"::: @@ -10825,7 +10749,6 @@ In some languages, such as C and C++, a null character indicates the end of a st ## Examples The following example demonstrates the property. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.length/CPP/length.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Length/length.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Length/length.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.length/VB/length.vb" id="Snippet1"::: @@ -10849,7 +10772,6 @@ The following example demonstrates the property. ## Examples The following example normalizes a string to each of four normalization forms, confirms the string was normalized to the specified normalization form, then lists the code points in the normalized string. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.normalize/CPP/norm.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/IsNormalized/norm.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/IsNormalized/norm.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.normalize/VB/norm.vb" id="Snippet1"::: @@ -11077,7 +10999,6 @@ The method defines the operation of the equa ## Examples The following example demonstrates the equality operator. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Equality/CPP/equalityop.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/op_Equality/equalityop.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/op_Equality/equalityop.fs" id="Snippet1"::: @@ -11202,7 +11123,6 @@ The operator in turn calls the static method pads the beginning of the ## Examples The following example demonstrates the method. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic String.PadLeft Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/PadLeft/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/PadLeft/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic String.PadLeft Example/VB/source.vb" id="Snippet1"::: @@ -11357,7 +11276,6 @@ The method pads the beg ## Examples The following example demonstrates the method. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic String.PadLeft1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/PadLeft/source1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/PadLeft/source1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic String.PadLeft1 Example/VB/source.vb" id="Snippet1"::: @@ -11445,7 +11363,6 @@ The method pads the end of the retur ## Examples The following example demonstrates the method. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic String.PadRight Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/PadRight/source.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/PadRight/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic String.PadRight Example/VB/source.vb" id="Snippet1"::: @@ -11519,7 +11436,6 @@ The method pads the en ## Examples The following example demonstrates the method. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic String.PadRight1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/PadRight/source1.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/PadRight/source1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic String.PadRight1 Example/VB/source.vb" id="Snippet1"::: @@ -11604,7 +11520,6 @@ In the .NET Framework, strings are zero-based. The value of the `startIndex` par ## Examples The following example demonstrates the method. The next-to-last case removes all text starting from the specified index through the end of the string. The last case removes three characters starting from the specified index. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.remove/CPP/r.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Remove/r.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Remove/r.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.remove/VB/r.vb" id="Snippet1"::: @@ -11693,7 +11608,6 @@ In the .NET Framework, strings are zero-based. The value of the `startIndex` par ## Examples The following example demonstrates how you can remove the middle name from a complete name. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringremove/CPP/stringremove.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Remove/stringremove.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Remove/stringremove.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringremove/VB/stringremove.vb" id="Snippet1"::: @@ -11800,7 +11714,6 @@ Because this method returns the modified string, you can chain together successi ## Examples The following example creates a comma separated value list by substituting commas for the blanks between a series of numbers. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.replace1/CPP/string.replace1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Replace/string.replace1.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Replace/string.replace1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.replace1/VB/string.replace1.vb" id="Snippet1"::: @@ -11903,7 +11816,6 @@ Because this method returns the modified string, you can chain together successi ## Examples The following example demonstrates how you can use the method to correct a spelling error. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringreplace/CPP/stringreplace.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Replace/stringreplace.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Replace/stringreplace.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringreplace/VB/stringreplace.vb" id="Snippet1"::: @@ -12684,7 +12596,6 @@ In addition, if the same set of characters is used to split strings in multiple ## Examples The following example uses the enumeration to include or exclude substrings generated by the method. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.split3/CPP/omit.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Split/options.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Split/options.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/system/string.split/omit.vb" id="Snippet1"::: @@ -13041,7 +12952,6 @@ In addition, if the same set of characters is used to split strings in multiple The following example uses the enumeration to include or exclude substrings generated by the method. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.split3/CPP/omit.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Split/options.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Split/options.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/system/string.split/omit.vb" id="Snippet1"::: @@ -13232,7 +13142,6 @@ In addition, if the same set of characters is used to split strings in multiple The following example uses the enumeration to include or exclude substrings generated by the method. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.split3/CPP/omit.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Split/options.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Split/options.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/system/string.split/omit.vb" id="Snippet1"::: @@ -13363,7 +13272,6 @@ This method performs a word (case-sensitive and culture-sensitive) comparison us The following example defines a `StripStartTags` method that uses the method to remove HTML start tags from the beginning of a string. Note that the `StripStartTags` method is called recursively to ensure that multiple HTML start tags at the beginning of the line are removed. The example does not remove HTML tags embedded in a string. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/stringstartswith/CPP/stringstartswith.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/StartsWith/stringstartswith.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/StartsWith/stringstartswith.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/stringstartswith/VB/stringstartswith.vb" id="Snippet1"::: @@ -13445,14 +13353,12 @@ The method compares the `value` parameter to ## Examples The following example searches for the string "the" at the beginning of a longer string that begins with the word "The". As the output from the example shows, a call to the method that performs a culture-insensitive but case-sensitive comparison fails to match the string, while a call that performs a culture- and case-insensitive comparison matches the string. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.string.startswith/cpp/StartsWith2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/String/StartsWith/StartsWith2.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/StartsWith/StartsWith2.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.string.startswith/vb/StartsWith2.vb" id="Snippet2"::: The following example determines whether a string starts with a particular substring. It initializes a two-dimensional string array. The first element in the second dimension contains a string, and the second element contains the string to search for at the start of the first string. The results are affected by the choice of culture, whether case is ignored, and whether an ordinal comparison is performed. Note that when the string instance contains a ligature, culture-sensitive comparisons with its consecutive characters successfully match. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.string.startswith/cpp/startswith1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/StartsWith/startswith1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/StartsWith/startswith1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.string.startswith/vb/startswith1.vb" id="Snippet1"::: @@ -13624,7 +13530,6 @@ If `startIndex` is equal to zero, the method returns the original string unchang ## Examples The following example demonstrates obtaining a substring from a string. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.String.Substring/cpp/Substring10.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System/String/Substring/Substring10.cs" interactive="try-dotnet-method" id="Snippet10"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Substring/Substring10.fs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.String.Substring/vb/Substring10.vb" id="Snippet10"::: @@ -13944,7 +13849,6 @@ For more information about the behavior of this method, see the Remarks section The following example uses the method with an . Because it attempts to compare a instance to a `TestClass` object, the method throws an . -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ExToString/CPP/extostring.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/CompareTo/extostring.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/CompareTo/extostring.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ExToString/VB/extostring.vb" id="Snippet1"::: @@ -13991,7 +13895,6 @@ The following example uses the method with an The following example displays the enumerated constant for the type. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.gettypecode/CPP/gtc.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/GetTypeCode/gtc.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/GetTypeCode/gtc.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.gettypecode/VB/gtc.vb" id="Snippet1"::: @@ -15356,7 +15259,6 @@ For more information, see [Character Encoding in .NET](/dotnet/standard/base-typ ## Examples The following example converts a substring within a string to an array of characters, then enumerates and displays the elements of the array. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.ToCharArray1/CPP/tocharry1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/ToCharArray/tocharry1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/ToCharArray/tocharry1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.ToCharArray1/VB/tocharry1.vb" id="Snippet1"::: @@ -15448,7 +15350,6 @@ The casing operation that results from calling the m method.Note that the example does not explicitly call the method. Instead, the method is called implicitly by the [composite formatting](/dotnet/standard/base-types/composite-formatting) feature. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.tostring/CPP/string.tostring.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/ToString/string.tostring.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/ToString/string.tostring.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/string.tostring/VB/string.tostring.vb" id="Snippet1"::: @@ -15849,7 +15748,6 @@ The casing operation that results from calling the method to convert a series of one-character strings that contain each character in the Basic Latin, Latin-1 Supplement, and Latin Extended-A character sets. It then displays each string whose uppercase character is different from its lowercase character. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.ToUpper/cpp/ToUpperEx.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/ToUpper/ToUpperEx.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/ToUpper/ToUpperEx.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.ToUpper/vb/ToUpperEx.vb" id="Snippet1"::: @@ -16097,7 +15995,6 @@ White-space characters are defined by the Unicode standard. The `Trim` method re The following example uses the method to remove any extra white space from strings entered by the user before concatenating them. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Trim/cpp/trim2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/String/Trim/Trim2.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Trim/Trim2.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Trim/vb/Trim2.vb" id="Snippet2"::: @@ -16247,7 +16144,6 @@ If `trimChars` is `null` or an empty array, this method removes any leading or t The following example uses the `Trim(System.Char[])` method to remove space, asterisk (*), and apostrophe (') characters from a string. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.String.Trim/cpp/trim1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Trim/Trim1.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Trim/Trim1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.String.Trim/vb/Trim1.vb" id="Snippet1"::: diff --git a/xml/System/StringComparer.xml b/xml/System/StringComparer.xml index b3c5a221823..e9bc1525870 100644 --- a/xml/System/StringComparer.xml +++ b/xml/System/StringComparer.xml @@ -90,7 +90,6 @@ method of the class. The example illustrates how different objects sort three versions of the Latin letter I. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.StringComparer/cpp/omni.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/StringComparer/Overview/omni.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/StringComparer/Overview/omni.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.StringComparer/vb/omni.vb" id="Snippet1"::: @@ -365,7 +364,6 @@ The following example demonstrates the properties and the method of the class. The example illustrates how different objects sort three versions of the Latin letter I. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.StringComparer/cpp/omni.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/StringComparer/Overview/omni.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/StringComparer/Overview/omni.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.StringComparer/vb/omni.vb" id="Snippet1"::: @@ -491,7 +489,6 @@ The following example demonstrates the properties and the method of the class. The example illustrates how different objects sort three versions of the Latin letter I. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.StringComparer/cpp/omni.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/StringComparer/Overview/omni.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/StringComparer/Overview/omni.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.StringComparer/vb/omni.vb" id="Snippet1"::: @@ -944,7 +941,6 @@ The following example demonstrates the properties and the method of the class. The example illustrates how different objects sort three versions of the Latin letter I. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.StringComparer/cpp/omni.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/StringComparer/Overview/omni.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/StringComparer/Overview/omni.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.StringComparer/vb/omni.vb" id="Snippet1"::: @@ -1182,7 +1178,6 @@ A "well-known ordinal comparer" describes a comparer that behaves identically to ## Examples The following code example demonstrates the properties and the method of the class. The example illustrates how different objects sort three versions of the Latin letter I. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.StringComparer/cpp/omni.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/StringComparer/Overview/omni.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/StringComparer/Overview/omni.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.StringComparer/vb/omni.vb" id="Snippet1"::: @@ -1248,7 +1243,6 @@ A "well-known ordinal comparer" describes a comparer that behaves identically to ## Examples The following code example demonstrates the properties and the method of the class. The example illustrates how different objects sort three versions of the Latin letter I. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.StringComparer/cpp/omni.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/StringComparer/Overview/omni.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/StringComparer/Overview/omni.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.StringComparer/vb/omni.vb" id="Snippet1"::: diff --git a/xml/System/StringSplitOptions.xml b/xml/System/StringSplitOptions.xml index f6b079edd23..cebc7cc1073 100644 --- a/xml/System/StringSplitOptions.xml +++ b/xml/System/StringSplitOptions.xml @@ -72,7 +72,6 @@ The `TrimEntries` field is only available in .NET 5 and later versions. The following example shows how the `StringSplitOptions` enumeration is used to include or exclude substrings generated by the method: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/string.split3/CPP/omit.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/String/Split/options.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/String/Split/options.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/system/string.split/omit.vb" id="Snippet1"::: diff --git a/xml/System/TimeSpan.xml b/xml/System/TimeSpan.xml index 7d5a81ec7ec..9a224ec6456 100644 --- a/xml/System/TimeSpan.xml +++ b/xml/System/TimeSpan.xml @@ -199,7 +199,6 @@ The following example instantiates a object that represen ## Examples The following example creates several objects using the constructor overload that initializes a to a specified number of ticks. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Ctor/CPP/ctorl.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/.ctor/ctorl.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/.ctor/ctorl.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.Ctor/VB/ctorl.vb" id="Snippet1"::: @@ -272,7 +271,6 @@ The following example instantiates a object that represen ## Examples The following example creates several objects using the constructor overload that initializes a to a specified number of hours, minutes, and seconds. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Ctor/CPP/ctoriii.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/.ctor/ctoriii.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/.ctor/ctoriii.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.Ctor/VB/ctoriii.vb" id="Snippet2"::: @@ -342,7 +340,6 @@ The following example instantiates a object that represen ## Examples The following example creates several objects using the constructor overload that initializes a to a specified number of days, hours, minutes, and seconds. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Ctor/CPP/ctoriiii.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/.ctor/ctoriiii.cs" interactive="try-dotnet" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/.ctor/ctoriiii.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.Ctor/VB/ctoriiii.vb" id="Snippet3"::: @@ -414,7 +411,6 @@ The following example instantiates a object that represen ## Examples The following example creates several objects using the constructor overload that initializes a to a specified number of days, hours, minutes, seconds, and milliseconds. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Ctor/CPP/ctoriiiii.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/.ctor/ctoriiiii.cs" interactive="try-dotnet" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/.ctor/ctoriiiii.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.Ctor/VB/ctoriiiii.vb" id="Snippet4"::: @@ -726,7 +722,6 @@ The specified `days`, `hours`, `minutes`, `seconds`, `milliseconds`, and `micros ## Examples The following example compares several structures and other objects to a reference structure using the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Compare_Equals/CPP/cto_eq_obj.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/CompareTo/cto_eq_obj.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/CompareTo/cto_eq_obj.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.Compare_Equals/VB/cto_eq_obj.vb" id="Snippet1"::: @@ -817,7 +812,6 @@ The specified `days`, `hours`, `minutes`, `seconds`, `milliseconds`, and `micros ## Examples The following example demonstrates generic and nongeneric versions of the method for several value and reference types. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/T.CompareTo/CPP/cat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Boolean/CompareTo/cat.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Boolean/CompareTo/cat.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/T.CompareTo/VB/cat.vb" id="Snippet1"::: @@ -881,7 +875,6 @@ The specified `days`, `hours`, `minutes`, `seconds`, `milliseconds`, and `micros ## Examples The following example creates several objects and displays the property of each. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Properties/CPP/properties.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/Days/properties.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/Days/properties.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.Properties/VB/properties.vb" id="Snippet1"::: @@ -1025,7 +1018,6 @@ The specified `days`, `hours`, `minutes`, `seconds`, `milliseconds`, and `micros ## Examples The following example applies the method to several objects. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Dura_Nega_Unary/CPP/dura_nega_una.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/Duration/dura_nega_una.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/Duration/dura_nega_una.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.Dura_Nega_Unary/VB/dura_nega_una.vb" id="Snippet1"::: @@ -1110,7 +1102,6 @@ The specified `days`, `hours`, `minutes`, `seconds`, `milliseconds`, and `micros ## Examples The following example compares several and other objects to a reference using the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Compare_Equals/CPP/cto_eq_obj.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/CompareTo/cto_eq_obj.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/CompareTo/cto_eq_obj.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.Compare_Equals/VB/cto_eq_obj.vb" id="Snippet1"::: @@ -1182,7 +1173,6 @@ The specified `days`, `hours`, `minutes`, `seconds`, `milliseconds`, and `micros ## Examples The following example demonstrates generic and nongeneric versions of the method for several value and reference types. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/T.CompareTo/CPP/cat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Boolean/CompareTo/cat.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Boolean/CompareTo/cat.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/T.CompareTo/VB/cat.vb" id="Snippet1"::: @@ -1248,7 +1238,6 @@ The specified `days`, `hours`, `minutes`, `seconds`, `milliseconds`, and `micros ## Examples The following example compares several objects to a reference object using the static method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Compare_Equals/CPP/comp_equal.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/CompareTo/comp_equal.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/CompareTo/comp_equal.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.Compare_Equals/VB/comp_equal.vb" id="Snippet2"::: @@ -1321,7 +1310,6 @@ The specified `days`, `hours`, `minutes`, `seconds`, `milliseconds`, and `micros ## Examples The following example creates several objects using the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.From/CPP/fromdays.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/FromDays/fromdays.cs" interactive="try-dotnet" id="Snippet6"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/FromDays/fromdays.fs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.From/VB/fromdays.vb" id="Snippet6"::: @@ -1484,7 +1472,6 @@ The specified `days`, `hours`, `minutes`, `seconds`, `milliseconds`, and `micros ## Examples The following example creates several objects using the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.From/CPP/fromhours.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/FromDays/fromhours.cs" interactive="try-dotnet" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/FromDays/fromhours.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.From/VB/fromhours.vb" id="Snippet5"::: @@ -1724,7 +1711,6 @@ The specified `days`, `hours`, `minutes`, `seconds`, `milliseconds`, and `micros ## Examples The following example creates several objects by using the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.From/CPP/frommillisec.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/FromDays/frommillisec.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/FromDays/frommillisec.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.From/VB/frommillisec.vb" id="Snippet2"::: @@ -1880,7 +1866,6 @@ The specified `days`, `hours`, `minutes`, `seconds`, `milliseconds`, and `micros ## Examples The following example creates several objects using the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.From/CPP/fromminutes.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/FromDays/fromminutes.cs" interactive="try-dotnet" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/FromDays/fromminutes.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.From/VB/fromminutes.vb" id="Snippet4"::: @@ -2039,7 +2024,6 @@ The specified `days`, `hours`, `minutes`, `seconds`, `milliseconds`, and `micros ## Examples The following example creates several objects using the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.From/CPP/fromseconds.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/FromDays/fromseconds.cs" interactive="try-dotnet" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/FromDays/fromseconds.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.From/VB/fromseconds.vb" id="Snippet3"::: @@ -2198,7 +2182,6 @@ The specified `days`, `hours`, `minutes`, `seconds`, `milliseconds`, and `micros ## Examples The following example creates several objects using the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.From/CPP/fromticks.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/FromDays/fromticks.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/FromDays/fromticks.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.From/VB/fromticks.vb" id="Snippet1"::: @@ -2267,7 +2250,6 @@ The specified `days`, `hours`, `minutes`, `seconds`, `milliseconds`, and `micros ## Examples The following example generates the hash codes of several objects using the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.GetHashCode/CPP/hashcode.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/GetHashCode/hashcode.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/GetHashCode/hashcode.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.GetHashCode/VB/hashcode.vb" id="Snippet1"::: @@ -2331,7 +2313,6 @@ The specified `days`, `hours`, `minutes`, `seconds`, `milliseconds`, and `micros ## Examples The following example creates several objects and displays the property of each. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Properties/CPP/properties.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/Days/properties.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/Days/properties.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.Properties/VB/properties.vb" id="Snippet1"::: @@ -2426,7 +2407,6 @@ The specified `days`, `hours`, `minutes`, `seconds`, `milliseconds`, and `micros ## Examples The following example references and displays the value of the field. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Fields/CPP/fields.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/MaxValue/fields.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/MaxValue/fields.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.Fields/VB/fields.vb" id="Snippet1"::: @@ -2671,7 +2651,6 @@ The property represents whole microseconds, ## Examples The following example creates several objects and displays the property of each. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Properties/CPP/properties.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/Days/properties.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/Days/properties.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.Properties/VB/properties.vb" id="Snippet1"::: @@ -2853,7 +2832,6 @@ The property represents whole microseconds, ## Examples The following example creates several objects and displays the property of each. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Properties/CPP/properties.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/Days/properties.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/Days/properties.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.Properties/VB/properties.vb" id="Snippet1"::: @@ -2976,7 +2954,6 @@ The property represents whole microseconds, ## Examples The following example references and displays the value of the field. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Fields/CPP/fields.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/MaxValue/fields.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/MaxValue/fields.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.Fields/VB/fields.vb" id="Snippet1"::: @@ -3153,7 +3130,6 @@ The value of this constant is 100. ## Examples The following example applies the method to several objects. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Dura_Nega_Unary/CPP/dura_nega_una.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/Duration/dura_nega_una.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/Duration/dura_nega_una.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.Dura_Nega_Unary/VB/dura_nega_una.vb" id="Snippet1"::: @@ -3374,7 +3350,6 @@ The value of this constant is 100. ## Examples The following example compares several objects to a reference using the operator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.RelationalOps/CPP/relationalops.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/op_Equality/relationalops.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/op_Equality/relationalops.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.RelationalOps/VB/relationalops.vb" id="Snippet1"::: @@ -3447,7 +3422,6 @@ The value of this constant is 100. ## Examples The following example compares several objects to a reference using the operator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.RelationalOps/CPP/relationalops.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/op_Equality/relationalops.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/op_Equality/relationalops.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.RelationalOps/VB/relationalops.vb" id="Snippet1"::: @@ -3519,7 +3493,6 @@ The value of this constant is 100. ## Examples The following example compares several objects to a reference using the operator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.RelationalOps/CPP/relationalops.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/op_Equality/relationalops.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/op_Equality/relationalops.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.RelationalOps/VB/relationalops.vb" id="Snippet1"::: @@ -3591,7 +3564,6 @@ The value of this constant is 100. ## Examples The following example compares several objects to a reference using the operator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.RelationalOps/CPP/relationalops.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/op_Equality/relationalops.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/op_Equality/relationalops.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.RelationalOps/VB/relationalops.vb" id="Snippet1"::: @@ -3663,7 +3635,6 @@ The value of this constant is 100. ## Examples The following example compares several objects to a reference using the operator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.RelationalOps/CPP/relationalops.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/op_Equality/relationalops.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/op_Equality/relationalops.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.RelationalOps/VB/relationalops.vb" id="Snippet1"::: @@ -3735,7 +3706,6 @@ The value of this constant is 100. ## Examples The following example compares several objects to a reference using the operator. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.RelationalOps/CPP/relationalops.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/op_Equality/relationalops.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/op_Equality/relationalops.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.RelationalOps/VB/relationalops.vb" id="Snippet1"::: @@ -3951,7 +3921,6 @@ The value of this constant is 100. ## Examples The following example applies the operator to several objects. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Dura_Nega_Unary/CPP/dura_nega_una.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/Duration/dura_nega_una.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/Duration/dura_nega_una.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.Dura_Nega_Unary/VB/dura_nega_una.vb" id="Snippet1"::: @@ -4013,7 +3982,6 @@ The value of this constant is 100. ## Examples The following example applies the operator to several objects. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Dura_Nega_Unary/CPP/dura_nega_una.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/Duration/dura_nega_una.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/Duration/dura_nega_una.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.Dura_Nega_Unary/VB/dura_nega_una.vb" id="Snippet1"::: @@ -4894,7 +4862,6 @@ The following example defines an array of objects and displays the property of each. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Properties/CPP/properties.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/Days/properties.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/Days/properties.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.Properties/VB/properties.vb" id="Snippet1"::: @@ -5161,7 +5128,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example creates several objects and displays the property of each. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Properties/CPP/properties.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/Days/properties.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/Days/properties.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.Properties/VB/properties.vb" id="Snippet1"::: @@ -5229,7 +5195,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example references and displays the value of the field. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Fields/CPP/fields.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/MaxValue/fields.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/MaxValue/fields.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.Fields/VB/fields.vb" id="Snippet1"::: @@ -5296,7 +5261,6 @@ This member is an explicit interface member implementation. It can be used only ## Examples The following example references and displays the value of the field. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Fields/CPP/fields.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/MaxValue/fields.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/MaxValue/fields.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.Fields/VB/fields.vb" id="Snippet1"::: @@ -5401,7 +5365,6 @@ The value of this constant is 10. ## Examples The following example references and displays the value of the field. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Fields/CPP/fields.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/MaxValue/fields.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/MaxValue/fields.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.Fields/VB/fields.vb" id="Snippet1"::: @@ -5468,7 +5431,6 @@ The value of this constant is 10. ## Examples The following example references and displays the value of the field. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Fields/CPP/fields.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/MaxValue/fields.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/MaxValue/fields.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.Fields/VB/fields.vb" id="Snippet1"::: @@ -5535,7 +5497,6 @@ The value of this constant is 10. ## Examples The following example references and displays the value of the field. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Fields/CPP/fields.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/MaxValue/fields.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/MaxValue/fields.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.Fields/VB/fields.vb" id="Snippet1"::: @@ -7390,7 +7351,6 @@ The following example defines an array of field. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeSpan.Fields/CPP/fields.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeSpan/MaxValue/fields.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeSpan/MaxValue/fields.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeSpan.Fields/VB/fields.vb" id="Snippet1"::: diff --git a/xml/System/TimeZone.xml b/xml/System/TimeZone.xml index 9e77ce7da08..bc340fb27f9 100644 --- a/xml/System/TimeZone.xml +++ b/xml/System/TimeZone.xml @@ -67,27 +67,24 @@ Represents a time zone. - [!IMPORTANT] -> Whenever possible, use the class instead of the class. - - You can use the class to retrieve information about the current time zone, and to convert times from local time to Coordinated Universal Time (UTC) or vice versa. However, you cannot use the class to represent time zones other than the local zone or to handle date and time conversions from one time zone to another. For this purpose, use the class. You can use this class to retrieve information on any time zone defined on the local system, to create custom time zones, and to convert times from one time zone to another. - - The class supports only a single daylight saving time adjustment rule for the local time zone. As a result, the class can accurately report daylight saving time information or convert between UTC and local time only for the period in which the latest adjustment rule is in effect. In contrast, the class supports multiple adjustment rules, which makes it possible to work with historic time zone data. - - - -## Examples - The following example references and displays selected `TimeZone` class elements. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeZone.Class/CPP/tzclass.cpp" id="Snippet1"::: +> Whenever possible, use the class instead of the class. + + You can use the class to retrieve information about the current time zone, and to convert times from local time to Coordinated Universal Time (UTC) or vice versa. However, you cannot use the class to represent time zones other than the local zone or to handle date and time conversions from one time zone to another. For this purpose, use the class. You can use this class to retrieve information on any time zone defined on the local system, to create custom time zones, and to convert times from one time zone to another. + + The class supports only a single daylight saving time adjustment rule for the local time zone. As a result, the class can accurately report daylight saving time information or convert between UTC and local time only for the period in which the latest adjustment rule is in effect. In contrast, the class supports multiple adjustment rules, which makes it possible to work with historic time zone data. + +## Examples + The following example references and displays selected `TimeZone` class elements. + :::code language="csharp" source="~/snippets/csharp/System/TimeZone/Overview/tzclass.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeZone.Class/VB/tzclass.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeZone.Class/VB/tzclass.vb" id="Snippet1"::: + ]]> @@ -174,20 +171,19 @@ Gets the time zone of the current computer. A object that represents the current local time zone. - property corresponds to the property. Whenever possible, use the property. - - - -## Examples - The following example references the `CurrentTimeZone` property and displays the names for standard time and daylight saving time for the local time zone. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeZone.Class/CPP/tzclass.cpp" id="Snippet1"::: + property corresponds to the property. Whenever possible, use the property. + + + +## Examples + The following example references the `CurrentTimeZone` property and displays the names for standard time and daylight saving time for the local time zone. + :::code language="csharp" source="~/snippets/csharp/System/TimeZone/Overview/tzclass.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeZone.Class/VB/tzclass.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeZone.Class/VB/tzclass.vb" id="Snippet1"::: + ]]> @@ -235,22 +231,21 @@ Gets the daylight saving time zone name. The daylight saving time zone name. - property corresponds to the property. Whenever possible, use the property. - - - -## Examples - The following example references and displays the `DaylightName` property of the current time zone. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeZone.Class/CPP/tzclass.cpp" id="Snippet1"::: + property corresponds to the property. Whenever possible, use the property. + + + +## Examples + The following example references and displays the `DaylightName` property of the current time zone. + :::code language="csharp" source="~/snippets/csharp/System/TimeZone/Overview/tzclass.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeZone.Class/VB/tzclass.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeZone.Class/VB/tzclass.vb" id="Snippet1"::: + ]]> @@ -299,13 +294,13 @@ Returns the daylight saving time period for a particular year. A object that contains the start and end date for daylight saving time in . - object, where the value of and is , and the value of is a initialized to 0 ticks. - + object, where the value of and is , and the value of is a initialized to 0 ticks. + ]]> @@ -359,24 +354,24 @@ Returns the Coordinated Universal Time (UTC) offset for the specified local time. The Coordinated Universal Time (UTC) offset from . - property. If the value of the property is or , the method returns the offset of the local time zone. If the value of the property is , the method returns an offset equal to . - - If the local time zone observes daylight saving time, applies the current adjustment rule to `time` when determining the offset of the local time zone. That is, the offset returned by reflects whether `time` falls in the time zone's standard time or its daylight saving time. - + property. If the value of the property is or , the method returns the offset of the local time zone. If the value of the property is , the method returns an offset equal to . + + If the local time zone observes daylight saving time, applies the current adjustment rule to `time` when determining the offset of the local time zone. That is, the offset returned by reflects whether `time` falls in the time zone's standard time or its daylight saving time. + > [!NOTE] -> The method recognizes only the current daylight saving time adjustment rule for the local time zone. As a result, it is guaranteed to accurately return the UTC offset of a local time only during the period in which the latest adjustment rule is in effect. It may return inaccurate results if `time` is a historic date and time value that was subject to a previous adjustment rule. - - The method corresponds to the method. Whenever possible, use the method. - - Because the date and time value represented by `time` and this value's offset from UTC are not tightly coupled, a local or unspecified date and time value can return a different offset value when run on different computers or when run on the same computer under different time zones. If this behavior is undesirable, use a value instead. The data type tightly couples a date and time value with its offset from UTC. - +> The method recognizes only the current daylight saving time adjustment rule for the local time zone. As a result, it is guaranteed to accurately return the UTC offset of a local time only during the period in which the latest adjustment rule is in effect. It may return inaccurate results if `time` is a historic date and time value that was subject to a previous adjustment rule. + + The method corresponds to the method. Whenever possible, use the method. + + Because the date and time value represented by `time` and this value's offset from UTC are not tightly coupled, a local or unspecified date and time value can return a different offset value when run on different computers or when run on the same computer under different time zones. If this behavior is undesirable, use a value instead. The data type tightly couples a date and time value with its offset from UTC. + ]]> @@ -436,13 +431,13 @@ if is in a daylight saving time period; otherwise, . - class supports a single daylight saving time adjustment rule, the method applies the current adjustment rule to any date, regardless of whether the adjustment rule was in effect on that date. Assuming that the operating system itself has accurate historic daylight saving time data, a more accurate result is available by using the method. Whenever possible, use the method. - + class supports a single daylight saving time adjustment rule, the method applies the current adjustment rule to any date, regardless of whether the adjustment rule was in effect on that date. Assuming that the operating system itself has accurate historic daylight saving time data, a more accurate result is available by using the method. Whenever possible, use the method. + ]]> @@ -494,11 +489,11 @@ if is in ; otherwise, . - method provides the same functionality as this overload of the method. Whenever possible, use the method. - + method provides the same functionality as this overload of the method. Whenever possible, use the method. + ]]> @@ -545,20 +540,19 @@ Gets the standard time zone name. The standard time zone name. - property corresponds to the property. Whenever possible, use the property. - - - -## Examples - The following example references and displays the `StandardName` property of the current time zone. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TimeZone.Class/CPP/tzclass.cpp" id="Snippet1"::: + property corresponds to the property. Whenever possible, use the property. + + + +## Examples + The following example references and displays the `StandardName` property of the current time zone. + :::code language="csharp" source="~/snippets/csharp/System/TimeZone/Overview/tzclass.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeZone.Class/VB/tzclass.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeZone.Class/VB/tzclass.vb" id="Snippet1"::: + ]]> An attempt was made to set this property to . @@ -608,31 +602,31 @@ Returns the local time that corresponds to a specified date and time value. A object whose value is the local time that corresponds to . - value returned by this method. - -|`time` parameter|Behavior|Return value| -|----------------------|--------------|------------------| -|A Coordinated Universal Time (UTC) time ().|Converts the time from UTC to the local time.|A object whose value is the local time that corresponds to `time`.| -|A local time ().|No conversion necessary.|The same value represented by the `time` parameter.| -|An unspecified time ().|Assumes that the time is UTC and converts it from UTC to the local time.|A object whose value is the local time that corresponds to `time`.| - - If the local time zone observes daylight saving time, applies the current adjustment rule to `time` when performing the conversion. - + value returned by this method. + +|`time` parameter|Behavior|Return value| +|----------------------|--------------|------------------| +|A Coordinated Universal Time (UTC) time ().|Converts the time from UTC to the local time.|A object whose value is the local time that corresponds to `time`.| +|A local time ().|No conversion necessary.|The same value represented by the `time` parameter.| +|An unspecified time ().|Assumes that the time is UTC and converts it from UTC to the local time.|A object whose value is the local time that corresponds to `time`.| + + If the local time zone observes daylight saving time, applies the current adjustment rule to `time` when performing the conversion. + > [!NOTE] -> The method recognizes only the current daylight saving time adjustment rule for the local time zone. As a result, it is guaranteed to accurately return the local time corresponding to a particular UTC time only during the period in which the latest adjustment rule is in effect. It may return inaccurate results if `time` is a historic date and time value that was subject to a previous adjustment rule. - - The method corresponds to the method with its `destinationTimeZone` parameter set to . Whenever possible, use the method. - +> The method recognizes only the current daylight saving time adjustment rule for the local time zone. As a result, it is guaranteed to accurately return the local time corresponding to a particular UTC time only during the period in which the latest adjustment rule is in effect. It may return inaccurate results if `time` is a historic date and time value that was subject to a previous adjustment rule. + + The method corresponds to the method with its `destinationTimeZone` parameter set to . Whenever possible, use the method. + ]]> - Although it is not required, in most cases derived classes running under the .NET Framework version 2.0 should override the default implementation of this method. In the .NET Framework versions 1.0 and 1.1, the method called the method and adjusted for daylight saving time when returning the local time. However, starting with the .NET Framework 2.0, the behavior of the default implementation depends on the property of the parameter. If its value is , this method returns unchanged. If its value is either or , this method assumes is UTC and converts it to the local system time without calling the method. - - The following code provides a simple override of the default implementation of the method. In this code, the variable represents a private instance of the class: - + Although it is not required, in most cases derived classes running under the .NET Framework version 2.0 should override the default implementation of this method. In the .NET Framework versions 1.0 and 1.1, the method called the method and adjusted for daylight saving time when returning the local time. However, starting with the .NET Framework 2.0, the behavior of the default implementation depends on the property of the parameter. If its value is , this method returns unchanged. If its value is either or , this method assumes is UTC and converts it to the local system time without calling the method. + + The following code provides a simple override of the default implementation of the method. In this code, the variable represents a private instance of the class: + :::code language="csharp" source="~/snippets/csharp/System/TimeZone/ToLocalTime/TimeZone_ToLocalTime.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TimeZone.ToLocalTime/VB/TimeZone_ToLocalTime.vb" id="Snippet1"::: @@ -682,20 +676,20 @@ Returns the Coordinated Universal Time (UTC) that corresponds to a specified time. A object whose value is the Coordinated Universal Time (UTC) that corresponds to . - applies the current adjustment rule to the `time` parameter when performing the conversion. - + applies the current adjustment rule to the `time` parameter when performing the conversion. + > [!NOTE] -> The method recognizes only the current daylight saving time adjustment rule for the local time zone. As a result, it is guaranteed to accurately return the Coordinated Universal Time (UTC) corresponding to a particular local time only during the period in which the latest adjustment rule is in effect. It may return inaccurate results if `time` is a historic date and time value that was subject to a previous adjustment rule. - - If the `time` parameter is an ambiguous time, the method assumes that it is a standard time. (An ambiguous time is one that can map either to a standard time or to a daylight saving time in the local time zone.) If `time` is an invalid time, the method simply subtracts the local time from the local time zone's UTC offset to return UTC. (An invalid time is one that does not exist because of the application of daylight saving time adjustment rules.) - - Because `time` is interpreted in relation to the current time zone on the current system, the date and time returned by this method can differ if an application is run on different computers or on the same computer with different time zones. For cases in which a date and time value must represent a single, unambiguous point in time, use a value to represent the local time. - - The method corresponds to the method overload with a parameter whose property does not equal . Whenever possible, use the method overload. - +> The method recognizes only the current daylight saving time adjustment rule for the local time zone. As a result, it is guaranteed to accurately return the Coordinated Universal Time (UTC) corresponding to a particular local time only during the period in which the latest adjustment rule is in effect. It may return inaccurate results if `time` is a historic date and time value that was subject to a previous adjustment rule. + + If the `time` parameter is an ambiguous time, the method assumes that it is a standard time. (An ambiguous time is one that can map either to a standard time or to a daylight saving time in the local time zone.) If `time` is an invalid time, the method simply subtracts the local time from the local time zone's UTC offset to return UTC. (An invalid time is one that does not exist because of the application of daylight saving time adjustment rules.) + + Because `time` is interpreted in relation to the current time zone on the current system, the date and time returned by this method can differ if an application is run on different computers or on the same computer with different time zones. For cases in which a date and time value must represent a single, unambiguous point in time, use a value to represent the local time. + + The method corresponds to the method overload with a parameter whose property does not equal . Whenever possible, use the method overload. + ]]> diff --git a/xml/System/TimeoutException.xml b/xml/System/TimeoutException.xml index a346fa5d0c3..20bcd483eb7 100644 --- a/xml/System/TimeoutException.xml +++ b/xml/System/TimeoutException.xml @@ -84,7 +84,6 @@ ## Examples The following code example demonstrates the use of in conjunction with members of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/TimeoutException.class/cpp/to.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TimeoutException/Overview/to.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/TimeoutException/Overview/to.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/TimeoutException.class/VB/to.vb" id="Snippet1"::: diff --git a/xml/System/Type.xml b/xml/System/Type.xml index b44d441489a..712ebc4b23c 100644 --- a/xml/System/Type.xml +++ b/xml/System/Type.xml @@ -99,7 +99,6 @@ To identify the overload signature, the code example creates a temporary array c The code example uses the to invoke the method on the string "Hello, World!", and displays the result. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Type/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/Overview/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/Overview/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Type/vb/source.vb" id="Snippet1"::: @@ -241,7 +240,7 @@ The code example uses the to invoke the object represents a constructed generic type, this property returns the assembly that contains the generic type definition. For example, suppose you create an assembly named MyGenerics.dll that contains the generic type definition `MyGenericStack` (`MyGenericStack(Of T)` in Visual Basic, `generic ref class MyGenericStack` in C++). If you create an instance of `MyGenericStack` (`MyGenericStack(Of Integer)` in Visual Basic) in another assembly, the property for the constructed type returns an object that represents MyGenerics.dll. + If the current object represents a constructed generic type, this property returns the assembly that contains the generic type definition. For example, suppose you create an assembly named MyGenerics.dll that contains the generic type definition `MyGenericStack` (`MyGenericStack(Of T)` in Visual Basic). If you create an instance of `MyGenericStack` (`MyGenericStack(Of Integer)` in Visual Basic) in another assembly, the property for the constructed type returns an object that represents MyGenerics.dll. Similarly, if the current object represents an unassigned generic parameter `T`, this property returns the assembly that contains the generic type that defines `T`. @@ -254,7 +253,6 @@ The code example uses the to invoke the represents a constructed generic type, the base type reflects the generic arguments. For example, consider the following declarations: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.type.basetype/cpp/remarks.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/BaseType/remarks.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/BaseType/remarks.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.type.basetype/vb/remarks.vb" id="Snippet1"::: @@ -524,7 +520,6 @@ TopNamespace.Sub\+Namespace.ContainingClass+NestedClass, MyAssembly, Version=1.3 ## Examples The following example demonstrates using the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/TestBaseType/CPP/testbasetype.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/BaseType/testbasetype.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/BaseType/testbasetype.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/TestBaseType/VB/testbasetype.vb" id="Snippet1"::: @@ -600,7 +595,6 @@ TopNamespace.Sub\+Namespace.ContainingClass+NestedClass, MyAssembly, Version=1.3 ## Examples The following example defines a generic class with two type parameters and then defines a second generic class that derives from the first class. The derived class's base class has two type arguments: the first is and the second is a type parameter of the derived type. The example displays information about these generic classes, including the positions reported by the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Type.HasUnboundGenericParameters/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/ContainsGenericParameters/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/ContainsGenericParameters/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Type.HasUnboundGenericParameters/VB/source.vb" id="Snippet1"::: @@ -684,7 +678,6 @@ TopNamespace.Sub\+Namespace.ContainingClass+NestedClass, MyAssembly, Version=1.3 ## Examples The following code example defines a class that has a generic method, assigns a type argument to the method, and invokes the resulting constructed generic method. It also displays information about the generic method definition and the constructed method. When displaying information about the type parameters of the generic method definition, in the `DisplayGenericMethodInfo` method, the example code shows the value of the property for the method's generic type parameter. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/MethodInfo.Generics/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/DeclaringMethod/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/DeclaringMethod/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/MethodInfo.Generics/VB/source.vb" id="Snippet1"::: @@ -759,7 +752,6 @@ TopNamespace.Sub\+Namespace.ContainingClass+NestedClass, MyAssembly, Version=1.3 If the current object represents a type parameter of a generic method, this property returns the type that contains the generic method definition. If the type is generic, the generic type definition is returned. That is, the following code returns the generic type definition of the generic class, which contains the generic method: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.type.declaringtype/cpp/remarks.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/DeclaringType/remarks.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/DeclaringType/remarks.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.type.declaringtype/vb/remarks.vb" id="Snippet1"::: @@ -777,7 +769,6 @@ TopNamespace.Sub\+Namespace.ContainingClass+NestedClass, MyAssembly, Version=1.3 ## Examples This example displays the declaring type of a method in a derived class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.DeclaringType Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/DeclaringType/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/DeclaringType/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Type.DeclaringType Example/VB/source.vb" id="Snippet1"::: @@ -865,7 +856,6 @@ TopNamespace.Sub\+Namespace.ContainingClass+NestedClass, MyAssembly, Version=1.3 ## Examples The following example gets the default binder from the `DefaultBinder` property, and invokes a member of MyClass by passing the `DefaultBinder` value as a parameter to . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_DefaultBinder/CPP/type_defaultbinder.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/DefaultBinder/type_defaultbinder.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/DefaultBinder/type_defaultbinder.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_DefaultBinder/VB/type_defaultbinder.vb" id="Snippet1"::: @@ -961,7 +951,6 @@ TopNamespace.Sub\+Namespace.ContainingClass+NestedClass, MyAssembly, Version=1.3 ## Examples The following code example shows the `EmptyTypes` field used in one of the `GetConstructor` methods to get a constructor that takes no parameters. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.EmptyTypes Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/EmptyTypes/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/EmptyTypes/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Type.EmptyTypes Example/VB/source.vb" id="Snippet1"::: @@ -1190,7 +1179,6 @@ TopNamespace.Sub\+Namespace.ContainingClass+NestedClass, MyAssembly, Version=1.3 ## Examples The following example gets the `FilterAttribute` delegate, passes it as a parameter to the method, and displays the specified members and their attributes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_FilterAttribute/CPP/type_filterattribute.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/FilterAttribute/type_filterattribute.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/FilterAttribute/type_filterattribute.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_FilterAttribute/VB/type_filterattribute.vb" id="Snippet1"::: @@ -1251,7 +1239,6 @@ TopNamespace.Sub\+Namespace.ContainingClass+NestedClass, MyAssembly, Version=1.3 ## Examples The following code example gets the methods associated with the user-defined `Application` type. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.FilterName Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/FilterName/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/FilterName/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Type.FilterName Example/VB/source.vb" id="Snippet1"::: @@ -1312,7 +1299,6 @@ TopNamespace.Sub\+Namespace.ContainingClass+NestedClass, MyAssembly, Version=1.3 ## Examples The following example gets the `MemberFilter` delegate, passes it as a parameter to the method, and displays the methods and their attributes of the `String` class that begin with the letter "c", disregarding the case. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_FilterNameIgnoreCase/CPP/type_filternameignorecase.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/FilterNameIgnoreCase/type_filternameignorecase.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/FilterNameIgnoreCase/type_filternameignorecase.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_FilterNameIgnoreCase/VB/type_filternameignorecase.vb" id="Snippet1"::: @@ -1406,7 +1392,6 @@ TopNamespace.Sub\+Namespace.ContainingClass+NestedClass, MyAssembly, Version=1.3 ## Examples The following example finds the specified interface implemented or inherited by the specified type, and then displays the interface names. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_FindInterfaces/CPP/type_findinterfaces.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/FindInterfaces/type_findinterfaces.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/FindInterfaces/type_findinterfaces.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_FindInterfaces/VB/type_findinterfaces.vb" id="Snippet1"::: @@ -1542,7 +1527,6 @@ The `filter` argument can be a custom delegate of type property and the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Type.GetGenericParameterConstraints/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GenericParameterAttributes/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GenericParameterAttributes/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Type.GetGenericParameterConstraints/VB/source.vb" id="Snippet1"::: @@ -1799,7 +1781,6 @@ The `filter` argument can be a custom delegate of type property, it's necessary to identify the generic type or method a type parameter belongs to. For example, consider the return value of the generic method `GetSomething` in the following code: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.type.genericparameterposition/cpp/remarks.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GenericParameterPosition/remarks.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GenericParameterPosition/remarks.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.type.genericparameterposition/vb/remarks.vb" id="Snippet1"::: @@ -1814,7 +1795,6 @@ The `filter` argument can be a custom delegate of type , and the second is a type parameter of the derived type. The example displays information about these generic classes, including the positions reported by the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Type.HasUnboundGenericParameters/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/ContainsGenericParameters/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/ContainsGenericParameters/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Type.HasUnboundGenericParameters/VB/source.vb" id="Snippet1"::: @@ -1943,7 +1923,6 @@ The `filter` argument can be a custom delegate of type object, and displays the constructor signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetConstructor/CPP/type_getconstructor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetConstructor/type_getconstructor.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetConstructor/type_getconstructor.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetConstructor/VB/type_getconstructor.vb" id="Snippet1"::: @@ -2282,7 +2260,6 @@ The `filter` argument can be a custom delegate of type object, and displays the constructor signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetConstructor2/CPP/type_getconstructor2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetConstructor/type_getconstructor2.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetConstructor/type_getconstructor2.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetConstructor2/VB/type_getconstructor2.vb" id="Snippet1"::: @@ -2445,7 +2422,6 @@ The `filter` argument can be a custom delegate of type object, and displays the constructor signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetConstructor3/CPP/type_getconstructor3.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetConstructor/type_getconstructor3.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetConstructor/type_getconstructor3.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetConstructor3/VB/type_getconstructor3.vb" id="Snippet1"::: @@ -2618,7 +2594,6 @@ The `filter` argument can be a custom delegate of type overload from a class that has two instance constructors and one static constructor. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.GetConstructors Example/CPP/source1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetConstructors/source1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetConstructors/source1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Type.GetConstructors Example/VB/source1.vb" id="Snippet1"::: @@ -2635,7 +2610,6 @@ False To find static constructors, use the overload, and pass it the combination (logical OR) of , , , , as shown in the following code example: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.GetConstructors Example/CPP/source2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetConstructors/source2.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetConstructors/source2.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Type.GetConstructors Example/VB/source2.vb" id="Snippet2"::: @@ -2923,7 +2897,6 @@ If the current represents a generic type parameter, the represents a generic type parameter, the represents a generic type parameter, the object and gets the event for a button class for the specified event. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetEvent/CPP/type_getevent.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetEvent/type_getevent.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetEvent/type_getevent.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetEvent/VB/type_getevent.vb" id="Snippet1"::: @@ -3465,7 +3436,6 @@ If the current represents a generic type parameter, the method to search a type for a public or non-public event named "Click" that is not `static` (`Shared` in Visual Basic). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/type_getevent1/CPP/type_getevent1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetEvent/type_getevent1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetEvent/type_getevent1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/type_getevent1/VB/type_getevent1.vb" id="Snippet1"::: @@ -3581,7 +3551,6 @@ If the current represents a generic type parameter, the represents a generic type parameter, the represents a generic type parameter, the object for the field, and displays the value of the field. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetField/CPP/type_getfield.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetField/type_getfield.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetField/type_getfield.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetField/VB/type_getfield.vb" id="Snippet1"::: @@ -3914,7 +3881,6 @@ If the current represents a generic type parameter, the object for the field that matches the specified binding flags, and displays the value of the field. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetField/CPP/type_getfield.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetField/type_getfield.cs" interactive="try-dotnet" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetField/type_getfield.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetField/VB/type_getfield.vb" id="Snippet2"::: @@ -4027,7 +3993,6 @@ If the current represents a generic type parameter, the method does ## Examples The following example shows a use of the `GetFields(BindingFlags)` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic MethodBase.Attributes Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetFields/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetFields/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic MethodBase.Attributes Example/VB/source.vb" id="Snippet1"::: @@ -4316,7 +4280,6 @@ In .NET 6 and earlier versions, the method does This code example is part of a larger example provided for the property. See the larger example for sample output. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsGenericTypeDefinition/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Type/IsGenericParameter/source.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/IsGenericParameter/source.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Type.IsGenericTypeDefinition/VB/source.vb" id="Snippet2"::: @@ -4381,7 +4344,6 @@ In .NET 6 and earlier versions, the method does ## Examples The following code example defines a generic type `Test` with two type parameters that have different constraints. When the program executes, the constraints are examined using the property and the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Type.GetGenericParameterConstraints/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GenericParameterAttributes/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GenericParameterAttributes/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Type.GetGenericParameterConstraints/VB/source.vb" id="Snippet1"::: @@ -4444,7 +4406,7 @@ In .NET 6 and earlier versions, the method does ` (expressed in C# syntax; `G(Of T)` in Visual Basic or `generic ref class G` in C++) you can construct and instantiate the type `G` (`G(Of Integer)` in Visual Basic). Given a object representing this constructed type, the method returns the generic type definition. + A generic type definition is a template from which other types can be constructed. For example, from the C# generic type definition `G`, you can construct and instantiate the type `G`. Given a object representing this constructed type, the method returns the generic type definition. If two constructed types are created from the same generic type definition, using the same type arguments, the method returns the same object for both types. @@ -4455,12 +4417,9 @@ In .NET 6 and earlier versions, the method does For a list of the invariant conditions for terms used in generic reflection, see the property remarks. - - ## Examples The following code example creates an instance of a constructed type by using ordinary instance creation and then uses the and methods to retrieve the constructed type and the generic type definition. This example uses the generic type; the constructed type represents a of `Test` objects with string keys. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Type.GetGenericTypeDefinition/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetGenericTypeDefinition/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetGenericTypeDefinition/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Type.GetGenericTypeDefinition/VB/source.vb" id="Snippet1"::: @@ -4539,7 +4498,6 @@ In .NET 6 and earlier versions, the method does ## Examples The following example displays the hash code of the `System.Windows.Forms.Button` class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetHashCode_GetFields/CPP/type_gethashcode_getfields.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetHashCode/type_gethashcode_getfields.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetHashCode/type_gethashcode_getfields.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetHashCode_GetFields/VB/type_gethashcode_getfields.vb" id="Snippet1"::: @@ -4643,7 +4601,6 @@ In .NET 6 and earlier versions, the method does The code example also demonstrates the method overload and the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetInterface/CPP/type_getinterface.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetInterface/type_getinterface.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetInterface/type_getinterface.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetInterface/VB/type_getinterface.vb" id="Snippet1"::: @@ -4747,7 +4704,6 @@ In .NET 6 and earlier versions, the method does The code example also demonstrates the method overload and the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetInterface/CPP/type_getinterface.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetInterface/type_getinterface.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetInterface/type_getinterface.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetInterface/VB/type_getinterface.vb" id="Snippet2"::: @@ -4930,7 +4886,6 @@ The current instance or argument is an open ge `vbc type_getinterfaces1.vb /r:System.Web.dll /r:System.dll` - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetInterfaces1/CPP/type_getinterfaces1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetInterfaces/type_getinterfaces1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetInterfaces/type_getinterfaces1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetInterfaces1/VB/type_getinterfaces1.vb" id="Snippet1"::: @@ -5047,7 +5002,6 @@ The current instance or argument is an open ge ## Examples The following example displays all the members of the `String` class that start with the letter C. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetMember/CPP/type_getmember.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetMember/type_getmember.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetMember/type_getmember.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetMember/VB/type_getmember.vb" id="Snippet1"::: @@ -5168,7 +5122,6 @@ The current instance or argument is an open ge ## Examples The following example displays all the public static members of the `myString` class that start with the letter C. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetMember/CPP/type_getmember.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetMember/type_getmember.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetMember/type_getmember.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetMember/VB/type_getmember.vb" id="Snippet2"::: @@ -5289,7 +5242,6 @@ The current instance or argument is an open ge ## Examples The following example displays all the methods of the `myString` class that start with the letter C. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetMember/CPP/type_getmember.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetMember/type_getmember.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetMember/type_getmember.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetMember/VB/type_getmember.vb" id="Snippet3"::: @@ -5412,7 +5364,6 @@ Members include properties, methods, constructors, fields, events, and nested ty ## Examples The following code example demonstrates how to use the method overload to collect information about all public members of a specified class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetMembers1/CPP/type_getmembers1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetMembers/type_getmembers1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetMembers/type_getmembers1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetMembers1/VB/type_getmembers1.vb" id="Snippet1"::: @@ -5529,7 +5480,6 @@ In .NET 6 and earlier versions, the method does ## Examples The following code example demonstrates how to use the method overload to collect information about all public instance members of a specified class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetMembers2/CPP/type_getmembers2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetMembers/type_getmembers2.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetMembers/type_getmembers2.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetMembers2/VB/type_getmembers2.vb" id="Snippet1"::: @@ -5694,7 +5644,6 @@ This method can be used to find a constructed generic member given a member from ## Examples The following example gets a method named `MethodA`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetMethod1/CPP/type_getmethod1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetMethod/type_getmethod1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetMethod/type_getmethod1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetMethod1/VB/type_getmethod1.vb" id="Snippet1"::: @@ -5828,7 +5777,6 @@ This method can be used to find a constructed generic member given a member from ## Examples The following example gets the method that matches the specified binding flags. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetMethod2/CPP/type_getmethod2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetMethod/type_getmethod2.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetMethod/type_getmethod2.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetMethod2/VB/type_getmethod2.vb" id="Snippet1"::: @@ -5937,7 +5885,6 @@ This method can be used to find a constructed generic member given a member from > [!NOTE] > The Visual C# 2005 example requires the `/unsafe` compiler option. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetMethod4/CPP/type_getmethod4.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetMethod/type_getmethod4.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetMethod/type_getmethod4.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetMethod4/VB/type_getmethod4.vb" id="Snippet1"::: @@ -6487,7 +6434,6 @@ One of the elements in the array is array is represents a type parameter in the definition ## Examples The following example creates a class with two public methods and one protected method, creates a `Type` object corresponding to `MyTypeClass`, gets all public and non-public methods, and displays their names. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetMethods2/CPP/type_getmethods2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetMethods/type_getmethods2.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetMethods2/VB/type_getmethods2.vb" id="Snippet1"::: @@ -7660,7 +7604,6 @@ If the current represents a type parameter in the definition ## Examples The following example defines a nested class and a `struct` in `MyClass`, and then obtains objects of the nested types using the type of `MyClass`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetNestedTypes/CPP/type_getnestedtypes.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetNestedTypes/type_getnestedtypes.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetNestedTypes/VB/type_getnestedtypes.vb" id="Snippet1"::: @@ -7762,7 +7705,6 @@ If the current represents a type parameter in the definition ## Examples The following example creates two nested public classes and two nested protected classes, and displays information for classes that match the specified binding constraints. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetNestedClassesAbs/CPP/type_getnestedclassesabs.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetNestedTypes/type_getnestedclassesabs.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetNestedClassesAbs/VB/type_getnestedclassesabs.vb" id="Snippet1"::: @@ -7919,7 +7861,6 @@ If the current represents a type parameter in the definition ## Examples The following example demonstrates the use of the `GetProperties` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetTypeCode/CPP/type_gettypecode.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetProperties/type_gettypecode.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetProperties/type_gettypecode.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetTypeCode/VB/type_gettypecode.vb" id="Snippet2"::: @@ -8028,7 +7969,6 @@ In .NET 6 and earlier versions, the method d ## Examples The following example defines a class named `PropertyClass` that includes six properties: two are public, one is private, one is protected, one is internal (`Friend` in Visual Basic), and one is protected internal (`Protected Friend` in Visual Basic). It then displays some basic property information (the property name and type, whether it's read/write, and the visibility of its `get` and `set` accessors) for the properties that match the specified binding constraints. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetProperties2/CPP/type_getproperties2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetProperties/type_getproperties2.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetProperties/type_getproperties2.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetProperties2/VB/type_getproperties2.vb" id="Snippet1"::: @@ -8121,7 +8061,6 @@ In .NET 6 and earlier versions, the method d is represented by the string "System.Nullable`1[System.Int32]". > [!NOTE] -> In C#, C++, and Visual Basic you can also get nullable types using type operators. For example, the nullable type is returned by `typeof(Nullable)` in C#, by `Nullable::typeid` in C++, and by `GetType(Nullable(Of Boolean))` in Visual Basic. +> You can also get nullable types using type operators. For example, the nullable type is returned by `typeof(Nullable)` in C# and by `GetType(Nullable(Of Boolean))` in Visual Basic. The following table shows the syntax you use with `GetType` for various types. @@ -9207,7 +9142,6 @@ Type.GetType("System.Collections.Generic.Dictionary`2[System.String,[MyType,MyAs ## Examples The following example retrieves the type of `System.Int32` and uses that type object to display the property of `System.Int32`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetType/CPP/type_gettype.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetType/type_gettype.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetType/type_gettype.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetType/VB/type_gettype.vb" id="Snippet1"::: @@ -9393,7 +9327,7 @@ Type.GetType("System.Collections.Generic.Dictionary`2[System.String,[MyType,MyAs Nullable types are a special case of generic types. For example, a nullable is represented by the string "System.Nullable`1[System.Int32]". > [!NOTE] -> In C#, C++, and Visual Basic you can also get nullable types using type operators. For example, the nullable type is returned by `typeof(Nullable)` in C#, by `Nullable::typeid` in C++, and by `GetType(Nullable(Of Boolean))` in Visual Basic. +> You can also get nullable types using type operators. For example, the nullable type is returned by `typeof(Nullable)` in C# and by `GetType(Nullable(Of Boolean))` in Visual Basic. The following table shows the syntax you use with `GetType` for various types. @@ -9420,7 +9354,6 @@ Type.GetType("System.Collections.Generic.Dictionary`2[System.String,[MyType,MyAs ## Examples The following example retrieves the type of `System.Int32` and uses that type object to display the property of `System.Int32`. If a type object refers to an assembly that does not exist, this example throws an exception. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetType/CPP/type_gettype.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetType/type_gettype.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetType/type_gettype.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetType/VB/type_gettype.vb" id="Snippet1"::: @@ -9629,7 +9562,7 @@ Type.GetType("System.Collections.Generic.Dictionary`2[System.String,[MyType,MyAs Nullable types are a special case of generic types. For example, a nullable is represented by the string "System.Nullable`1[System.Int32]". > [!NOTE] -> In C#, C++, and Visual Basic you can also get nullable types using type operators. For example, the nullable type is returned by `typeof(Nullable)` in C#, by `Nullable::typeid` in C++, and by `GetType(Nullable(Of Boolean))` in Visual Basic. +> You can also get nullable types using type operators. For example, the nullable type is returned by `typeof(Nullable)` in C# and by `GetType(Nullable(Of Boolean))` in Visual Basic. The following table shows the syntax you use with `GetType` for various types. @@ -10142,7 +10075,6 @@ Calling this method overload is the same as calling the method to list the types of the elements of an array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetTypeCode/CPP/type_gettypecode.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetProperties/type_gettypecode.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetProperties/type_gettypecode.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetTypeCode/VB/type_gettypecode.vb" id="Snippet3"::: @@ -10213,7 +10145,6 @@ Calling this method overload is the same as calling the enumeration can be used. In a decision block inside the `WriteObjectInfo` method, the of an parameter is examined, and an appropriate message is written to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TypeCode/CPP/iconvertible.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetTypeCode/iconvertible.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetTypeCode/iconvertible.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TypeCode/VB/iconvertible.vb" id="Snippet2"::: @@ -10739,7 +10670,6 @@ Calling this method overload is the same as calling the method to get a object from a provided by the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_GetTypeFromHandle/CPP/type_gettypefromhandle.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetTypeFromHandle/type_gettypefromhandle.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetTypeFromHandle/type_gettypefromhandle.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_GetTypeFromHandle/VB/type_gettypefromhandle.vb" id="Snippet1"::: @@ -10911,7 +10841,6 @@ Calling this method overload is the same as calling the structure using the `GUID` property of the `Type` class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_Guid/CPP/type_guid.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GUID/type_guid.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GUID/type_guid.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_Guid/VB/type_guid.vb" id="Snippet1"::: @@ -11291,7 +11216,6 @@ Calling this method overload is the same as calling the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_IsAutoLayout/CPP/type_isautolayout.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/IsAutoLayout/type_isautolayout.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/IsAutoLayout/type_isautolayout.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_IsAutoLayout/VB/type_isautolayout.vb" id="Snippet1"::: @@ -12762,7 +12680,6 @@ GetType(Array).IsAssignableFrom(type) ## Examples The following example demonstrates a use of the `IsByRef` property to check whether a specified type is passed by reference. The example defines the class `MyTypeDelegator`, which overrides the `HasElementTypeImpl` method. The main class checks for the `HasElementType` property and displays the element type. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_HasElementTypeImpl/CPP/type_haselementtypeimpl.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/HasElementTypeImpl/type_haselementtypeimpl.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/HasElementTypeImpl/type_haselementtypeimpl.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_HasElementTypeImpl/VB/type_haselementtypeimpl.vb" id="Snippet1"::: @@ -12921,7 +12838,6 @@ Byref-like structures are declared using `ref struct` keyword in C#. An instance ## Examples The following example creates an instance of a type and indicates whether the type is a class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_IsClass/CPP/type_isclass.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/IsClass/type_isclass.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/IsClass/type_isclass.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_IsClass/VB/type_isclass.vb" id="Snippet1"::: @@ -13155,7 +13071,6 @@ Byref-like structures are declared using `ref struct` keyword in C#. An instance ## Examples The following example demonstrates the `IsContextful`, , and properties of the class. It checks whether the given type can be hosted in the context, whether it can be marshaled by reference, and whether the type is a primitive data type. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_IsContextful/CPP/type_iscontextful.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/IsContextful/type_iscontextful.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/IsContextful/type_iscontextful.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_IsContextful/VB/type_iscontextful.vb" id="Snippet1"::: @@ -13218,7 +13133,6 @@ Byref-like structures are declared using `ref struct` keyword in C#. An instance ## Examples The following example demonstrates a use of the `IsContextfulImpl` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_IsContextfulImpl/CPP/type_iscontextfulimpl.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/IsContextfulImpl/type_iscontextfulimpl.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/IsContextfulImpl/type_iscontextfulimpl.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_IsContextfulImpl/VB/type_iscontextfulimpl.vb" id="Snippet1"::: @@ -13296,7 +13210,6 @@ Byref-like structures are declared using `ref struct` keyword in C#. An instance ## Examples The following example demonstrates how to use the `IsEnum` property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/TestIsEnum/CPP/TestIsEnum.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/IsEnum/testisenum.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/IsEnum/testisenum.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/TestIsEnum/VB/testisenum.vb" id="Snippet1"::: @@ -13623,7 +13536,6 @@ Byref-like structures are declared using `ref struct` keyword in C#. An instance ## Examples The following example uses the property to test for generic type parameters in a generic type. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsGenericParameter/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetGenericArguments/source.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/GetGenericArguments/source.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Type.IsGenericParameter/VB/source.vb" id="Snippet2"::: @@ -13698,7 +13610,6 @@ Byref-like structures are declared using `ref struct` keyword in C#. An instance The following code example and table illustrate some of these terms and invariants. The `Derived` class is of particular interest because its base type is a constructed type that has a mixture of types and type parameters in its type argument list. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsGenericType/cpp/remarks.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Type/IsGenericType/remarks.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/IsGenericType/remarks.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Type.IsGenericType/vb/remarks.vb" id="Snippet2"::: @@ -13719,7 +13630,6 @@ Byref-like structures are declared using `ref struct` keyword in C#. An instance ## Examples The following code example displays the value of the , , , and properties for the types described in the Remarks section. For explanations of the property values, see the accompanying table in Remarks. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsGenericType/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/IsGenericType/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/IsGenericType/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Type.IsGenericType/vb/source.vb" id="Snippet1"::: @@ -13774,7 +13684,7 @@ Byref-like structures are declared using `ref struct` keyword in C#. An instance ` (expressed in C# syntax; `G(Of T)` in Visual Basic or `generic ref class G` in C++) you can construct and instantiate the type `G` (`G(Of Integer)` in Visual Basic), by calling the method with a generic argument list containing the type. Given a object representing this constructed type, the method gets the generic type definition back again. + A generic type definition is a template from which other types can be constructed. For example, from the C# generic type definition `G`, you can construct and instantiate the type `G` (`G(Of Integer)` in Visual Basic), by calling the method with a generic argument list containing the type. Given a object representing this constructed type, the method gets the generic type definition back again. Use the property to determine whether you can create new types from the current type. If the property returns `true`, you can call the method to create new generic types. @@ -13785,7 +13695,6 @@ Byref-like structures are declared using `ref struct` keyword in C#. An instance ## Examples The following example displays information about a type, including whether or not it's a generic type definition. Information is displayed for a constructed type, for its generic type definition, and for an ordinary type. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Type.IsGenericTypeDefinition/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/IsGenericParameter/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/IsGenericParameter/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Type.IsGenericTypeDefinition/VB/source.vb" id="Snippet1"::: @@ -13963,7 +13872,6 @@ Byref-like structures are declared using `ref struct` keyword in C#. An instance ## Examples The following example demonstrates the use of the `IsInstanceOfType` method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/TestIsInstanceOfType/CPP/testisinstanceoftype.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/IsInstanceOfType/testisinstanceoftype.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/IsInstanceOfType/testisinstanceoftype.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/TestIsInstanceOfType/VB/testisinstanceoftype.vb" id="Snippet1"::: @@ -14035,7 +13943,6 @@ Byref-like structures are declared using `ref struct` keyword in C#. An instance ## Examples The following example creates an interface, checks for the interface type, and indicates whether a class has the `IsInterface` property set. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_IsInterface/CPP/type_isinterface.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/IsInterface/type_isinterface.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/IsInterface/type_isinterface.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_IsInterface/VB/type_isinterface.vb" id="Snippet1"::: @@ -14109,7 +14016,6 @@ Byref-like structures are declared using `ref struct` keyword in C#. An instance ## Examples The following example creates an instance of a class for which the enumeration value in the class has been set, checks for the property, and displays the result. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_IsLayoutSequential/CPP/type_islayoutsequential.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/IsLayoutSequential/type_islayoutsequential.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/IsLayoutSequential/type_islayoutsequential.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_IsLayoutSequential/VB/type_islayoutsequential.vb" id="Snippet1"::: @@ -14170,7 +14076,6 @@ Byref-like structures are declared using `ref struct` keyword in C#. An instance ## Examples The following example demonstrates the , `IsMarshalByRef`, and properties of the class. It checks whether the given type can be hosted in the context, whether it can be marshaled by reference, and whether the type is a primitive data type. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_IsContextful/CPP/type_iscontextful.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/IsContextful/type_iscontextful.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/IsContextful/type_iscontextful.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_IsContextful/VB/type_iscontextful.vb" id="Snippet1"::: @@ -14231,7 +14136,6 @@ Byref-like structures are declared using `ref struct` keyword in C#. An instance ## Examples The following example determines whether the given type is marshaled by reference and displays the result. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_IsMarshalByRefImpl/CPP/type_ismarshalbyrefimpl.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/IsMarshalByRefImpl/type_ismarshalbyrefimpl.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/IsMarshalByRefImpl/type_ismarshalbyrefimpl.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_IsMarshalByRefImpl/VB/type_ismarshalbyrefimpl.vb" id="Snippet1"::: @@ -14766,14 +14670,12 @@ Byref-like structures are declared using `ref struct` keyword in C#. An instance ## Examples This example uses the `IsNotPublic` property to get the visibility of the type. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.IsNotPublic Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/IsNotPublic/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/IsNotPublic/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Type.IsNotPublic Example/VB/source.vb" id="Snippet1"::: The following code example demonstrates why you cannot use `IsPublic` and `IsNotPublic` for nested classes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.IsNotPublic Example/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Type/IsNotPublic/source.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/IsNotPublic/source.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Type.IsNotPublic Example/VB/source.vb" id="Snippet2"::: @@ -14853,7 +14755,6 @@ Byref-like structures are declared using `ref struct` keyword in C#. An instance ## Examples The following example shows a use of the `IsPointer` property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_HasElementTypeImpl/CPP/type_haselementtypeimpl.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/HasElementTypeImpl/type_haselementtypeimpl.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/HasElementTypeImpl/type_haselementtypeimpl.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_HasElementTypeImpl/VB/type_haselementtypeimpl.vb" id="Snippet1"::: @@ -14962,7 +14863,6 @@ Byref-like structures are declared using `ref struct` keyword in C#. An instance ## Examples The following example demonstrates the , , and `IsPrimitive` properties of the class. It checks whether the given type can be hosted in the context, whether it can be marshaled by reference, and whether the type is a primitive data type. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_IsContextful/CPP/type_iscontextful.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/IsContextful/type_iscontextful.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/IsContextful/type_iscontextful.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_IsContextful/VB/type_iscontextful.vb" id="Snippet1"::: @@ -15035,7 +14935,6 @@ Byref-like structures are declared using `ref struct` keyword in C#. An instance ## Examples The following example determines whether the given type is a primitive type and displays the result. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_IsPrimitiveImpl/CPP/type_isprimitiveimpl.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/IsPrimitiveImpl/type_isprimitiveimpl.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/IsPrimitiveImpl/type_isprimitiveimpl.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_IsPrimitiveImpl/VB/type_isprimitiveimpl.vb" id="Snippet1"::: @@ -15120,7 +15019,6 @@ Byref-like structures are declared using `ref struct` keyword in C#. An instance ## Examples The following example creates an instance of `MyTestClass`, checks for the `IsPublic` property, and displays the result. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type.IsPublic/CPP/type_ispublic.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/IsPublic/type_ispublic.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/IsPublic/type_ispublic.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type.IsPublic/VB/type_ispublic.vb" id="Snippet1"::: @@ -15185,7 +15083,6 @@ Byref-like structures are declared using `ref struct` keyword in C#. An instance ## Examples The following example creates an instance of a `sealed` class, checks for the `IsSealed` property, and displays the result. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_IsSealed/CPP/type_issealed.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/IsSealed/type_issealed.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/IsSealed/type_issealed.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_IsSealed/VB/type_issealed.vb" id="Snippet1"::: @@ -15446,7 +15343,6 @@ Types that are defined in the .NET Standard are not marked with method to create a constructed type from the generic type definition for the type. The constructed type represents a of `Test` objects with string keys. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Type.BindGenericParameters/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/MakeGenericType/source.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/MakeGenericType/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Type.BindGenericParameters/VB/source.vb" id="Snippet1"::: @@ -16568,7 +16459,6 @@ The following example uses the method to c ## Examples The following code example creates array, `ref` (`ByRef` in Visual Basic), and pointer types for the `Test` class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Type.MakeXxxType/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/MakeByRefType/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/MakeByRefType/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Type.MakeXxxType/VB/source.vb" id="Snippet1"::: @@ -16641,7 +16531,6 @@ The following example uses the method to c ## Examples The following code example shows the `MemberType` field as a parameter to the `GetMember` method: - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.MemberType Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/MemberType/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/MemberType/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Type.MemberType Example/VB/source.vb" id="Snippet1"::: @@ -16703,7 +16592,6 @@ The following example uses the method to c ## Examples The following code example shows the use of the `Missing` field to invoke a method with its default arguments. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.Missing Example/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/Missing/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/Missing/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Type.Missing Example/VB/source.vb" id="Snippet1"::: @@ -16775,7 +16663,6 @@ The following example uses the method to c ## Examples This following example demonstrates a use of the and `Module` properties and the method of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_ToString/CPP/type_tostring.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/Module/type_tostring.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/Module/type_tostring.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_ToString/VB/type_tostring.vb" id="Snippet1"::: @@ -16882,7 +16769,6 @@ The following example uses the method to c ## Examples This following example demonstrates a use of the `Namespace` and properties and the method of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_ToString/CPP/type_tostring.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/Module/type_tostring.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/Module/type_tostring.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_ToString/VB/type_tostring.vb" id="Snippet1"::: @@ -17060,7 +16946,6 @@ The following example uses the method to c ## Examples This example displays the reflected type of a nested class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic Type.ReflectedType Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/ReflectedType/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/ReflectedType/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic Type.ReflectedType Example/VB/source.vb" id="Snippet1"::: @@ -17254,7 +17139,6 @@ The following example uses the method to c ## Examples The following code example first defines a class, a structure, and a structure with special layout attributes (the structures are nested within the class). The example then uses the property to obtain a for each type, and displays the properties of the attributes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type.StructLayoutAttribute/CPP/Type.StructLayoutAttribute.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/StructLayoutAttribute/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/StructLayoutAttribute/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type.StructLayoutAttribute/VB/source.vb" id="Snippet1"::: @@ -17522,7 +17406,6 @@ The following example uses the method to c ## Examples This following example demonstrates a use of the and properties and the `ToString` method of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_ToString/CPP/type_tostring.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/Module/type_tostring.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/Module/type_tostring.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_ToString/VB/type_tostring.vb" id="Snippet1"::: @@ -17597,7 +17480,6 @@ The following example uses the method to c ## Examples The following example returns the handle of the corresponding type and passes the handle to a method that gets the type from the handle and displays it. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Type_TypeHandle/CPP/type_typehandle.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Type/TypeHandle/type_typehandle.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Type/TypeHandle/type_typehandle.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Type_TypeHandle/VB/type_typehandle.vb" id="Snippet1"::: diff --git a/xml/System/TypeCode.xml b/xml/System/TypeCode.xml index e7e63870615..79e2c45adf7 100644 --- a/xml/System/TypeCode.xml +++ b/xml/System/TypeCode.xml @@ -58,22 +58,21 @@ Specifies the type of an object. - method on classes that implement the interface to obtain the type code for an instance of that class. + + Otherwise, call an object's method to obtain its object, then call the `Type` object's method to obtain the object's type code. + + + +## Examples + The following code example demonstrates how the enumeration can be used. In a decision block inside the WriteObjectInfo method, the of an parameter is examined, and an appropriate message is written to the console. -## Remarks - Call the method on classes that implement the interface to obtain the type code for an instance of that class. - - Otherwise, call an object's method to obtain its object, then call the `Type` object's method to obtain the object's type code. - - - -## Examples - The following code example demonstrates how the enumeration can be used. In a decision block inside the WriteObjectInfo method, the of an parameter is examined, and an appropriate message is written to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.TypeCode/CPP/iconvertible.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Type/GetTypeCode/iconvertible.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TypeCode/VB/iconvertible.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.TypeCode/VB/iconvertible.vb" id="Snippet2"::: + ]]> diff --git a/xml/System/TypeLoadException.xml b/xml/System/TypeLoadException.xml index 97c0a9ca586..c1acc22de96 100644 --- a/xml/System/TypeLoadException.xml +++ b/xml/System/TypeLoadException.xml @@ -80,9 +80,9 @@ is thrown when the common language runtime cannot find the assembly, the type within the assembly, or cannot load the type. The property contains more detailed information that can help you identify the cause of the exception. + is thrown when the common language runtime cannot find the assembly or the type within the assembly, or cannot load the type. The property contains more detailed information that can help you identify the cause of the exception. - uses the HRESULT COR_E_TYPELOAD, that has the value 0x80131522. + uses the HRESULT COR_E_TYPELOAD, which has the value 0x80131522. For a list of initial property values for an instance of , see the constructors. @@ -223,7 +223,6 @@ The exact timing of when statically referenced types are loaded is unspecified. ## Examples The following code example demonstrates the constructor. It contains a method that generates a with a custom message, and displays the error message to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/TypeLoadException_Constructor2/CPP/typeloadexception_constructor2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TypeLoadException/.ctor/typeloadexception_constructor2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/TypeLoadException_Constructor2/VB/typeloadexception_constructor2.vb" id="Snippet1"::: @@ -296,7 +295,6 @@ The exact timing of when statically referenced types are loaded is unspecified. ## Examples The following example generates an exception, and serializes the exception data to a file, and then reconstitutes the exception. For this code example to run, you must provide the fully qualified assembly name. For information about how to obtain the fully qualified assembly name, see [Assembly Names](/dotnet/standard/assembly/names). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/TypeLoadException_GetObjectData/CPP/typeloadexception_getobjectdata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TypeLoadException/.ctor/typeloadexception_getobjectdata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/TypeLoadException_GetObjectData/VB/typeloadexception_getobjectdata.vb" id="Snippet1"::: @@ -369,7 +367,6 @@ The exact timing of when statically referenced types are loaded is unspecified. ## Examples The following code example demonstrates the constructor. It contains a method that generates a , catches that exception, and throws a new with a custom message, including the original as the inner exception. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/TypeLoadException_Constructor3/CPP/typeloadexception_constructor3.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TypeLoadException/.ctor/typeloadexception_constructor3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/TypeLoadException_Constructor3/VB/typeloadexception_constructor3.vb" id="Snippet1"::: @@ -453,7 +450,6 @@ The exact timing of when statically referenced types are loaded is unspecified. The following example generates an exception, and serializes the exception data to a file, and then reconstitutes the exception. For this code example to run, you must provide the fully qualified assembly name. For information about how to obtain the fully qualified assembly name, see [Assembly Names](/dotnet/standard/assembly/names). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/TypeLoadException_GetObjectData/CPP/typeloadexception_getobjectdata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TypeLoadException/.ctor/typeloadexception_getobjectdata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/TypeLoadException_GetObjectData/VB/typeloadexception_getobjectdata.vb" id="Snippet1"::: @@ -525,7 +521,6 @@ The exact timing of when statically referenced types are loaded is unspecified. ## Examples The following example attempts to load a non-existent type from the mscorlib assembly. The resulting exception is caught, and the and values are displayed. For this code example to run, you must provide the fully qualified assembly name. For information about how to obtain the fully qualified assembly name, see [Assembly Names](/dotnet/standard/assembly/names). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/TypeLoadException_TypeName/CPP/typeloadexception_typename.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TypeLoadException/Message/typeloadexception_typename.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/TypeLoadException_TypeName/VB/typeloadexception_typename.vb" id="Snippet1"::: @@ -581,7 +576,6 @@ The exact timing of when statically referenced types are loaded is unspecified. ## Examples The following example attempts to load a non-existent type from the mscorlib assembly. The resulting exception is caught, and the and values are displayed. For this code example to run, you must provide the fully qualified assembly name. For information about how to obtain the fully qualified assembly name, see [Assembly Names](/dotnet/standard/assembly/names). - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/TypeLoadException_TypeName/CPP/typeloadexception_typename.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/TypeLoadException/Message/typeloadexception_typename.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/TypeLoadException_TypeName/VB/typeloadexception_typename.vb" id="Snippet1"::: diff --git a/xml/System/UInt16.xml b/xml/System/UInt16.xml index db975025c06..9d7acbc6ba6 100644 --- a/xml/System/UInt16.xml +++ b/xml/System/UInt16.xml @@ -411,7 +411,6 @@ ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/UInt16 Example/CPP/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/UInt16/CompareTo/source.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/UInt16/CompareTo/source.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/UInt16 Example/VB/source.vb" id="Snippet3"::: @@ -506,7 +505,6 @@ ## Examples The following example demonstrates generic and nongeneric versions of the method for several value and reference types. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/T.CompareTo/CPP/cat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Boolean/CompareTo/cat.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Boolean/CompareTo/cat.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/T.CompareTo/VB/cat.vb" id="Snippet1"::: @@ -792,7 +790,6 @@ ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/UInt16_Equals/CPP/uint16_equals.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/UInt16/Equals/uint16_equals.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/UInt16/Equals/uint16_equals.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/UInt16_Equals/VB/uint16_equals.vb" id="Snippet1"::: diff --git a/xml/System/UInt32.xml b/xml/System/UInt32.xml index a2bb9dcf274..1ff9412de2d 100644 --- a/xml/System/UInt32.xml +++ b/xml/System/UInt32.xml @@ -445,7 +445,6 @@ ## Examples The following code example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/UInt32 Example/CPP/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/UInt32/CompareTo/source.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/UInt32/CompareTo/source.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/UInt32 Example/VB/source.vb" id="Snippet3"::: @@ -540,7 +539,6 @@ ## Examples The following code example demonstrates generic and nongeneric versions of the method for several value and reference types. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/T.CompareTo/CPP/cat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Boolean/CompareTo/cat.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Boolean/CompareTo/cat.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/T.CompareTo/VB/cat.vb" id="Snippet1"::: @@ -832,7 +830,6 @@ ## Examples The following code example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/UInt32_Equals/CPP/uint32_equals.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/UInt32/Equals/uint32_equals.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/UInt32/Equals/uint32_equals.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/UInt32_Equals/VB/uint32_equals.vb" id="Snippet1"::: @@ -1445,7 +1442,6 @@ For this method matches the IEEE 754:2 ## Examples The following example demonstrates how to use the field to display the smallest possible value of a variable. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/UInt32 Example/CPP/source.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/UInt32/CompareTo/source.cs" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/UInt32/CompareTo/source.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/UInt32 Example/VB/source.vb" id="Snippet2"::: diff --git a/xml/System/UInt64.xml b/xml/System/UInt64.xml index ea0fd2688c8..2b91e1ea13a 100644 --- a/xml/System/UInt64.xml +++ b/xml/System/UInt64.xml @@ -443,7 +443,6 @@ ## Examples The following code example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/UInt64 Example/CPP/source.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/UInt64/CompareTo/source.cs" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/UInt64/CompareTo/source.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/UInt64 Example/VB/source.vb" id="Snippet3"::: @@ -538,7 +537,6 @@ ## Examples The following code example demonstrates generic and nongeneric versions of the method for several value and reference types. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/T.CompareTo/CPP/cat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Boolean/CompareTo/cat.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Boolean/CompareTo/cat.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/T.CompareTo/VB/cat.vb" id="Snippet1"::: @@ -900,7 +898,6 @@ ## Examples The following example demonstrates the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/UInt64_Equals/CPP/uint64_equals.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/UInt64/Equals/uint64_equals.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/UInt64/Equals/uint64_equals.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/UInt64_Equals/VB/uint64_equals.vb" id="Snippet1"::: diff --git a/xml/System/UnhandledExceptionEventArgs.xml b/xml/System/UnhandledExceptionEventArgs.xml index ed1b0c95836..410b67c95c4 100644 --- a/xml/System/UnhandledExceptionEventArgs.xml +++ b/xml/System/UnhandledExceptionEventArgs.xml @@ -175,7 +175,6 @@ ## Examples The following example demonstrates the event. It defines an event handler, `MyHandler`, that is invoked whenever an unhandled exception is thrown in the default application domain. It then throws two exceptions. The first is handled by a **try/catch** block. The second is unhandled and invokes the `MyHandle` routine before the application terminates. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/AppDomain_UnhandledException/CPP/unhandledexception.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/AppDomain/UnhandledException/unhandledexception.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/AppDomain/UnhandledException/unhandledexception.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/AppDomain_UnhandledException/VB/unhandledexception.vb" id="Snippet1"::: diff --git a/xml/System/Uri.xml b/xml/System/Uri.xml index 6ddc0ee3c45..44207b6a580 100644 --- a/xml/System/Uri.xml +++ b/xml/System/Uri.xml @@ -104,7 +104,6 @@ class and uses it to perform a GET request with . -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic Uri Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/Overview/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/Overview/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic Uri Example/VB/source.vb" id="Snippet1"::: @@ -203,7 +202,6 @@ The following code snippet shows example values of the various properties on the ## Examples The following example creates a instance with the URI `http://www.contoso.com/`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/.ctor/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/.ctor/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic Uri.Uri Example/VB/source.vb" id="Snippet1"::: @@ -453,7 +451,6 @@ The following code snippet shows example values of the various properties on the ## Examples The following example creates a instance for the URI `http://www.contoso.com/Hello%20World.htm`. Because the contained URI is completely escaped and is in canonical form, the `dontEscape` parameter can be set to `true`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri1 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/.ctor/source1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/.ctor/source1.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic Uri.Uri1 Example/VB/source.vb" id="Snippet1"::: @@ -751,7 +748,6 @@ The following code snippet shows example values of the various properties on the ## Examples The following example creates a new instance of the class by combining the relative URIs `http://www.contoso.com` and `catalog/shownew.htm` to form the absolute URI `http://www.contoso.com/catalog/shownew.htm`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic Uri.Uri3 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/.ctor/source2.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/.ctor/source2.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic Uri.Uri3 Example/VB/source.vb" id="Snippet1"::: @@ -873,7 +869,6 @@ The following code snippet shows example values of the various properties on the ## Examples This example creates an absolute instance, `absoluteUri`, and a relative instance, `relativeUri`. A new instance, `combinedUri`, is then created from these two instances. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriEnhancements/CPP/nclurienhancements.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/.ctor/nclurienhancements.cs" interactive="try-dotnet-method" id="Snippet2"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/.ctor/nclurienhancements.fs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriEnhancements/VB/nclurienhancements.vb" id="Snippet2"::: @@ -1017,7 +1012,6 @@ The URI formed by combining and and and and and and instance from a string. It illustrates the difference between the value returned from , which returns the host name or address specified in the URI, and the value returned from , which returns an address that is safe to use in DNS resolution. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriEnhancements/CPP/nclurienhancements.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/.ctor/nclurienhancements.cs" interactive="try-dotnet-method" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/.ctor/nclurienhancements.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriEnhancements/VB/nclurienhancements.vb" id="Snippet4"::: @@ -1789,7 +1777,6 @@ If you used an escaped string to construct this instance (for example, `"http:// ## Examples This example creates two instances from strings and compares them to determine whether they represent the same value. `address1` and `address2` are the same because the portion is ignored for this comparison. The outcome is written to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" interactive="try-dotnet-method" id="Snippet8"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet8"::: @@ -2210,7 +2197,6 @@ If you used an escaped string to construct this instance (for example, `"http:// ## Examples The following example creates a instance and writes the fragment information to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" interactive="try-dotnet-method" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet4"::: @@ -2271,7 +2257,6 @@ If you used an escaped string to construct this instance (for example, `"http:// ## Examples The following example determines whether a character is a hexadecimal character and, if it is, writes the corresponding decimal value to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" interactive="try-dotnet-method" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet1"::: @@ -2400,7 +2385,6 @@ If you used an escaped string to construct this instance (for example, `"http:// ## Examples The following example creates a instance and writes the hash code to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" interactive="try-dotnet-method" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet4"::: @@ -2479,7 +2463,6 @@ The following examples show a URI and the results of calling instance and writes the path to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" interactive="try-dotnet-method" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet4"::: @@ -2583,7 +2566,6 @@ The following examples show a URI and the results of calling instance and writes the to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" interactive="try-dotnet-method" id="Snippet9"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet9"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet9"::: @@ -3016,7 +2995,6 @@ The following examples show a URI and the results of calling instance that represents a base instance. It then creates a second instance from a string. It calls to determine whether the base instance is the base of the second instance. The outcome is written to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriEnhancements/CPP/nclurienhancements.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/.ctor/nclurienhancements.cs" interactive="try-dotnet-method" id="Snippet6"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/.ctor/nclurienhancements.fs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriEnhancements/VB/nclurienhancements.vb" id="Snippet6"::: @@ -3076,7 +3054,6 @@ The following examples show a URI and the results of calling instance and checks whether it uses the default port. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" interactive="try-dotnet-method" id="Snippet4"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet4"::: @@ -3198,7 +3175,6 @@ The following examples show a URI and the results of calling instance and determines whether it is a file URI. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" id="Snippet6"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet6"::: @@ -3260,7 +3236,6 @@ The following examples show a URI and the results of calling instance and determines whether it references a local host. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" id="Snippet6"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet6"::: @@ -3506,7 +3479,6 @@ The following examples show a URI and the results of calling instance and determines whether it is a UNC path. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" interactive="try-dotnet-method" id="Snippet6"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet6"::: @@ -3727,7 +3699,6 @@ The following examples show a URI and the results of calling instance and writes the local path to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" id="Snippet6"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet6"::: @@ -3817,7 +3788,6 @@ The following examples show a URI and the results of calling instances. The difference in the path information is written to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" interactive="try-dotnet-method" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet3"::: @@ -3894,7 +3864,6 @@ The following examples show a URI and the results of calling instances. The difference in the path information is written to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" interactive="try-dotnet-method" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet3"::: @@ -3964,7 +3933,6 @@ The following examples show a URI and the results of calling instances from strings and compares them to determine whether they represent the same value. `Address1` and `Address2` are the same because the portion is ignored for this comparison. The outcome is written to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriEnhancements/CPP/nclurienhancements.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/.ctor/nclurienhancements.cs" interactive="try-dotnet-method" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/.ctor/nclurienhancements.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriEnhancements/VB/nclurienhancements.vb" id="Snippet5"::: @@ -4031,7 +3999,6 @@ The following examples show a URI and the results of calling instances from strings and compares them to determine whether they represent the same value. `Address2` and `Address3` are not the same because `Address3` contains a that is not found in `Address2`. The outcome is written to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriEnhancements/CPP/nclurienhancements.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/.ctor/nclurienhancements.cs" interactive="try-dotnet-method" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/.ctor/nclurienhancements.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriEnhancements/VB/nclurienhancements.vb" id="Snippet5"::: @@ -4098,7 +4065,6 @@ The following examples show a URI and the results of calling instance from a string. It illustrates the difference between the value returned from , which returns the string that was passed to the constructor, and from a call to , which returns the canonical form of the string. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriEnhancements/CPP/nclurienhancements.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/.ctor/nclurienhancements.cs" interactive="try-dotnet-method" id="Snippet3"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/.ctor/nclurienhancements.fs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriEnhancements/VB/nclurienhancements.vb" id="Snippet3"::: @@ -4218,7 +4184,6 @@ The following examples show a URI and the results of calling , , and an address. A instance is then created from the string. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet17"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" interactive="try-dotnet-method" id="Snippet17"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet17"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet17"::: @@ -4566,7 +4527,6 @@ The following examples show a URI and the results of calling instance with 3 segments and displays the segments on the screen. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" interactive="try-dotnet-method" id="Snippet5"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet5"::: @@ -4772,7 +4732,6 @@ The following examples show a URI and the results of calling instance from a string. It illustrates the difference between the value returned from , which returns the string that was passed to the constructor, and from a call to , which returns the canonical form of the string. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" interactive="try-dotnet-method" id="Snippet7"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet7"::: @@ -5398,7 +5357,6 @@ The following examples show a URI and the results of calling instance and determines whether the scheme is . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet10"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" interactive="try-dotnet-method" id="Snippet10"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet10"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet10"::: @@ -5450,7 +5408,6 @@ The following examples show a URI and the results of calling instance and determines whether the scheme is . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet15"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" interactive="try-dotnet-method" id="Snippet15"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet15"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet15"::: @@ -5532,7 +5489,6 @@ The following examples show a URI and the results of calling instance and determines whether the scheme is . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet14"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" interactive="try-dotnet-method" id="Snippet14"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet14"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet14"::: @@ -5584,7 +5540,6 @@ The following examples show a URI and the results of calling instance and determines whether the scheme is . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" interactive="try-dotnet-method" id="Snippet9"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet9"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet9"::: @@ -5636,7 +5591,6 @@ The following examples show a URI and the results of calling instance and determines whether the scheme is . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet16"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" interactive="try-dotnet-method" id="Snippet16"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet16"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet16"::: @@ -5688,7 +5642,6 @@ The following examples show a URI and the results of calling instance and determines whether the scheme is . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet11"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" interactive="try-dotnet-method" id="Snippet11"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet11"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet11"::: @@ -5818,7 +5771,6 @@ The following examples show a URI and the results of calling instance and determines whether the scheme is . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet12"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" interactive="try-dotnet-method" id="Snippet12"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet12"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet12"::: @@ -5873,7 +5825,6 @@ The following examples show a URI and the results of calling instance and determines whether the scheme is . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet13"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" interactive="try-dotnet-method" id="Snippet13"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet13"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet13"::: @@ -6084,7 +6035,6 @@ The following examples show a URI and the results of calling instance and determines whether it was fully escaped when it was created. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet18"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" interactive="try-dotnet-method" id="Snippet18"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet18"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet18"::: @@ -6144,7 +6094,6 @@ The following examples show a URI and the results of calling instance and writes the user information to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NCLUriExamples/CPP/uriexamples.cpp" id="Snippet18"::: :::code language="csharp" source="~/snippets/csharp/System/Uri/CheckSchemeName/uriexamples.cs" interactive="try-dotnet-method" id="Snippet18"::: :::code language="fsharp" source="~/snippets/fsharp/System/Uri/CheckSchemeName/uriexamples.fs" id="Snippet18"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLUriExamples/VB/uriexamples.vb" id="Snippet18"::: diff --git a/xml/System/UriBuilder.xml b/xml/System/UriBuilder.xml index bb7ea2b09d2..33c6b913197 100644 --- a/xml/System/UriBuilder.xml +++ b/xml/System/UriBuilder.xml @@ -64,13 +64,13 @@ Provides a custom constructor for uniform resource identifiers (URIs) and modifies URIs for the class. - class provides a convenient way to modify the contents of a instance without creating a new instance for each modification. - - The properties provide read/write access to the read-only properties so that they can be modified. - + class provides a convenient way to modify the contents of a instance without creating a new instance for each modification. + + The properties provide read/write access to the read-only properties so that they can be modified. + ]]> @@ -129,22 +129,22 @@ Initializes a new instance of the class. - class with its properties initialized as follows. - -|Property|Initial Value| -|--------------|-------------------| -|Fragment|| -|Host|"loopback"| -|Password|| -|Path|"/"| -|Port|-1| -|Query|| -|Scheme|"http"| -|UserName|| - + class with its properties initialized as follows. + +|Property|Initial Value| +|--------------|-------------------| +|Fragment|| +|Host|"loopback"| +|Password|| +|Path|"/"| +|Port|-1| +|Query|| +|Scheme|"http"| +|UserName|| + ]]> @@ -201,30 +201,30 @@ A URI string. Initializes a new instance of the class with the specified URI. - class with the , , , , , , and properties set as specified in `uri`. - - If `uri` does not specify a scheme, the scheme defaults to "http:". - + class with the , , , , , , and properties set as specified in `uri`. + + If `uri` does not specify a scheme, the scheme defaults to "http:". + ]]> is . - is a zero-length string or contains only spaces. - - -or- - - The parsing routine detected a scheme in an invalid form. - - -or- - - The parser detected more than two consecutive slashes in a URI that does not use the "file" scheme. - - -or- - + is a zero-length string or contains only spaces. + + -or- + + The parsing routine detected a scheme in an invalid form. + + -or- + + The parser detected more than two consecutive slashes in a URI that does not use the "file" scheme. + + -or- + is not a valid URI. Note: In .NET for Windows Store apps or the Portable Class Library, catch the base class exception, , instead. @@ -276,11 +276,11 @@ Note: In An instance of the class. Initializes a new instance of the class with the specified instance. - class with the , , , , , , and properties set as specified in `uri`. - + class with the , , , , , , and properties set as specified in `uri`. + ]]> @@ -335,19 +335,18 @@ Note: In A DNS-style domain name or IP address. Initializes a new instance of the class with the specified scheme and host. - instance is initialized with the property set to `schemeName` and the property set to `hostName`. is initialized to the value -1 to indicate the default port for the scheme should be used, and the property is set to the slash character (/). + +## Examples + The following example creates a instance that contains the URI `http://www.contoso.com/`. -## Examples - The following example creates a instance that contains the URI `http://www.contoso.com/`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder3 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/UriBuilder/.ctor/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/UriBuilder/.ctor/source.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder3 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder3 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -402,21 +401,20 @@ Note: In An IP port number for the service. Initializes a new instance of the class with the specified scheme, host, and port. - instance is initialized with the property set to `schemeName`, the property set to `hostName`, and the property set to `portNumber`. The property is set to the slash character (/). - + instance is initialized with the property set to `schemeName`, the property set to `hostName`, and the property set to `portNumber`. The property is set to the slash character (/). + If the `portNumber` is set to a value of -1, this indicates that the default port value for the scheme will be used to connect to the host. - -## Examples - The following example creates a instance that contains the URI `http://www.contoso.com:8080/`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder4 Example/CPP/source.cpp" id="Snippet1"::: + +## Examples + The following example creates a instance that contains the URI `http://www.contoso.com:8080/`. + :::code language="csharp" source="~/snippets/csharp/System/UriBuilder/.ctor/source1.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/UriBuilder/.ctor/source1.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder4 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder4 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -475,21 +473,20 @@ Note: In The path to the Internet resource. Initializes a new instance of the class with the specified scheme, host, port number, and path. - instance is initialized with the property set to `schemeName`, the property set to `hostName`, the property set to `portNumber`, and the property set to `pathValue`. - + instance is initialized with the property set to `schemeName`, the property set to `hostName`, the property set to `portNumber`, and the property set to `pathValue`. + If the `portNumber` is set to a value of -1, this indicates that the default port value for the scheme will be used to connect to the host. - -## Examples - The following example creates a instance that contains the URI `http://www.contoso.com:8080/index.htm`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder5 Example/CPP/source.cpp" id="Snippet1"::: + +## Examples + The following example creates a instance that contains the URI `http://www.contoso.com:8080/index.htm`. + :::code language="csharp" source="~/snippets/csharp/System/UriBuilder/.ctor/source2.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/UriBuilder/.ctor/source2.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder5 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder5 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -550,21 +547,20 @@ Note: In A query string or fragment identifier. Initializes a new instance of the class with the specified scheme, host, port number, path, and query string or fragment identifier. - instance is initialized with the property set to `schemeName`, the property set to `hostName`, the property set to `portNumber`, and the property set to `pathValue`. If `extraValue` begins with a number sign (#), then is set to `extraValue`. If `extraValue` begins with a question mark (?), then is set to `extraValue`. - + instance is initialized with the property set to `schemeName`, the property set to `hostName`, the property set to `portNumber`, and the property set to `pathValue`. If `extraValue` begins with a number sign (#), then is set to `extraValue`. If `extraValue` begins with a question mark (?), then is set to `extraValue`. + If the `portNumber` is set to a value of -1, this indicates that the default port value for the scheme will be used to connect to the host. - -## Examples - The following example creates a instance that contains the URI `http://www.contoso.com:8080/index.htm#top`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder6 Example/CPP/source.cpp" id="Snippet1"::: + +## Examples + The following example creates a instance that contains the URI `http://www.contoso.com:8080/index.htm#top`. + :::code language="csharp" source="~/snippets/csharp/System/UriBuilder/.ctor/source3.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/UriBuilder/.ctor/source3.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder6 Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic UriBuilder.UriBuilder6 Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -631,11 +627,11 @@ Note: In if represents the same as the constructed by this instance; otherwise, . - method compares a specified instance with the instance built by the instance. If the two are the same, the method returns `true`. - + method compares a specified instance with the instance built by the instance. If the two are the same, the method returns `true`. + ]]> @@ -691,8 +687,8 @@ Note: In property contains any text following a fragment marker (#) in the URI, including the marker itself. When setting the property: @@ -703,14 +699,13 @@ The property contains any text following a fra > [!NOTE] > To append a value to an existing fragment in .NET Framework, you must remove the leading fragment marker before setting the property with the new value. This is because .NET Framework always prepends the fragment marker when setting the property. .NET 5 (and .NET Core) and later versions are tolerant to a leading fragment marker, and will only prepend one if necessary. -## Examples - The following example creates the URI `"http://www.contoso.com/index.htm#main"`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic UriBuilder.Fragment Example/CPP/source.cpp" id="Snippet1"::: +## Examples + The following example creates the URI `"http://www.contoso.com/index.htm#main"`. + :::code language="csharp" source="~/snippets/csharp/System/UriBuilder/Fragment/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/UriBuilder/Fragment/source.fs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic UriBuilder.Fragment Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic UriBuilder.Fragment Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -761,15 +756,15 @@ The property contains any text following a fra Returns the hash code for the URI. The hash code generated for the URI. - A and B are guaranteed to be the same when A.Equals(B) is `true`. - - This method implements . - + A and B are guaranteed to be the same when A.Equals(B) is `true`. + + This method implements . + ]]> @@ -825,11 +820,11 @@ The property contains any text following a fra Gets or sets the Domain Name System (DNS) host name or IP address of a server. The DNS host name or IP address of the server. - property contains the fully qualified DNS host name or IP address of the server. - + property contains the fully qualified DNS host name or IP address of the server. + ]]> @@ -938,13 +933,13 @@ The property contains any text following a fra Gets or sets the path to the resource referenced by the URI. The path to the resource referenced by the URI. - property contains the path information that the server uses to resolve requests for information. Typically, this is the path to the desired information on the server's file system. It can also indicate the application or script that the server must run to provide the information. - - The path information does not include the scheme, host name, or query portion of the URI. The property always returns at least a slash (/). - + property contains the path information that the server uses to resolve requests for information. Typically, this is the path to the desired information on the server's file system. It can also indicate the application or script that the server must run to provide the information. + + The path information does not include the scheme, host name, or query portion of the URI. The property always returns at least a slash (/). + ]]> @@ -1000,11 +995,11 @@ The property contains any text following a fra Gets or sets the port number of the URI. The port number of the URI. - property returns the value of -1 to indicate that the default port value for the protocol scheme will be used to connect to the host. If the property is set to a value of -1, this indicates that the default port value for the protocol scheme will be used to connect to the host. - + property returns the value of -1 to indicate that the default port value for the protocol scheme will be used to connect to the host. If the property is set to a value of -1, this indicates that the default port value for the protocol scheme will be used to connect to the host. + ]]> The port cannot be set to a value less than -1 or greater than 65,535. @@ -1063,8 +1058,8 @@ The property contains any text following a fra Gets or sets any query information included in the URI, including the leading '?' character if not empty. The query information included in the URI. - property contains any query information included in the URI. Query information is separated from the path information by a question mark (?) and continues to the end of the URI. The query information that's returned includes the leading question mark. When setting the property: @@ -1072,7 +1067,7 @@ The property contains any query information included in - In .NET Framework, a question mark is always prepended to the string, even if the string already starts with a question mark. - In .NET 5 (and .NET Core) and later versions, a question mark is prepended to the string if it's not already present. -The query information is escaped according to RFC 2396. +The query information is escaped according to RFC 2396. > [!NOTE] > To append a value to existing query information in .NET Framework, you must remove the leading question mark before setting the property with the new value. This is because .NET Framework always prepends the question mark when setting the property. .NET 5 (and .NET Core) and later versions are tolerant to a leading question mark, and will only prepend one if necessary. @@ -1081,10 +1076,9 @@ The query information is escaped according to RFC 2396. The following example sets the property. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/UriBuilderSample/cpp/main.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/UriBuilder/Query/main.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/UriBuilder/Query/main.fs" id="Snippet1"::: - + ]]> @@ -1142,21 +1136,21 @@ The following example sets the property. Gets or sets the scheme name of the URI. The scheme of the URI. - property. - -|Scheme|Description| -|------------|-----------------| -|file|The resource is a file on the local computer.| -|ftp|The resource is accessed through FTP.| -|gopher|The resource is accessed through the Gopher protocol.| -|http|The resource is accessed through HTTP.| -|https|The resource is accessed through SSL-encrypted HTTP.| -|mailto|The resource is an email address and is accessed through SMTP.| -|news|The resource is accessed through NNTP.| - + property. + +|Scheme|Description| +|------------|-----------------| +|file|The resource is a file on the local computer.| +|ftp|The resource is accessed through FTP.| +|gopher|The resource is accessed through the Gopher protocol.| +|http|The resource is accessed through HTTP.| +|https|The resource is accessed through SSL-encrypted HTTP.| +|mailto|The resource is an email address and is accessed through SMTP.| +|news|The resource is accessed through NNTP.| + ]]> The scheme cannot be set to an invalid scheme name. @@ -1210,8 +1204,8 @@ The following example sets the property. Returns the display string for the specified instance. The string that contains the unescaped display string of the . - property value if one of the following conditions is true: @@ -1220,7 +1214,7 @@ The display string contains the property value if - The port was specified when the was constructed using one of the constructors that accept a port number parameter. In either case, the display string does not contain the property value if the port number was set to a value of -1 (for the default port). - + ]]> The instance has a bad password. @@ -1274,15 +1268,15 @@ Note: In instance constructed by the specified instance. The URI constructed by the . - property contains the created by the . Any changes made to the properties are reflected in the property. - + property contains the created by the . Any changes made to the properties are reflected in the property. + ]]> The URI constructed by the properties is invalid. - + Note: In .NET for Windows Store apps or the Portable Class Library, catch the base class exception, , instead. diff --git a/xml/System/ValueType.xml b/xml/System/ValueType.xml index 6ff1b0f168f..f26efe8b250 100644 --- a/xml/System/ValueType.xml +++ b/xml/System/ValueType.xml @@ -214,7 +214,6 @@ When you call the method on a Windows Runtime method can be overridden by a derived value type. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ValueType.Equals Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/ValueType/Equals/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/ValueType/Equals/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ValueType.Equals Example/VB/source.vb" id="Snippet1"::: @@ -288,7 +287,6 @@ When you call the method on a Windows Run method can be overridden by a derived value type. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ValueType.Equals Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/ValueType/Equals/source.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/ValueType/Equals/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ValueType.Equals Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System/Version.xml b/xml/System/Version.xml index 18f6a379d0b..e4f75803657 100644 --- a/xml/System/Version.xml +++ b/xml/System/Version.xml @@ -444,7 +444,6 @@ The following example uses the ## Examples The following code example demonstrates the constructor, and , , , , , and properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.version.revision/cpp/rev.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Version/.ctor/rev.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Version/.ctor/rev.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.version.revision/vb/rev.vb" id="Snippet1"::: @@ -508,7 +507,6 @@ The following example uses the ## Examples The following code example demonstrates the constructor, and , , , , , and properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.version.revision/cpp/rev.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Version/.ctor/rev.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Version/.ctor/rev.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.version.revision/vb/rev.vb" id="Snippet1"::: @@ -759,7 +757,6 @@ The following example uses the ## Examples The following code example demonstrates generic and nongeneric versions of the `CompareTo` method for several value and reference types. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/T.CompareTo/CPP/cat.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Boolean/CompareTo/cat.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Boolean/CompareTo/cat.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/T.CompareTo/VB/cat.vb" id="Snippet1"::: @@ -958,7 +955,6 @@ The following example uses the ## Examples The following code example demonstrates the constructor, and , , , , , and properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.version.revision/cpp/rev.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Version/.ctor/rev.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Version/.ctor/rev.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.version.revision/vb/rev.vb" id="Snippet1"::: @@ -1073,7 +1069,6 @@ The following example uses the ## Examples The following code example demonstrates the constructor, and the , , , , , and properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.version.revision/cpp/rev.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Version/.ctor/rev.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Version/.ctor/rev.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.version.revision/vb/rev.vb" id="Snippet1"::: @@ -1136,7 +1131,6 @@ The following example uses the ## Examples The following code example demonstrates the constructor, and , , , , , and properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.version.revision/cpp/rev.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Version/.ctor/rev.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Version/.ctor/rev.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.version.revision/vb/rev.vb" id="Snippet1"::: @@ -1197,7 +1191,6 @@ The following example uses the ## Examples The following code example demonstrates the constructor, and the , , , , , and properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.version.revision/cpp/rev.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Version/.ctor/rev.cs" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Version/.ctor/rev.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.version.revision/vb/rev.vb" id="Snippet1"::: @@ -1782,7 +1775,6 @@ where `major`, `minor`, `build`, and `revision` are the string representations o ## Examples The following code example demonstrates the constructor, and , , , , , and properties. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.version.revision/cpp/rev.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System/Version/.ctor/rev.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="fsharp" source="~/snippets/fsharp/System/Version/.ctor/rev.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.version.revision/vb/rev.vb" id="Snippet1"::: diff --git a/xml/ns-System.xml b/xml/ns-System.xml index 19a3a390e4c..9c8080c8870 100644 --- a/xml/ns-System.xml +++ b/xml/ns-System.xml @@ -1,6 +1,6 @@ - Contains fundamental classes and base classes that define commonly-used value and reference data types, events and event handlers, interfaces, attributes, and processing exceptions. + Contains fundamental classes and base classes that define commonly used value and reference data types, events and event handlers, interfaces, attributes, and processing exceptions.