Click here to Skip to main content
15,888,803 members
Home / Discussions / C#
   

C#

 
GeneralRe: #if indentation Pin
F2dk29-Jan-10 10:36
F2dk29-Jan-10 10:36 
GeneralRe: #if indentation Pin
Not Active29-Jan-10 11:02
mentorNot Active29-Jan-10 11:02 
AnswerRe: #if indentation Pin
OriginalGriff29-Jan-10 10:31
mveOriginalGriff29-Jan-10 10:31 
GeneralRe: #if indentation Pin
F2dk29-Jan-10 10:33
F2dk29-Jan-10 10:33 
GeneralRe: #if indentation Pin
OriginalGriff29-Jan-10 10:52
mveOriginalGriff29-Jan-10 10:52 
GeneralRe: #if indentation Pin
F2dk29-Jan-10 10:57
F2dk29-Jan-10 10:57 
GeneralRe: #if indentation Pin
Not Active29-Jan-10 11:04
mentorNot Active29-Jan-10 11:04 
GeneralRe: #if indentation Pin
F2dk29-Jan-10 11:32
F2dk29-Jan-10 11:32 
By disabling "Place 'else' on a new line" I get code looking like this:
} else {

(on one line) - That is what I am used to.

But due to C#'s syntax, I can force something in between the } and the else.
For example, a comment.
if (true) {
  DoSomething();
}
  // a comment
else {

In this case MSVC# actually doesn't know what to do about the else, so if I change its indentation and Format the document (Edit -> Advanced) then it doesn't change else's indentation.

This is in my opinion a bug (or lack of feature) since you obviously would want the else-clause to be indented to the same level as the if-clause.

You could also put an #if directive before an else-clause. In this case MSVC# insists on indenting the else-clause by exactly 1 space.
      if (true) {
        DoSomething();
      }
#if DEBUG
 else {

Again, I would expect the else-clause to be indented to the same level as the if-clause. Would you disagree with that?

I fully understand why it doesn't happen though. (After the compiler has parsed the #if directives, all it reads is } else { and therefore it places a space before the else-clause just like I told it to by disabling the new-line-before-else option.)

But I definitely consider it a bug. Don't you?
GeneralRe: #if indentation Pin
PIEBALDconsult29-Jan-10 12:20
mvePIEBALDconsult29-Jan-10 12:20 
GeneralRe: #if indentation Pin
Luc Pattyn29-Jan-10 12:49
sitebuilderLuc Pattyn29-Jan-10 12:49 
GeneralRe: #if indentation Pin
Not Active29-Jan-10 13:17
mentorNot Active29-Jan-10 13:17 
JokeRe: #if indentation Pin
DaveyM6929-Jan-10 13:45
professionalDaveyM6929-Jan-10 13:45 
GeneralRe: #if indentation Pin
#realJSOP30-Jan-10 8:08
mve#realJSOP30-Jan-10 8:08 
GeneralRe: #if indentation Pin
Not Active29-Jan-10 13:05
mentorNot Active29-Jan-10 13:05 
JokeRe: #if indentation Pin
F2dk29-Jan-10 20:46
F2dk29-Jan-10 20:46 
GeneralRe: #if indentation Pin
#realJSOP30-Jan-10 8:25
mve#realJSOP30-Jan-10 8:25 
GeneralRe: #if indentation Pin
#realJSOP30-Jan-10 8:11
mve#realJSOP30-Jan-10 8:11 
GeneralRe: #if indentation Pin
Not Active30-Jan-10 13:19
mentorNot Active30-Jan-10 13:19 
GeneralRe: #if indentation [modified] Pin
#realJSOP30-Jan-10 8:33
mve#realJSOP30-Jan-10 8:33 
GeneralRe: #if indentation Pin
Not Active30-Jan-10 13:18
mentorNot Active30-Jan-10 13:18 
Questionbuilding a safe environemnt to run suspicious EXEs Pin
Mohamed hossam29-Jan-10 7:02
Mohamed hossam29-Jan-10 7:02 
AnswerRe: building a safe environemnt to run suspicious EXEs Pin
EliottA29-Jan-10 7:48
EliottA29-Jan-10 7:48 
GeneralRe: building a safe environemnt to run suspicious EXEs [modified] Pin
Mohamed hossam29-Jan-10 9:16
Mohamed hossam29-Jan-10 9:16 
AnswerRe: building a safe environemnt to run suspicious EXEs Pin
Ravi Bhavnani29-Jan-10 8:46
professionalRavi Bhavnani29-Jan-10 8:46 
GeneralRe: building a safe environemnt to run suspicious EXEs Pin
Mohamed hossam29-Jan-10 9:41
Mohamed hossam29-Jan-10 9:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.