• Create Account

### #Actualsiri

Posted 17 April 2013 - 07:04 AM

// Used to check if x is equal to 0
if (x == 0)
{
x  =  5;        // give x the value of 5
}
else                 // if x is not equal to 0 then do this
{
x = 4;         // give x the value of 4
}

Did he mark you down for not commenting the curly braces themselves ?

Pretty much every comment there is unnecessary in my opinion. There is such a thing as commenting too much and hindering readability.

As for me I tend to use braces in this manner:

void func() {
}


I'm not sure why it's just habit. I've recently started using C# and found the auto-formatting in VS very annoying. Took me a while to work out how to disable it.

Edit:

Just occurred to me that the block Andy posted was likely just an example.

### #1siri

Posted 17 April 2013 - 07:01 AM

// Used to check if x is equal to 0
if (x == 0)
{
x  =  5;        // give x the value of 5
}
else                 // if x is not equal to 0 then do this
{
x = 4;         // give x the value of 4
}

Did he mark you down for not commenting the curly braces themselves ?

Pretty much every comment there is unnecessary in my opinion. There is such a thing as commenting too much and hindering readability.

As for me I tend to use braces in this manner:

void func() {
}


I'm not sure why it's just habit. I've recently started using C# and found the auto-formatting in VS very annoying. Took me a while to work out how to disable it.

PARTNERS