5

I absolutely HATE the leading underscore in .NET variables.

I systematically destroy them 😈

Comments
  • 2
    @lambda123 there ARE good potential reasons for that, though. like creating an instance of the whole application to use in automated e2e-tests.
  • 6
    Leading underscore for private readonly fields.

    Anything else and the PR is getting rejected.
  • 1
    interesting.

    New to C#, coming from Python, I place underscore for local vars (i.e func input params).

    Am I the worst?
  • 1
    @Nihil75 Nope, its just a deprecated practice (at least most of the C# devs I met agree with this, not sure of the community as a whole)
  • 2
    Agree. We have stopped using Hungarian notation for a reason.

    I also hate C#'s capitalization convention.
    Almost everything is capitalized. Types, namespaces, generics, properties, public variables, methods, enum cases. There is no clear rule or reasoning behind why something is capitalized or not. It’s completely arbitrary.
  • 0
    @lambda123 You "hate" that it allows you freedom to code however you want?

    Really?

    Is it the language's fault that someone does weird, uneccessary, complicated or downright wrong things with it?

    Please name a language that doesn't allow you to do that. Including spoken languages.

    Bad tradesmen blame their tools. Don't be a bad tradesman. Don't blame your tools.
  • 1
    OP: for the record, I am not a big fan of underscores either. It looks ugly, but I have learned to ignore it. I am an eager user of keyboard shortcuts in VS, so most of the time they are declared for me.
  • 2
    @lambda123 Shit, you're right! I just re-read it now, I interpreted it the wrong way.

    Sorry, my bad! 😖
  • 1
    Leading underscores are commonwealth metasyntax for "ignore" or "do not use"; names which are accessible due to limitations of the language's visibility system but weren't meant to be used by the majority of code which has them in-scope, which are planned to be used by future code, or which exist purely to satisfy language rules such as unused parameter names. Python's private properties are a good example. Does C# use them in any other way?
  • 2
    @lbfalvy in C# a leading underscore signifies it is a private member of the class (though C# is strongly typed, therefore this underscore is by definition superfluous)

    What I mean is your editor shows and knows what are the private class fields so there is no need to add an extra character to show this.
Add Comment