Check if a SpecialName attribute is set in the FieldAttributes in CSharp
Description
The following code shows how to check if a SpecialName attribute is set in the FieldAttributes.
Example
using System;/* ww w . j a v a 2 s .co m*/
using System.Reflection;
using System.ComponentModel.Design;
class FieldInfo_IsSpecialName
{
public static void Main()
{
Type myType = typeof(ViewTechnology);
FieldInfo[] myField = myType.GetFields();
for(int i = 0; i < myField.Length; i++)
{
if(myField[i].IsSpecialName)
{
Console.WriteLine("The field {0} has a SpecialName attribute.",
myField[i].Name);
}
}
}
}
The code above generates the following result.
C# Tutorial »
Reflection »