enum
keyword is used to declare an enumeration, a distinct type that consists of a set of named constants called the enumerator list.using
directivenamespace ExtensionMethods
{
public static class MyExtensions
{
public static int WordCount(this String str)
{
return str.Split(new char[] { ' ', '.', '?' },
StringSplitOptions.RemoveEmptyEntries).Length;
}
}
}
string s = "Hello Extension Methods"; int i = s.WordCount();
https://msdn.microsoft.com/en-us/library/aa288470(v=vs.71).aspx
It's a so-called auto property, and is essentially a shorthand for the following (similar code will be generated by the compiler):
private string name;
public string Name
{
get
{
return this.name;
}
set
{
this.name = value;
}
}