CodeTypeConstructor クラス
アセンブリ: System (system.dll 内)

<SerializableAttribute> _ <ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _ <ComVisibleAttribute(True)> _ Public Class CodeTypeConstructor Inherits CodeMemberMethod
[SerializableAttribute] [ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] [ComVisibleAttribute(true)] public class CodeTypeConstructor : CodeMemberMethod
[SerializableAttribute] [ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] [ComVisibleAttribute(true)] public ref class CodeTypeConstructor : public CodeMemberMethod

CodeTypeConstructor を使用して、クラスの静的コンストラクタを表すことができます。静的コンストラクタは、型が読み込まれるときに 1 回呼び出されます。
![]() |
---|
静的コンストラクタは、すべての言語でサポートされているわけではありません。特定の言語でコード ジェネレータが静的コンストラクタをサポートしているかどうかを調べるには、StaticConstructors フラグを指定して Supports を呼び出します。 |

CodeTypeConstructor を使用して、型の静的コンストラクタを宣言する例を次に示します。
' Declares a new type for a static constructor. Dim type1 As New CodeTypeDeclaration("Type1") ' Declares a static constructor. Dim constructor2 As New CodeTypeConstructor() ' Adds the static constructor to the type. type1.Members.Add(constructor2) ' A Visual Basic code generator produces the following source code for the preceeding example code: ' Public Class Type1 ' ' Shared Sub New() ' End Sub ' End Class
// Declares a new type for a static constructor. CodeTypeDeclaration type1 = new CodeTypeDeclaration("Type1"); // Declares a static constructor. CodeTypeConstructor constructor2 = new CodeTypeConstructor(); // Adds the static constructor to the type. type1.Members.Add( constructor2 ); // A C# code generator produces the following source code for the preceeding example code: // public class Type1 // { // // static Type1() // { // } // }
// Declares a new type for a static constructor. CodeTypeDeclaration^ type1 = gcnew CodeTypeDeclaration( "Type1" ); // Declares a static constructor. CodeTypeConstructor^ constructor2 = gcnew CodeTypeConstructor; // Adds the static constructor to the type. type1->Members->Add( constructor2 ); // A C# code generator produces the following source code for the preceeding example code: // public class Type1 // { // // static Type1() // { // } // }
// Declares a new type for a static constructor. CodeTypeDeclaration type1 = new CodeTypeDeclaration("Type1"); // Declares a static constructor. CodeTypeConstructor constructor2 = new CodeTypeConstructor(); // Adds the static constructor to the type. type1.get_Members().Add(constructor2); // A VJ# code generator produces the following source code for // the preceeding example code: //public class Type1 //{ // static { // } //Type1 //} //Type1

System.CodeDom.CodeObject
System.CodeDom.CodeTypeMember
System.CodeDom.CodeMemberMethod
System.CodeDom.CodeTypeConstructor


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- CodeTypeConstructor クラスのページへのリンク