TypeConverterAttributeとは? わかりやすく解説

TypeConverterAttribute クラス

この属性が関連付けられているオブジェクトのコンバータとして使用する型を指定します。このクラスは継承できません。

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

<AttributeUsageAttribute(AttributeTargets.All)> _
Public NotInheritable Class
 TypeConverterAttribute
    Inherits Attribute
Dim instance As TypeConverterAttribute
[AttributeUsageAttribute(AttributeTargets.All)] 
public sealed class TypeConverterAttribute
 : Attribute
[AttributeUsageAttribute(AttributeTargets::All)] 
public ref class TypeConverterAttribute sealed
 : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.All) */ 
public final class TypeConverterAttribute extends
 Attribute
AttributeUsageAttribute(AttributeTargets.All) 
public final class TypeConverterAttribute extends
 Attribute
解説解説
使用例使用例

MyClass に対して、MyClassConverter という名前の型コンバータを使用するように指示する例を次に示します。この例は、MyClassConverter が別の場所で実装されていることを前提にしています。コンバータ (MyClassConverter) を実装するクラスは、TypeConverter クラスから継承する必要があります。

<TypeConverter(GetType(MyClassConverter))> _
Public Class ClassA
    ' Insert code here.
End Class 'MyClass
[TypeConverter(typeof(MyClassConverter))]
 public class MyClass {
    // Insert code here.
 }
[TypeConverter(Class1::MyClassConverter::typeid)]
ref class MyClass{
   // Insert code here.
};
/** @attribute TypeConverter(MyClassConverter.class)
 */
public static class MyClass
{
    // Insert code here.
} //MyClass   

MyClass のインスタンスを作成する例を次に示します。そのクラスの属性を取得し、MyClass で使用する型コンバータの名前を出力します。

Public Shared Function Main()
 As Integer
    ' Creates a new instance of ClassA.
    Dim myNewClass As New
 ClassA()
    
    ' Gets the attributes for the instance.
    Dim attributes As AttributeCollection =
 TypeDescriptor.GetAttributes(myNewClass)
    
    ' Prints the name of the type converter by retrieving the
    ' TypeConverterAttribute from the AttributeCollection. 
    Dim myAttribute As TypeConverterAttribute
 = _
        CType(attributes(GetType(TypeConverterAttribute)), TypeConverterAttribute)
    
    Console.WriteLine(("The type conveter for this class is: "
 _
        + myAttribute.ConverterTypeName))
    Return 0
End Function 'Main
public static int Main()
 {
    // Creates a new instance of MyClass.
    MyClass myNewClass = new MyClass();
 
    // Gets the attributes for the instance.
    AttributeCollection attributes = TypeDescriptor.GetAttributes(myNewClass);
 
    /* Prints the name of the type converter by retrieving the 
     * TypeConverterAttribute from the AttributeCollection. */
    TypeConverterAttribute myAttribute = 
        (TypeConverterAttribute)attributes[typeof(TypeConverterAttribute)];
    
    Console.WriteLine("The type conveter for this
 class is: " + 
        myAttribute.ConverterTypeName);
 
    return 0;
 }
int main()
{
   // Creates a new instance of MyClass.
   Class1::MyClass^ myNewClass = gcnew Class1::MyClass;

   // Gets the attributes for the instance.
   AttributeCollection^ attributes = TypeDescriptor::GetAttributes( myNewClass );

   /* Prints the name of the type converter by retrieving the 
        * TypeConverterAttribute from the AttributeCollection. */
   TypeConverterAttribute^ myAttribute = dynamic_cast<TypeConverterAttribute^>(attributes[
 TypeConverterAttribute::typeid ]);
   Console::WriteLine( "The type converter for this
 class is: {0}", myAttribute->ConverterTypeName );
   return 0;
}
public static void main(String[]
 args)
{
    // Creates a new instance of MyClass.       
    MyClass myNewClass = new MyClass();

    // Gets the attributes for the instance.
    AttributeCollection attributes = 
        TypeDescriptor.GetAttributes(myNewClass);

    /* Prints the name of the type converter by retrieving the 
     * TypeConverterAttribute from the AttributeCollection.
     */
    TypeConverterAttribute myAttribute = ((TypeConverterAttribute)
        (attributes.get_Item( TypeConverterAttribute.class.ToType())));
    Console.WriteLine(("The type conveter for this
 class is: " 
        + myAttribute.get_ConverterTypeName()));
   } //main 
継承階層継承階層
System.Object
   System.Attribute
    System.ComponentModel.TypeConverterAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

TypeConverterAttribute コンストラクタ ()


TypeConverterAttribute コンストラクタ (Type)

この属性が関連付けられているオブジェクトのデータ コンバータとして型名を指定して、TypeConverterAttribute クラスの新しいインスタンスを初期化します。

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

Dim type As Type

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

パラメータ

type

この属性が関連付けられているオブジェクトのデータ変換で使用するコンバータ クラスの型を表す Type。

解説解説

データ変換を実現するクラスは、TypeConverter から継承する必要があります。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TypeConverterAttribute クラス
TypeConverterAttribute メンバ
System.ComponentModel 名前空間
TypeConverter クラス

TypeConverterAttribute コンストラクタ (String)

この属性が関連付けられているオブジェクトのデータ コンバータとして指定した型名を使用して、TypeConverterAttribute クラスの新しいインスタンスを初期化します。

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

Dim typeName As String

Dim instance As New TypeConverterAttribute(typeName)
public TypeConverterAttribute (
    string typeName
)
public:
TypeConverterAttribute (
    String^ typeName
)
public TypeConverterAttribute (
    String typeName
)
public function TypeConverterAttribute (
    typeName : String
)

パラメータ

typeName

この属性が関連付けられているオブジェクトのデータ変換で使用するクラスの完全修飾名。

解説解説

データ変換を実現するクラスは、TypeConverter から継承する必要があります。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TypeConverterAttribute クラス
TypeConverterAttribute メンバ
System.ComponentModel 名前空間
TypeConverter クラス

TypeConverterAttribute コンストラクタ

TypeConverterAttribute クラスの新しいインスタンスを初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
TypeConverterAttribute () 既定の型コンバータである空の文字列 ("") を使用して、TypeConverterAttribute クラスの新しいインスタンスを初期化します。
TypeConverterAttribute (String) この属性が関連付けられているオブジェクトのデータ コンバータとして指定した型名を使用して、TypeConverterAttribute クラスの新しいインスタンスを初期化します。
TypeConverterAttribute (Type) この属性が関連付けられているオブジェクトのデータ コンバータとして型名を指定して、TypeConverterAttribute クラスの新しいインスタンスを初期化します。
参照参照

関連項目

TypeConverterAttribute クラス
TypeConverterAttribute メンバ
System.ComponentModel 名前空間
TypeConverter クラス

TypeConverterAttribute フィールド


TypeConverterAttribute プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ ConverterTypeName この属性が関連付けられているオブジェクトのコンバータとして使用する Type の完全修飾型名を取得します。
パブリック プロパティ TypeId  派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。 ( Attribute から継承されます。)
参照参照

関連項目

TypeConverterAttribute クラス
System.ComponentModel 名前空間
TypeConverter クラス

TypeConverterAttribute メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Equals オーバーロードされます。 オーバーライドされます。 指定したオブジェクトの値が現在の TypeConverterAttribute と等しいかどうかを示す値を返します。
パブリック メソッド GetCustomAttribute  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 ( Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 ( Attribute から継承されます。)
パブリック メソッド GetHashCode オーバーライドされます。 対象のインスタンスのハッシュ コードを返します。
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 ( Object から継承されます。)
パブリック メソッド IsDefaultAttribute  派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 ( Attribute から継承されます。)
パブリック メソッド IsDefined  オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 ( Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 ( Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

TypeConverterAttribute クラス
System.ComponentModel 名前空間
TypeConverter クラス

TypeConverterAttribute メンバ

この属性が関連付けられているオブジェクトのコンバータとして使用する型を指定します。このクラスは継承できません。

TypeConverterAttribute データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド TypeConverterAttribute オーバーロードされます。 TypeConverterAttribute クラスの新しいインスタンスを初期化します。
パブリック フィールドパブリック フィールド
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ ConverterTypeName この属性が関連付けられているオブジェクトのコンバータとして使用する Type の完全修飾型名を取得します。
パブリック プロパティ TypeId  派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。(Attribute から継承されます。)
パブリック メソッドパブリック メソッド
( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Equals オーバーロードされます。 オーバーライドされます。 指定したオブジェクトの値が現在の TypeConverterAttribute と等しいかどうかを示す値を返します。
パブリック メソッド GetCustomAttribute  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 (Attribute から継承されます。)
パブリック メソッド GetCustomAttributes  オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 (Attribute から継承されます。)
パブリック メソッド GetHashCode オーバーライドされます。 対象のインスタンスのハッシュ コードを返します。
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 (Object から継承されます。)
パブリック メソッド IsDefaultAttribute  派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 (Attribute から継承されます。)
パブリック メソッド IsDefined  オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 (Attribute から継承されます。)
パブリック メソッド Match  派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 (Attribute から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

TypeConverterAttribute クラス
System.ComponentModel 名前空間
TypeConverter クラス



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「TypeConverterAttribute」の関連用語

TypeConverterAttributeのお隣キーワード
検索ランキング

   

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



TypeConverterAttributeのページの著作権

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

©2026 GRAS Group, Inc.RSS