What is a good naming convention to differentiate a class name from a property in C#?
c#, design-patterns, naming-conventions
Solution
This is actually a very common pattern in .Net programming. Particularly so with enum types and members as it's the .Net Design Guidelines recommended way of programming.
4.0 design guidelines reference
- http://msdn.microsoft.com/en-us/library/ms229012(v=VS.100).aspx
While it may be a bit confusing, it's not once you've seen it a few times. The tools well support this pattern and given one is a type and the other an instance it's hard to accidentally invert them without causing a compilation error.
Problem
I run into this frequently enough that I thought I'd see what others had to say about it. Using the StyleCop conventions, I find that I often have a property name that is hard to make different than the class name it is accessing. For example: ``` public class ProjectManager { // Stuff here } public class OtherClass { private ProjectManager ProjectManager { get; set; } } ``` It compiles and runs, but seems like it would be an easy way to confuse things, even with the use of "this".