FieldInfo.IsSpecialName Proprietà
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene un valore che indica se l'attributo SpecialName
corrispondente è impostato sull'enumeratore FieldAttributes.
public:
property bool IsSpecialName { bool get(); };
public bool IsSpecialName { get; }
member this.IsSpecialName : bool
Public ReadOnly Property IsSpecialName As Boolean
true
se l'attributo SpecialName
è impostato in FieldAttributes; in caso contrario, false
.
Nell'esempio seguente viene restituito un valore che indica se i campi della classe contengono un attributo SpecialName.
#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
I nomi che iniziano con o contengono un carattere di sottolineatura (_), le funzioni di accesso alle proprietà e i metodi di overload degli operatori sono esempi di nomi che potrebbero richiedere un trattamento speciale da parte di alcuni compilatori.
Prodotto | Versioni |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1 |
UWP | 10.0 |
Feedback su .NET
.NET è un progetto di open source. Selezionare un collegamento per fornire feedback: