The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
XmlSerializer::FromTypes Method (array<Type^>^)
.NET Framework (current version)
Returns an array of XmlSerializer objects created from an array of types.
Assembly: System.Xml (in System.Xml.dll)
Parameters
- types
-
Type:
array<System::Type^>^
An array of Type objects.
Return Value
Type: array<System.Xml.Serialization::XmlSerializer^>^An array of XmlSerializer objects.
The FromTypes method allows you to efficiently create an array of XmlSerializer objects for processing an array of Type objects.
The following example uses the FromTypes method to return an array of XmlSerializer objects. The code includes three class definitions that are each used to create an array of Type objects.
#using <System.Xml.dll> #using <System.dll> using namespace System; using namespace System::IO; using namespace System::Xml::Serialization; /* Three classes are included here. Each one will be used to create three XmlSerializer objects. */ public ref class Instrument { public: String^ InstrumentName; }; public ref class Player { public: String^ PlayerName; }; public ref class Piece { public: String^ PieceName; }; void GetSerializers() { // Create an array of types. array<Type^>^types = gcnew array<Type^>(3); types[ 0 ] = Instrument::typeid; types[ 1 ] = Player::typeid; types[ 2 ] = Piece::typeid; // Create an array for XmlSerializer objects. array<XmlSerializer^>^serializers = gcnew array<XmlSerializer^>(3); serializers = XmlSerializer::FromTypes( types ); // Create one Instrument and serialize it. Instrument^ i = gcnew Instrument; i->InstrumentName = "Piano"; // Create a TextWriter to write with. TextWriter^ writer = gcnew StreamWriter( "Inst.xml" ); serializers[ 0 ]->Serialize( writer, i ); writer->Close(); } int main() { GetSerializers(); }
Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Show: