XmlIncludeAttribute Constructor (Type)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Initializes a new instance of the XmlIncludeAttribute class.

Namespace:   System.Xml.Serialization
Assembly:  System.Xml (in System.Xml.dll)

public XmlIncludeAttribute(
	Type type


Type: System.Type

The Type of the object to include.

The following example shows three classes, two of which inherit from the third. The example applies the XmlIncludeAttribute to a method that returns an instance of one of the two derived classes. The example sets the Type property to the type of the returned object.

public class Vehicle{}

public class Car:Vehicle{}

public class Truck:Vehicle{}

public class Sample
public Vehicle ReturnVehicle(int i){
   if(i == 0)
      return new Car();
      return new Truck();

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top