C# FieldInfo IsLiteral
Description
FieldInfo IsLiteral
Gets a value indicating whether
the value is written at compile time and cannot be changed.
Syntax
FieldInfo.IsLiteral
has the following syntax.
public bool IsLiteral { get; }
Example
using System;//from www . ja va 2 s.c om
using System.Reflection;
public class Example
{
public int f_public;
internal int f_internal;
protected int f_protected;
protected internal int f_protected_public;
public static void Main()
{
foreach (FieldInfo f in typeof(Example).GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public))
{
Console.WriteLine(f.Name);
Console.WriteLine(f.IsLiteral);
}
}
}
The code above generates the following result.