XmlIncludeAttribute コンストラクタとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > XmlIncludeAttribute コンストラクタの意味・解説 

XmlIncludeAttribute コンストラクタ

XmlIncludeAttribute クラス新しインスタンス初期化します。

名前空間: System.Xml.Serialization
アセンブリ: System.Xml (system.xml.dll 内)
構文構文

Dim type As Type

Dim instance As New XmlIncludeAttribute(type)
public XmlIncludeAttribute (
    Type type
)
public:
XmlIncludeAttribute (
    Type^ type
)
public XmlIncludeAttribute (
    Type type
)
public function XmlIncludeAttribute (
    type : Type
)

パラメータ

type

含めオブジェクトType

使用例使用例

次の例では 3 つのクラスがあり、そのうち 2 つ3 番目のクラスから継承したクラスです。この例では、2 つのうちの 1 つ派生クラスインスタンス返すメソッドXmlIncludeAttribute適用します。Type プロパティには、返されるオブジェクトの型が設定されます。

public class Vehicle{}
 
public class Car:Vehicle{}
 
public class Truck:Vehicle{}
 
public class Sample
{
[WebMethodAttribute]
[XmlInclude(typeof(Car))]
[XmlInclude(typeof(Truck))]
public Vehicle ReturnVehicle(int i){
   if(i == 0)
      return new Car();
   else
      return new Truck();
   }
}   
public ref class Vehicle{};

public ref class Car: public
 Vehicle{};

public ref class Truck: public
 Vehicle{};

public ref class Sample
{
public:

   [WebMethodAttribute]
   [XmlInclude(Car::typeid)]
   [XmlInclude(Truck::typeid)]
   Vehicle^ ReturnVehicle( int i )
   {
      if ( i == 0 )
            return gcnew Car;
      else
            return gcnew Truck;
   }
};
public class Vehicle
{
} //Vehicle

public class Car extends Vehicle
{
} //Car

public class Truck extends Vehicle
{
} //Truck

public class Sample
{
    /** @attribute WebMethodAttribute()
     */
    /** @attribute XmlInclude(Car.class)
     */
    /** @attribute XmlInclude(Truck.class)
     */
    public Vehicle ReturnVehicle(int i)
    {
        if (i == 0) {
            return new Car();
        }
        else {
            return new Truck();
        }
    } //ReturnVehicle
} //Sample
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
XmlIncludeAttribute クラス
XmlIncludeAttribute メンバ
System.Xml.Serialization 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「XmlIncludeAttribute コンストラクタ」の関連用語

XmlIncludeAttribute コンストラクタのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



XmlIncludeAttribute コンストラクタのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS