views:

112

answers:

3

I've never understood this, and frankly, it pisses me off to see it in code: variable names that begin with an underscore.

What is the point of this?

I've just installed Resharper 5.1, trying it out and it seems nice, though this one thing is ruining it for me.

I haven't checked, but I'm hoping I can turn it off. But why is it done in the first place?

+1  A: 

It's a common practice to use underscores to denote class variables.

There should be an option in ReSharper to configure what, if anything, you want your class variables to start with. I don't have it installed on this machine so I can't easily check what that option is.

ChrisF
+3  A: 

It's a pretty common style for private fields, some use m_lowerCamelCase, others only _lowerCamelCase and still others lowerCamelCase. For variables inside a functions it's a lot more rare and reshaper by default use lowerCamelCase for them.

Note that the naming section of the design guidelines discourage the use of prefixes for public members but private members are not concerned (And public fields should be used only in really specific cases due to their dangers anyway).

In the reshaper options all of that could be changed in Languages > Common > Naming Style.

You could also save your parameters in the solution or in a file and import/export them. Using that you could set the parameters once and for all for everyone in your team.

VirtualBlackFox
+1  A: 

Prefixing private instance and/or static members of various kinds with an underscore is a widely-adopted practice ([citation needed], obviously, but it is); this is not the place for me to discuss its rights and wrongs.

In ReSharper | Options you will see Languages | Common | Naming Style (and per-language overrides) that will allow you to instruct ReSharper to do exactly as you wish instead.

AakashM

related questions