Fremus.co.za

Demistifying Life and Web Development

For and If statements without the braces

I noted a lot recently that C# developers do not use the curly braces for if and for loops, it seems that the indentation is enough. So if you write this:

                if (elemInner.HasElements)
                    foreach (XElement elemInnerInner in elemInner.Elements())
                        context.Response.Write("
" + elemInnerInner.Name + "
");

Apparently you use curly braces if you have multiple lines you should use curly braces. If you don’t use curly braces only the first line in your condition will be execute.

  • Share/Bookmark
posted by fr3dr1k in C# and have No Comments
Tags:

Place your comment

Please fill your data and comment below.
Name
Email
Website
Your comment
Get Adobe Flash playerPlugin by wpburn.com wordpress themes