balalakshmi
balalakshmi

Reputation: 4218

why there is no semicolon after automatic properties

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

Answers (2)

Robin Day
Robin Day

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

Justin Niessner
Justin Niessner

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

Related Questions