views:

89

answers:

4

ReSharper extension of VS suggest me to use PascalCase in below property.

public Color Color { get; private set; }

Here Color is Enum type. I would never thought this can be possible because it is same name with type. But it is valid. Is it something suggested by general rules ? Do I have to listen ReSharper always ? Would be appreciated good reference links for PascalCase.

+6  A: 

This is called the Color Color problem actually and is explained here;

http://blogs.msdn.com/b/ericlippert/archive/2009/07/06/color-color.aspx

And yes, it is supposed to work and follows the naming typically agreed upon naming convention rules. I would leave it as you show it in your example.

Ed Swangren
Actually, this code could *introduce* the Color Color problem, but the property itself is perfectly valid because the syntax for properties is always `accessmodifier(s) type Name`
R. Bemrose
I get shocked that there is same naming problem with my spesific question.
Freshblood
@R. Bemrose: Yes, I probably could have worded that better, but I think that the OP gets what I was driving at.
Ed Swangren
A: 

Yes this is recommended. I suggest that you folloe ReSharper guidelines, especially if you are new to programming.

Wikipedia article about CamelCase has some useful information.

kgiannakakis
A: 

The syntax highlighting on here makes it particularly confusing, but the compiler know when to expect a type and when to expect a name so its no problem.

Paul Creasey
A: 

http://msdn.microsoft.com/en-us/library/ms229043.aspx

The following guidelines provide the general rules for identifiers.

Do use Pascal casing for all public member, type, and namespace names consisting of multiple words.

Listen to ReSharper ;)

Dimps
Listen to ReSharper for just this spesific question or for everything?
Freshblood
Just for this specific question.I do not have enough ReSharper experience, but looks like it is always right.
Dimps
You shouldn't blindly listen to anything, and that goes beyond programming. The OP wanted to know the "why" behind the suggestion, which is a good thing.
Ed Swangren
@Ed Swangren - You are right
Freshblood