I saw something like the following somewhere, and was wondering what it meant. I know they are getters and setters, but want to know why the string Type is defined like this. Thanks for helping me.
public string Type { get; set; }
Those are Auto-Implemented Properties (Auto Properties for short).
The compiler will auto-generate the equivalent of the following simple implementation:
private string _type;
public string Type
{
get { return _type; }
set { _type = value; }
}
That is an auto-property and it is the shorthand notation for this:
private string type;
public string Type
{
get { return this.type; }
set { this.type = value; }
}
This means that the compiler defines a backing field at runtime. This is the syntax for auto-implemented properties.
More Information: Auto-Implemented Properties
These are called auto properties.
http://msdn.microsoft.com/en-us/library/bb384054.aspx
Functionally (and in terms of the compiled IL), they are the same as properties with backing fields.
"Type", the .NET type of which isSystem.string. There's nothing more to it. - Jon