Reputation: 4218
Why we donot need to specify ; after an automatic property declaration
public string Name{get;set;}
How different is this statement from any other c# statement
Upvotes: 1
Views: 484
Reputation: 102528
There is a semi colon after the two statements. Get, Set. The curly braces are not part of the statements.
Think of it like
public string Name
{
get;
set;
}
Upvotes: 1
Reputation: 245459
Because there's never a semi-colon after a code block (code contained between {}
's), the only go after statements.
get
and set
are your statements in this case (which is why they both have the semi-colons after them)
Upvotes: 5