ConstructorBuilder.Name Özellik
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Bu oluşturucunun adını alır.
public:
virtual property System::String ^ Name { System::String ^ get(); };
public override string Name { get; }
member this.Name : string
Public Overrides ReadOnly Property Name As String
Özellik Değeri
Bu oluşturucunun adı.
Açıklamalar
Aşağıdaki kod örneğinde kullanımı gösterilmektedir Name
.
MethodBuilder^ myMethodBuilder = nullptr;
AppDomain^ myCurrentDomain = AppDomain::CurrentDomain;
// Create assembly in current CurrentDomain.
AssemblyName^ myAssemblyName = gcnew AssemblyName;
myAssemblyName->Name = "TempAssembly";
// Create a dynamic assembly.
myAssemblyBuilder = myCurrentDomain->DefineDynamicAssembly( myAssemblyName, AssemblyBuilderAccess::Run );
// Create a dynamic module in the assembly.
myModuleBuilder = myAssemblyBuilder->DefineDynamicModule( "TempModule" );
FieldInfo^ myFieldInfo = myModuleBuilder->DefineUninitializedData( "myField", 2, FieldAttributes::Public );
// Create a type in the module.
TypeBuilder^ myTypeBuilder = myModuleBuilder->DefineType( "TempClass", TypeAttributes::Public );
FieldBuilder^ myGreetingField = myTypeBuilder->DefineField( "Greeting", String::typeid, FieldAttributes::Public );
array<Type^>^myConstructorArgs = {String::typeid};
// Define a constructor of the dynamic class.
ConstructorBuilder^ myConstructor = myTypeBuilder->DefineConstructor( MethodAttributes::Public, CallingConventions::Standard, myConstructorArgs );
// Display the name of the constructor.
Console::WriteLine( "The constructor name is : {0}", myConstructor->Name );
// Display the 'Type' object from which this object was obtained.
Console::WriteLine( "The reflected type is : {0}", myConstructor->ReflectedType );
// Display the signature of the field.
Console::WriteLine( myConstructor->Signature );
// Display the constructor builder instance as a string.
Console::WriteLine( myConstructor );
MethodBuilder myMethodBuilder = null;
AppDomain myCurrentDomain = AppDomain.CurrentDomain;
// Create assembly in current CurrentDomain.
AssemblyName myAssemblyName = new AssemblyName();
myAssemblyName.Name = "TempAssembly";
// Create a dynamic assembly.
myAssemblyBuilder = myCurrentDomain.DefineDynamicAssembly
(myAssemblyName, AssemblyBuilderAccess.Run);
// Create a dynamic module in the assembly.
myModuleBuilder = myAssemblyBuilder.DefineDynamicModule("TempModule");
FieldInfo myFieldInfo =
myModuleBuilder.DefineUninitializedData("myField", 2, FieldAttributes.Public);
// Create a type in the module.
TypeBuilder myTypeBuilder = myModuleBuilder.DefineType("TempClass",TypeAttributes.Public);
FieldBuilder myGreetingField = myTypeBuilder.DefineField("Greeting",
typeof(String), FieldAttributes.Public);
Type[] myConstructorArgs = { typeof(String) };
// Define a constructor of the dynamic class.
ConstructorBuilder myConstructor = myTypeBuilder.DefineConstructor(
MethodAttributes.Public, CallingConventions.Standard, myConstructorArgs);
// Display the name of the constructor.
Console.WriteLine("The constructor name is : "+ myConstructor.Name);
// Display the 'Type' object from which this object was obtained.
Console.WriteLine("The reflected type is : "+ myConstructor.ReflectedType);
// Display the signature of the field.
Console.WriteLine(myConstructor.Signature);
// Display the constructor builder instance as a string.
Console.WriteLine(myConstructor.ToString());
Dim myMethodBuilder As MethodBuilder = Nothing
Dim myCurrentDomain As AppDomain = AppDomain.CurrentDomain
' Create assembly in current CurrentDomain.
Dim myAssemblyName As New AssemblyName()
myAssemblyName.Name = "TempAssembly"
' Create a dynamic assembly.
myAssemblyBuilder = _
myCurrentDomain.DefineDynamicAssembly(myAssemblyName, AssemblyBuilderAccess.Run)
' Create a dynamic module in the assembly.
myModuleBuilder = myAssemblyBuilder.DefineDynamicModule("TempModule")
Dim myFieldInfo As FieldInfo = _
myModuleBuilder.DefineUninitializedData("myField", 2, FieldAttributes.Public)
' Create a type in the module.
Dim myTypeBuilder As TypeBuilder = _
myModuleBuilder.DefineType("TempClass", TypeAttributes.Public)
Dim myGreetingField As FieldBuilder = _
myTypeBuilder.DefineField("Greeting", GetType(String), FieldAttributes.Public)
Dim myConstructorArgs As Type() = {GetType(String)}
' Define a constructor of the dynamic class.
Dim myConstructor As ConstructorBuilder = _
myTypeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, _
myConstructorArgs)
' Display the name of the constructor.
Console.WriteLine("The constructor name is : " + myConstructor.Name)
' Display the 'Type' object from which this object was obtained.
Console.WriteLine("The reflected type is : " + myConstructor.ReflectedType.ToString())
' Display the signature of the field.
Console.WriteLine(myConstructor.Signature)
' Display the constructor builder instance as a string.
Console.WriteLine(myConstructor.ToString())
Şunlara uygulanır
GitHub'da bizimle işbirliği yapın
Bu içeriğin kaynağı GitHub'da bulunabilir; burada ayrıca sorunları ve çekme isteklerini oluşturup gözden geçirebilirsiniz. Daha fazla bilgi için katkıda bulunan kılavuzumuzu inceleyin.