C# Type GetFields()
Description
Type GetFields()
returns all the public fields of the
current Type.
Syntax
Type.GetFields()
has the following syntax.
public FieldInfo[] GetFields()
Returns
Type.GetFields()
method returns
Example
The following example shows a use of the GetFields() method.
/*from w ww. ja va 2 s . c om*/
using System;
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(myField[i].Name);
}
}
}
}
The code above generates the following result.