CodeTypeConstructor-Klasse
Stellt einen statischen Konstruktor für eine Klasse dar.
Namespace: System.CodeDom
Assembly: System (in system.dll)
Syntax
'Declaration
<SerializableAttribute> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class CodeTypeConstructor
Inherits CodeMemberMethod
'Usage
Dim instance As CodeTypeConstructor
[SerializableAttribute]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
[ComVisibleAttribute(true)]
public class CodeTypeConstructor : CodeMemberMethod
[SerializableAttribute]
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)]
[ComVisibleAttribute(true)]
public ref class CodeTypeConstructor : public CodeMemberMethod
/** @attribute SerializableAttribute() */
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */
/** @attribute ComVisibleAttribute(true) */
public class CodeTypeConstructor extends CodeMemberMethod
SerializableAttribute
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)
ComVisibleAttribute(true)
public class CodeTypeConstructor extends CodeMemberMethod
Hinweise
Der statische Konstruktor für eine Klasse kann mit CodeTypeConstructor dargestellt werden. Ein statischer Konstruktor wird einmal aufgerufen, wenn der Typ geladen wird.
Hinweis
Nicht alle Sprachen unterstützen statische Konstruktoren. Die Unterstützung für statische Konstruktoren kann überprüft werden, indem Supports mit dem StaticConstructors-Flag aufgerufen wird. Damit können Sie bestimmen, ob statische Konstruktoren vom Codegenerator für eine bestimmte Sprache unterstützt werden.
Beispiel
Im folgenden Beispiel wird veranschaulicht, wie mit einem CodeTypeConstructor ein statischer Konstruktor für einen Typ deklariert wird.
' 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
Vererbungshierarchie
System.Object
System.CodeDom.CodeObject
System.CodeDom.CodeTypeMember
System.CodeDom.CodeMemberMethod
System.CodeDom.CodeTypeConstructor
Threadsicherheit
Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.
Plattformen
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 unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
CodeTypeConstructor-Member
System.CodeDom-Namespace
CodeConstructor-Klasse