Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide curly braces in C#

After getting back into Python, I'm starting to notice and be annoyed more and more by my C# coding style requiring braces everywhere

 if (...)
 {
     return ...;
 }
 else
 {
     return ...;
 }

preferring the (subjective) much cleaner looking python counter-part

if ...:
    return ...
else
    return ...

is there any way I can go about hiding these braces (as they do take up about 30% of my coding screen on average and just look ugly!)

like image 355
Joe Avatar asked Jan 30 '11 23:01

Joe


2 Answers

Sorry, but if you're coding in C# and doing more than just simple single-expression blocks, you're going to have to suck it up. Python's "indent-denotes-scope" grammar may be nice, but it's Python, not C#.

like image 158
Moo-Juice Avatar answered Sep 28 '22 06:09

Moo-Juice


You could switch to:

 if (...) {
     return ...;
 } else {
     return ...;
 }

to gain some screen.

I think it's a bad idea to pretend that C# works like Python though.

like image 45
Skilldrick Avatar answered Sep 28 '22 07:09

Skilldrick