The name pretty much says it all, how do I know if I get the compiler created by backingfield for {get; set;} property?
I run this code to get my FieldInfos:
Class MyType
{
private int foo;
public int bar {get; private set; }
}
Type type = TypeOf(MyType);
foreach (FieldInfo fi in type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.NonPublic))
{
}
so the question is, can I somehow find that FieldInfo is a background field without relying on checking its name? (Which is quite undocumented and could be broken in the next version of the framework)
source
share