S2 Q2: Semi colons *are* optional per line - but not per statement

I realize this is slightly pedantic, but the quiz states “Semi-colons on the end of lines are optional in C#?”

This is clearly true; you can write, for example:

void Start () {
print(“Welcome to Number Wizard!”)
;
print(“Pick a number in your head, but don’t tell me!”);
}

And it does, in fact, compile and run fine.

C# requires a semi-colon per statement, but not per line. Maybe this was too subtle for a beginning class, but it’s sometimes an important distinction.

== John ==

2 Likes

Yep, the white space gets ignored by the compiler…

Handy for this kind of thing; <-- irony

MethodCall (
    int parameterOne,
    int parameterTwo,
    int parameterThree,
    bool parameterFour);

So then the quiz needs to be changed, right?

Also, not sure why you mentioned “irony”, as it IS pretty handy for this:

MethodCall (
int parameterOne, //long description of what Param one is for, expected values, etc.
int parameterTwo, //long description of what Param one is for, expected values, etc.
int parameterThree, //long description of what Param one is for, expected values, etc.
bool parameterFour); //long description of what Param one is for, expected values, etc.

It would make sense if it is incorrect yes.

It was an attempt at a little light-hearted humour based on the fact I added a semi-colon at the end of my statement…

Handy for this kind of thing;

LOL :slight_smile: Ok, I get it!

1 Like

:wink:

Not sure of the best way to get the info to either Ben or Sam though, I know that they do use the Q&A on Udemy for checking question/queries by students, so for course related issues that could be a good place to post it, however, lets also tag them both here and see if they spot the post :slight_smile:

/me waves to @Ben and @sampattuzzi

Got it, I’ll post over there - thanks again for your help!

== John ==

1 Like

True but at this stage we are trying to keep it simple for beginners. Most won’t know what a statement is yet.

Privacy & Terms