I have a simple question. What do you call the MyField variable defined in MyClass below. I’m looking for answers like: “field”, “Property”, “Instance variable”, “Class variable”. What would be the most accurate name for it?
public class MyClass
{
private object MyField;
...
}
It’s not a property – it’s definitely a field, and it’s also an instance variable. From section 10.5.1 of the C# spec:
I’ve never been keen on the terminology “class variable” – it’s not clear whether that means instance variable or static variable, and it’s also unclear how it applies if you declare it as a member of a value type.
See section 10.5 of the C# 5 specification for more details about fields in general.