-
August 19th, 2013, 03:30 PM
#1
[RESOLVED] New C# programmmer needs help with curly brackets.
Hello! I recently got a C# book for extra credit for school. I'm having a lot of problems with indenting, when to indent, and how to use curly brackets. For instance, right now I'm working on a project where I am making loops and testing them with Console.Beep(); and I keep getting error messages that my curly brackets are in the wrong place.
When I go back and try to fix them, Visual Studio 2010 keeps shifting the curly brackets to the left more than I need them (weird I know). For example, if I need my bracket
here------->{
It will move it
here-->{
Any help would appreciated.
-
August 19th, 2013, 07:39 PM
#2
Re: New C# programmmer needs help with curly brackets.
You'll have to show your code the indent of the { is not the issue
If you have pretty code turned on as most do then the IDE tries to format the code for readablility but of course if you have a mistake in there it is not always able to do so.
As for the code there is no difference between
and
beyond the way it looks when you read it
Always use [code][/code] tags when posting code.
-
August 19th, 2013, 08:11 PM
#3
Re: New C# programmmer needs help with curly brackets.
Thanks for the reply. I guess since I'm familiar with lua and python where brackets and such has to be precise, I freaked out a little. Well, I guess I'll close the thread.
-
August 20th, 2013, 10:44 AM
#4
Re: [RESOLVED] New C# programmmer needs help with curly brackets.
Id you are still having problems post the code that is giving you a problem and someone should be able to point you in the right direction.
Always use [code][/code] tags when posting code.
-
August 20th, 2013, 11:04 PM
#5
Re: [RESOLVED] New C# programmmer needs help with curly brackets.
Btw, in some languages the placement of the opening curly brace is on the same line of the preceding statement.
Code:
if( x > 0 ) {
// other code
}
However, in C#, the opening brace generally starts in line with the preceding statement but on the next line.
Code:
if( x > 0 )
{
// other code
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|