次の方法で共有


privateMembers?

How do you name your private members?

camelCased or PascalCased?

I think the use of camelCase syntax to name the private members provides a high level of readibality because you know where you are (Public or private) without to look to the member definition.

However, reading code from GDN, people prefer to use PascalCase for everything. All the documentation I've found talking about this topic, only covers Public members so, I suppose you should have freedom to name your privates as you want, but inside a team a general coding standard is a good thing.

What do you think?

Comments

  • Anonymous
    February 06, 2004
    I'd recomend using camelCase for private member and Pacal for public.

    some people also prefix private members with "_", but I find it messes up intellisense ;)
  • Anonymous
    February 06, 2004
    I believe that FxCop requires camelCase. I try to keep my systems as FxCop compatible as possible.
  • Anonymous
    February 06, 2004
    Ditto (although for readability's sake, not to appease the FxCop gods :)
  • Anonymous
    February 06, 2004
    I tend to use camelCase for private and public and PascalCase for classes .. that's how I can keep things straight..

    IMHO
    Jake
  • Anonymous
    February 06, 2004
    camelCase and I prefix all access to them using "this." to easily identify what is a member versus local, etc.
  • Anonymous
    February 06, 2004
    Because I use a m_ prefix I find PascalCase easier to read:

    m_firstName
    m_FirstName
  • Anonymous
    February 07, 2004
    I use
    _firstName

    It works both in C# and VB.NET.
  • Anonymous
    February 10, 2004
    camelCased with an underscore in front of it.

    _firstName, just as Jan.
  • Anonymous
    February 10, 2004
    _firstName for me.

    And I don't prefix them with this. either when accessing them.

    Public = FirstName
    Private = _firstName
    local = firstName

    That's why I use the underscore, to distinguish between local and private. Without it, it's possible to get clashes and it makes the code more readable (IMO).
  • Anonymous
    February 10, 2004
    I prefer _camelCase for private and PascalCased for public
  • Anonymous
    February 10, 2004
    The comment has been removed
  • Anonymous
    February 10, 2004
    I don't really like the idea of _privateVar but in practice it makes my life easier than privateVar
  • Anonymous
    February 10, 2004
    The comment has been removed
  • Anonymous
    February 10, 2004
    The comment has been removed
  • Anonymous
    February 10, 2004
    I use camelCase for private fields, _camelCase for fields that back properties, and PascalCase for everything else.
  • Anonymous
    February 10, 2004
    m_camelCase for private fields.
  • Anonymous
    February 18, 2008
    Rido has post a kind of poll about the naming of private members. Some comments on using PascalCase,