How do you resolve the common collsision between type name and object name?

Posted by Catskul on Stack Overflow See other posts from Stack Overflow or by Catskul
Published on 2010-03-12T18:05:23Z Indexed on 2010/03/12 18:07 UTC
Read the original article Hit count: 205

Filed under:
|
|
|

Since the convention is to capitalize the first letter of public properties, the old c++ convention of initial capital for type names, and initial lowercase for non-type names does not prevent the classic name collision

class FooManager
{
    public BarManager BarManager { get; set; } // Feels very wrong.
                                               // Recommended naming convention?
    public int DoIt()
    {
         return Foo.Blarb + Foo.StaticBlarb; // 1st and 2nd Foo are two 
                                             // different symbols
    }
}

class BarManager
{
    public        int Blarb { get; set; }
    public static int StaticBlarb { get; set; }
}

It seems to compile, but feels so wrong. Is there a recommend naming convention to avoid this?

© Stack Overflow or respective owner

Related posts about c#

Related posts about naming-conventions