ConstructorInfo クラス
アセンブリ: mscorlib (mscorlib.dll 内)

<SerializableAttribute> _ <ComVisibleAttribute(True)> _ <ClassInterfaceAttribute(ClassInterfaceType.None)> _ Public MustInherit Class ConstructorInfo Inherits MethodBase Implements _ConstructorInfo
[SerializableAttribute] [ComVisibleAttribute(true)] [ClassInterfaceAttribute(ClassInterfaceType.None)] public abstract class ConstructorInfo : MethodBase, _ConstructorInfo
[SerializableAttribute] [ComVisibleAttribute(true)] [ClassInterfaceAttribute(ClassInterfaceType::None)] public ref class ConstructorInfo abstract : public MethodBase, _ConstructorInfo

コンストラクタの属性を取得するだけでなく、コンストラクタを呼び出すためにも、ConstructorInfo を使用します。オブジェクトは、Type オブジェクトの GetConstructors メソッドまたは GetConstructor メソッドによって返される ConstructorInfo で Invoke を呼び出すと作成されます。
![]() |
---|
ConstructorInfo は、ジェネリック メソッドを調べるために使用できる、IsGenericMethod など、複数の MethodBase メンバから継承されます。.NET Framework Version 2.0 では、コンストラクタをジェネリックにすることはできないため、これらのメンバは false または null 参照 (Visual Basic では Nothing) を返します。 |

ConstructorInfo を GetConstructor および BindingFlags と併せて使用し、指定した検索条件と一致するコンストラクタを検索する例を次に示します。
Public Class MyClass1 Public Sub New(ByVal i As Integer) End Sub Public Shared Sub Main() Try Dim myType As Type = GetType(MyClass1) Dim types(0) As Type types(0) = GetType(Integer) ' Get the public instance constructor that takes an integer parameter. Dim constructorInfoObj As ConstructorInfo = _ myType.GetConstructor(BindingFlags.Instance Or _ BindingFlags.Public, Nothing, _ CallingConventions.HasThis, types, Nothing) If Not (constructorInfoObj Is Nothing) Then Console.WriteLine("The constructor of MyClass1 that " + _ "is a public instance method and takes an " + _ "integer as a parameter is: ") Console.WriteLine(constructorInfoObj.ToString()) Else Console.WriteLine("The constructor MyClass1 that " + _ "is a public instance method and takes an " + _ "integer as a parameter is not available.") End If Catch e As ArgumentNullException Console.WriteLine("ArgumentNullException: " + e.Message) Catch e As ArgumentException Console.WriteLine("ArgumentException: " + e.Message) Catch e As SecurityException Console.WriteLine("SecurityException: " + e.Message) Catch e As Exception Console.WriteLine("Exception: " + e.Message) End Try End Sub End Class
using System; using System.Reflection; using System.Security; public class MyClass1 { public MyClass1(int i){} public static void Main() { try { Type myType = typeof(MyClass1); Type[] types = new Type[1]; types[0] = typeof(int); // Get the public instance constructor that takes an integer parameter. ConstructorInfo constructorInfoObj = myType.GetConstructor( BindingFlags.Instance | BindingFlags.Public, null , CallingConventions.HasThis, types, null); if(constructorInfoObj != null) { Console.WriteLine("The constructor of MyClass1 that is a public " + "instance method and takes an integer as a parameter is: "); Console.WriteLine(constructorInfoObj.ToString()); } else { Console.WriteLine("The constructor of MyClass1 that is a public instance " + "method and takes an integer as a parameter is not available."); } } catch(ArgumentNullException e) { Console.WriteLine("ArgumentNullException: " + e.Message); } catch(ArgumentException e) { Console.WriteLine("ArgumentException: " + e.Message); } catch(SecurityException e) { Console.WriteLine("SecurityException: " + e.Message); } catch(Exception e) { Console.WriteLine("Exception: " + e.Message); } } }
using namespace System; using namespace System::Reflection; using namespace System::Security; public ref class MyClass1 { public: MyClass1( int i ){} }; int main() { try { Type^ myType = MyClass1::typeid; array<Type^>^types = gcnew array<Type^>(1); types[ 0 ] = int::typeid; // Get the public instance constructor that takes an integer parameter. ConstructorInfo^ constructorInfoObj = myType->GetConstructor( static_cast<BindingFlags>(BindingFlags::Instance | BindingFlags::Public), nullptr, CallingConventions::HasThis, types, nullptr ); if ( constructorInfoObj != nullptr ) { Console::WriteLine( "The constructor of MyClass1 that is a public instance method and takes an integer as a parameter is: " ); Console::WriteLine( constructorInfoObj ); } else { Console::WriteLine( "The constructor of MyClass1 that is a public instance method and takes an integer as a parameter is not available." ); } } catch ( ArgumentNullException^ e ) { Console::WriteLine( "ArgumentNullException: {0}", e->Message ); } catch ( ArgumentException^ e ) { Console::WriteLine( "ArgumentException: {0}", e->Message ); } catch ( SecurityException^ e ) { Console::WriteLine( "SecurityException: {0}", e->Message ); } catch ( Exception^ e ) { Console::WriteLine( "Exception: {0}", e->Message ); } }
import System.*; import System.Reflection.*; import System.Security.*; public class MyClass1 { public MyClass1(int i) { } //MyClass1 public static void main(String[] args) { try { Type myType = MyClass1.class.ToType(); Type types[] = new Type[1]; types.set_Item(0, int.class.ToType()); // Get the public instance constructor that takes an // integer parameter. ConstructorInfo constructorInfoObj = myType.GetConstructor(BindingFlags.Instance|BindingFlags.Public, null, CallingConventions.HasThis, types, null); if (constructorInfoObj != null) { Console.WriteLine("The constructor of MyClass1 that is a public " + "instance method and takes an integer as a parameter is: "); Console.WriteLine(constructorInfoObj.ToString()); } else { Console.WriteLine("The constructor of MyClass1 that is a " + "public instance method and takes an integer " + "as a parameter is not available."); } } catch (ArgumentNullException e) { Console.WriteLine("ArgumentNullException: " + e.get_Message()); } catch (ArgumentException e) { Console.WriteLine("ArgumentException: " + e.get_Message()); } catch (SecurityException e) { Console.WriteLine("SecurityException: " + e.get_Message()); } catch (System.Exception e) { Console.WriteLine("Exception: " + e.get_Message()); } } //main } //MyClass1

System.Reflection.MemberInfo
System.Reflection.MethodBase
System.Reflection.ConstructorInfo
Microsoft.JScript.JSConstructor
System.Reflection.Emit.ConstructorBuilder


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ConstructorInfo コンストラクタ
アセンブリ: mscorlib (mscorlib.dll 内)



Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ConstructorInfo フィールド

名前 | 説明 | |
---|---|---|
![]() | TypeConstructorName | メタデータに格納されているとおりに型コンストラクタのメソッドの名前を表します。この名前は常に ".cctor" です。このプロパティは読み取り専用です。 |

ConstructorInfo プロパティ

名前 | 説明 | |
---|---|---|
![]() | Attributes | このメソッドに関連付けられている属性を取得します。 ( MethodBase から継承されます。) |
![]() | CallingConvention | このメソッドの呼び出し規約を示す値を取得します。 ( MethodBase から継承されます。) |
![]() | ContainsGenericParameters | ジェネリック メソッドに、割り当てられていないジェネリック型パラメータが含まれているかどうかを示す値を取得します。 ( MethodBase から継承されます。) |
![]() | DeclaringType | このメンバを宣言するクラスを取得します。 ( MemberInfo から継承されます。) |
![]() | IsAbstract | メソッドが抽象メソッドかどうかを示す値を取得します。 ( MethodBase から継承されます。) |
![]() | IsAssembly | 同じアセンブリの異なるクラスからこのメソッドを呼び出すことができるかどうかを示す値を取得します。 ( MethodBase から継承されます。) |
![]() | IsConstructor | メソッドがコンストラクタかどうかを示す値を取得します。 ( MethodBase から継承されます。) |
![]() | IsFamily | このメソッドへのアクセスがクラスのメンバと派生クラスのメンバに制限されているかどうかを示す値を取得します。 ( MethodBase から継承されます。) |
![]() | IsFamilyAndAssembly | 同じアセンブリの派生クラスからこのメソッドを呼び出すことができるかどうかを示す値を取得します。 ( MethodBase から継承されます。) |
![]() | IsFamilyOrAssembly | すべての派生クラスおよび同じアセンブリのすべてのクラスからこのメソッドを呼び出すことができるかどうかを示す値を取得します。 ( MethodBase から継承されます。) |
![]() | IsFinal | このメソッドが final かどうかを示す値を取得します。 ( MethodBase から継承されます。) |
![]() | IsGenericMethod | メソッドがジェネリック メソッドかどうかを示す値を取得します。 ( MethodBase から継承されます。) |
![]() | IsGenericMethodDefinition | メソッドがジェネリック メソッドの定義かどうかを示す値を取得します。 ( MethodBase から継承されます。) |
![]() | IsHideBySig | 派生クラスで、正確に同じシグネチャを持つ同じ種類のメンバだけが隠しメンバになるかどうかを示す値を取得します。 ( MethodBase から継承されます。) |
![]() | IsPrivate | このメンバがプライベートかどうかを示す値を取得します。 ( MethodBase から継承されます。) |
![]() | IsPublic | パブリック メソッドかどうかを示す値を取得します。 ( MethodBase から継承されます。) |
![]() | IsSpecialName | 特別な名前のメソッドかどうかを示す値を取得します。 ( MethodBase から継承されます。) |
![]() | IsStatic | メソッドが static かどうかを示す値を取得します。 ( MethodBase から継承されます。) |
![]() | IsVirtual | メソッドが virtual かどうかを示す値を取得します。 ( MethodBase から継承されます。) |
![]() | MemberType | オーバーライドされます。 このメンバがコンストラクタであることを示す MemberTypes 値を取得します。 |
![]() | MetadataToken | メタデータ要素を識別する値を取得します。 ( MemberInfo から継承されます。) |
![]() | MethodHandle | メソッドの内部メタデータ表現を識別するハンドルを取得します。 ( MethodBase から継承されます。) |
![]() | Module | 現在の MemberInfo によって表されるメンバを宣言する型が定義されているモジュールを取得します。 ( MemberInfo から継承されます。) |
![]() | Name | 現在のメンバの名前を取得します。 ( MemberInfo から継承されます。) |
![]() | ReflectedType | MemberInfo のこのインスタンスを取得するために使用したクラス オブジェクトを取得します。 ( MemberInfo から継承されます。) |

ConstructorInfo メソッド


名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | System.Runtime.InteropServices._ConstructorInfo.GetIDsOfNames | 一連の名前を対応する一連のディスパッチ識別子に割り当てます。 |
![]() | System.Runtime.InteropServices._ConstructorInfo.GetType | ConstructorInfo 型を表す Type オブジェクトを取得します。 |
![]() | System.Runtime.InteropServices._ConstructorInfo.GetTypeInfo | オブジェクトの型情報を取得します。その後は、インターフェイスの型情報の取得に使用できます。 |
![]() | System.Runtime.InteropServices._ConstructorInfo.GetTypeInfoCount | オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。 |
![]() | System.Runtime.InteropServices._ConstructorInfo.Invoke | オブジェクトが公開するプロパティおよびメソッドにアクセスできるようにします。 |
![]() | System.Runtime.InteropServices._ConstructorInfo.Invoke_2 | このメンバの説明については、Invoke_2 のトピックを参照してください。 |
![]() | System.Runtime.InteropServices._ConstructorInfo.Invoke_3 | このメンバの説明については、Invoke_3 のトピックを参照してください。 |
![]() | System.Runtime.InteropServices._ConstructorInfo.Invoke_4 | このメンバの説明については、Invoke_4 のトピックを参照してください。 |
![]() | System.Runtime.InteropServices._ConstructorInfo.Invoke_5 | このメンバの説明については、Invoke_5 のトピックを参照してください。 |

ConstructorInfo メンバ
クラス コンストラクタの属性を取得し、コンストラクタのメタデータにアクセスできるようにします。
ConstructorInfo データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | TypeConstructorName | メタデータに格納されているとおりに型コンストラクタのメソッドの名前を表します。この名前は常に ".cctor" です。このプロパティは読み取り専用です。 |

名前 | 説明 | |
---|---|---|
![]() | Attributes | このメソッドに関連付けられている属性を取得します。(MethodBase から継承されます。) |
![]() | CallingConvention | このメソッドの呼び出し規約を示す値を取得します。(MethodBase から継承されます。) |
![]() | ContainsGenericParameters | ジェネリック メソッドに、割り当てられていないジェネリック型パラメータが含まれているかどうかを示す値を取得します。(MethodBase から継承されます。) |
![]() | DeclaringType | このメンバを宣言するクラスを取得します。(MemberInfo から継承されます。) |
![]() | IsAbstract | メソッドが抽象メソッドかどうかを示す値を取得します。(MethodBase から継承されます。) |
![]() | IsAssembly | 同じアセンブリの異なるクラスからこのメソッドを呼び出すことができるかどうかを示す値を取得します。(MethodBase から継承されます。) |
![]() | IsConstructor | メソッドがコンストラクタかどうかを示す値を取得します。(MethodBase から継承されます。) |
![]() | IsFamily | このメソッドへのアクセスがクラスのメンバと派生クラスのメンバに制限されているかどうかを示す値を取得します。(MethodBase から継承されます。) |
![]() | IsFamilyAndAssembly | 同じアセンブリの派生クラスからこのメソッドを呼び出すことができるかどうかを示す値を取得します。(MethodBase から継承されます。) |
![]() | IsFamilyOrAssembly | すべての派生クラスおよび同じアセンブリのすべてのクラスからこのメソッドを呼び出すことができるかどうかを示す値を取得します。(MethodBase から継承されます。) |
![]() | IsFinal | このメソッドが final かどうかを示す値を取得します。(MethodBase から継承されます。) |
![]() | IsGenericMethod | メソッドがジェネリック メソッドかどうかを示す値を取得します。(MethodBase から継承されます。) |
![]() | IsGenericMethodDefinition | メソッドがジェネリック メソッドの定義かどうかを示す値を取得します。(MethodBase から継承されます。) |
![]() | IsHideBySig | 派生クラスで、正確に同じシグネチャを持つ同じ種類のメンバだけが隠しメンバになるかどうかを示す値を取得します。(MethodBase から継承されます。) |
![]() | IsPrivate | このメンバがプライベートかどうかを示す値を取得します。(MethodBase から継承されます。) |
![]() | IsPublic | パブリック メソッドかどうかを示す値を取得します。(MethodBase から継承されます。) |
![]() | IsSpecialName | 特別な名前のメソッドかどうかを示す値を取得します。(MethodBase から継承されます。) |
![]() | IsStatic | メソッドが static かどうかを示す値を取得します。(MethodBase から継承されます。) |
![]() | IsVirtual | メソッドが virtual かどうかを示す値を取得します。(MethodBase から継承されます。) |
![]() | MemberType | オーバーライドされます。 このメンバがコンストラクタであることを示す MemberTypes 値を取得します。 |
![]() | MetadataToken | メタデータ要素を識別する値を取得します。(MemberInfo から継承されます。) |
![]() | MethodHandle | メソッドの内部メタデータ表現を識別するハンドルを取得します。(MethodBase から継承されます。) |
![]() | Module | 現在の MemberInfo によって表されるメンバを宣言する型が定義されているモジュールを取得します。(MemberInfo から継承されます。) |
![]() | Name | 現在のメンバの名前を取得します。(MemberInfo から継承されます。) |
![]() | ReflectedType | MemberInfo のこのインスタンスを取得するために使用したクラス オブジェクトを取得します。(MemberInfo から継承されます。) |


名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | System.Runtime.InteropServices._ConstructorInfo.GetIDsOfNames | 一連の名前を対応する一連のディスパッチ識別子に割り当てます。 |
![]() | System.Runtime.InteropServices._ConstructorInfo.GetType | ConstructorInfo 型を表す Type オブジェクトを取得します。 |
![]() | System.Runtime.InteropServices._ConstructorInfo.GetTypeInfo | オブジェクトの型情報を取得します。その後は、インターフェイスの型情報の取得に使用できます。 |
![]() | System.Runtime.InteropServices._ConstructorInfo.GetTypeInfoCount | オブジェクトが提供する型情報インターフェイスの数 (0 または 1) を取得します。 |
![]() | System.Runtime.InteropServices._ConstructorInfo.Invoke | オブジェクトが公開するプロパティおよびメソッドにアクセスできるようにします。 |
![]() | System.Runtime.InteropServices._ConstructorInfo.Invoke_2 | このメンバの説明については、Invoke_2 のトピックを参照してください。 |
![]() | System.Runtime.InteropServices._ConstructorInfo.Invoke_3 | このメンバの説明については、Invoke_3 のトピックを参照してください。 |
![]() | System.Runtime.InteropServices._ConstructorInfo.Invoke_4 | このメンバの説明については、Invoke_4 のトピックを参照してください。 |
![]() | System.Runtime.InteropServices._ConstructorInfo.Invoke_5 | このメンバの説明については、Invoke_5 のトピックを参照してください。 |

_ConstructorInfo インターフェイス
アセンブリ: mscorlib (mscorlib.dll 内)

<InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)> _ <ComVisibleAttribute(True)> _ <GuidAttribute("E9A19478-9646-3679-9B10-8411AE1FD57D")> _ <CLSCompliantAttribute(False)> _ Public Interface _ConstructorInfo
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] [ComVisibleAttribute(true)] [GuidAttribute("E9A19478-9646-3679-9B10-8411AE1FD57D")] [CLSCompliantAttribute(false)] public interface _ConstructorInfo
[InterfaceTypeAttribute(ComInterfaceType::InterfaceIsIUnknown)] [ComVisibleAttribute(true)] [GuidAttribute(L"E9A19478-9646-3679-9B10-8411AE1FD57D")] [CLSCompliantAttribute(false)] public interface class _ConstructorInfo

このインターフェイスは、アンマネージ コードからマネージ クラスにアクセスするためのインターフェイスであるため、マネージ コードからは呼び出さないでください。
System.Reflection.ConstructorInfo クラスは、クラス コンストラクタの属性を見つけ、コンストラクタのメタデータにアクセスできるようにします。
System.Runtime.InteropServices._ConstructorInfo インターフェイスでは、アンマネージ COM オブジェクトでアクセス可能な System.Reflection.ConstructorInfo クラス メンバの vtable の順序が保持されます。

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


_ConstructorInfo プロパティ


_ConstructorInfo メソッド


_ConstructorInfo メンバ
System.Reflection.ConstructorInfo クラスのパブリック メンバをアンマネージ コードに公開します。
_ConstructorInfo データ型で公開されるメンバを以下の表に示します。



- ConstructorInfoのページへのリンク