This documentation is archived and is not being maintained.

XmlIncludeAttribute Constructor

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();
public __gc class Vehicle{};

public __gc class Car: public Vehicle{};

public __gc class Truck: public Vehicle{};

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

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

XNA Framework

Supported in: 3.0, 2.0, 1.0