FieldInfo.IsSpecialName Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan nilai yang menunjukkan apakah atribut yang SpecialName
sesuai diatur dalam FieldAttributes enumerator.
public:
property bool IsSpecialName { bool get(); };
public bool IsSpecialName { get; }
member this.IsSpecialName : bool
Public ReadOnly Property IsSpecialName As Boolean
Nilai Properti
true
SpecialName
jika atribut diatur dalam FieldAttributes; jika tidak, false
.
Penerapan
Contoh
Contoh berikut mengembalikan nilai yang menunjukkan apakah bidang di kelas berisi atribut SpecialName atau tidak.
#using <system.dll>
using namespace System;
using namespace System::Reflection;
using namespace System::ComponentModel::Design;
int main()
{
try
{
// Get the type handle of a specified class.
Type^ myType = ViewTechnology::typeid;
// Get the fields of the specified class.
array<FieldInfo^>^myField = myType->GetFields();
Console::WriteLine( "\nDisplaying fields that have SpecialName attributes:\n" );
for ( int i = 0; i < myField->Length; i++ )
{
// Determine whether or not each field is a special name.
if ( myField[ i ]->IsSpecialName )
{
Console::WriteLine( "The field {0} has a SpecialName attribute.", myField[ i ]->Name );
}
}
}
catch ( Exception^ e )
{
Console::WriteLine( "Exception : {0} ", e->Message );
}
}
using System;
using System.Reflection;
using System.ComponentModel.Design;
class FieldInfo_IsSpecialName
{
public static void Main()
{
try
{
// Get the type handle of a specified class.
Type myType = typeof(ViewTechnology);
// Get the fields of the specified class.
FieldInfo[] myField = myType.GetFields();
Console.WriteLine("\nDisplaying fields that have SpecialName attributes:\n");
for(int i = 0; i < myField.Length; i++)
{
// Determine whether or not each field is a special name.
if(myField[i].IsSpecialName)
{
Console.WriteLine("The field {0} has a SpecialName attribute.",
myField[i].Name);
}
}
}
catch(Exception e)
{
Console.WriteLine("Exception : {0} " , e.Message);
}
}
}
Imports System.Reflection
Imports System.ComponentModel.Design
Class FieldInfo_IsSpecialName
Public Shared Sub Main()
Try
' Get the type handle of a specified class.
Dim myType As Type = GetType(ViewTechnology)
' Get the fields of a specified class.
Dim myField As FieldInfo() = myType.GetFields()
Console.WriteLine(ControlChars.Cr + "Displaying fields that have SpecialName attributes:" + ControlChars.Cr)
Dim i As Integer
For i = 0 To myField.Length - 1
' Determine whether or not each field is a special name.
If myField(i).IsSpecialName Then
Console.WriteLine("The field {0} has a SpecialName attribute.", myField(i).Name)
End If
Next i
Catch e As Exception
Console.WriteLine("Exception : {0} ", e.Message.ToString())
End Try
End Sub
End Class
Keterangan
Nama yang dimulai dengan atau berisi karakter garis bawah (_), aksesor properti, dan metode kelebihan beban operator adalah contoh nama yang mungkin memerlukan perlakuan khusus oleh beberapa pengkompilasi.