Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Visual Studio Oddity - Case Statement extra indenting

Status
Not open for further replies.

Qik3Coder

Programmer
Jan 4, 2006
1,487
US
Why does VS add an extra indent on the parens for the CASE block? Is there a way to turn that off?
No other logic block does that.
Code:
switch (DisplayMethod)
{
	case CONSTANTS.DisplayMethod.Mode1:
         [b][red]------>[/red][/b]{
            		...
		}
	case CONSTANTS.DisplayMethod.Mode2:
        	{
                	...
		}
	case CONSTANTS.DisplayMethod.Mode3:
        	{
                	...
		}
}

Lodlaiden


You've got questions and source code. We want both!
Oh? That? That's not an important password. - IT Security Admin (pw on whiteboard)
 
This is YOUR extra level. Switch statement (informal;) syntax:
Code:
switch (,,,)
{
  case ...:
    statement
    ...
    statement
  case ...:
    ...
}
You add block statement after case (why?) - it's indented - what's a problem?
 
You're talking about the pair of curly braces? Didn't realize they were optional here.
This is the only control structure that doesn't require a pair of braces for a multi-line logic block.

With your statement, I was able to find this:
Option->Text Editor->C#->Formatting->Indentation->Indent case contents

Unchecking that option makes the CASE block indent in a similar fashion to IF/FOR/WHILE

Thanks!
Lodlaiden

You've got questions and source code. We want both!
Oh? That? That's not an important password. - IT Security Admin (pw on whiteboard)
 
Some addition:
No such animal as "case block" in C family languages. Case construct is a label only - marked point in the switch statement block.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top