×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Visual Studio Oddity - Case Statement extra indenting

Visual Studio Oddity - Case Statement extra indenting

Visual Studio Oddity - Case Statement extra indenting

(OP)
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:
------>{
...
}
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)

RE: Visual Studio Oddity - Case Statement extra indenting

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?

RE: Visual Studio Oddity - Case Statement extra indenting

(OP)
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)

RE: Visual Studio Oddity - Case Statement extra indenting

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close