I have no idea what these are for. The documentation is not very clear:
GetField Specifies that the value of the specified field should be returned.
SetField Specifies that the value of the specified field should be set.
GetProperty Specifies that the value of the specified property should be returned.
SetProperty Specifies that the value of the specified property should be set. For COM properties, specifying this binding flag is equivalent to specifying PutDispProperty and PutRefDispProperty.
If I specify them in BindingFlags
enumeration, what should they return? I thought it has to do with properties and fields of a type, but this simple test says no:
class Base
{
int i;
int I { get; set; }
void Do()
{
}
}
print typeof(Base).GetMembers(BindingFlags.GetField
| BindingFlags.Instance
| BindingFlags.NonPublic);
// Int32 get_I()
// Void set_I(Int32)
// Void Do()
// Void Finalize()
// System.Object MemberwiseClone()
// Int32 I
// Int32 i
// Int32 <I>k__BackingField
The same set is returned for SetField
, GetProperty
and SetProperty
.