クラスの静的コンストラクタを表します。
この型のすべてのメンバの一覧については、CodeTypeConstructor メンバ を参照してください。
System.Object
System.CodeDom.CodeObject
System.CodeDom.CodeTypeMember
System.CodeDom.CodeMemberMethod
System.CodeDom.CodeTypeConstructor
<Serializable>
<ClassInterface(ClassInterfaceType.AutoDispatch)>
<ComVisible(True)>
Public Class CodeTypeConstructor Inherits CodeMemberMethod
[C#]
[Serializable]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
[ComVisible(true)]
public class CodeTypeConstructor : CodeMemberMethod
[C++]
[Serializable]
[ClassInterface(ClassInterfaceType::AutoDispatch)]
[ComVisible(true)]
public __gc class CodeTypeConstructor : public CodeMemberMethod
[JScript]
public
Serializable
ClassInterface(ClassInterfaceType.AutoDispatch)
ComVisible(true)
class CodeTypeConstructor extends CodeMemberMethod
スレッドセーフ
この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。
解説
CodeTypeConstructor を使用して、クラスの静的コンストラクタを表すことができます。静的コンストラクタは、型が読み込まれるときに 1 回呼び出されます。
メモ 静的コンストラクタは、すべての言語でサポートされているわけではありません。特定の言語でコード ジェネレータが静的コンストラクタをサポートしているかどうかを調べるには、 StaticConstructors フラグを指定して Supports を呼び出します。
使用例
[Visual Basic, C#, C++] 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
[C#]
// 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()
// {
// }
// }
[C++]
// Declares a new type for a static constructor.
CodeTypeDeclaration* type1 = new CodeTypeDeclaration(S"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()
// {
// }
// }
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
名前空間: System.CodeDom
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
アセンブリ: System (System.dll 内)
参照
CodeTypeConstructor メンバ | System.CodeDom 名前空間 | CodeConstructor