Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 678803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:11:23+00:00 2026-05-14T01:11:23+00:00

To sum it up, there are two basic trains of thought: The private field

  • 0

To sum it up, there are two basic trains of thought:

  • The private field should just be CamelCase to match the .NET guidelines
  • The private field should be CamelCase but with a _ pre-appended to tell the difference between method scope variables and class scope variables.

Original Post

Take the following example

public class Class1{

    public string Prop1{
        get {return m_Prop1;}
        set {m_Prop1 = value; }
    }
    private string m_Prop1; // This is standard private property variable name.

    // How do we cap this variable name? While the compiler can figure out same casing
    // it makes it hard to read.
    private Class2 Class2;

    // We camel case the parameter.
    public Class1(Class2 class2){
      this.Class2 = class2;
    }
}

Here are my stock rules

  • The class name is capitalized (Class1)
  • The public properties are capitalized (Prop1)
  • The private field tied to a public property has m_ to indicate this. My coworker prefers _. There is some debate if using m_ or _ should be used at all, as it is like Hungarian notation.
  • Private class fields are capitalized.

The part I am trying to figure out is what do I do if when the class name of a private field matches the private field name. For example, private Class2 Class2;. This is confusing.

If the private field name is not the same class, for example private string Name;, there isn’t much issue.

Or am I thinking about the issue in the wrong way? Should my classes and private fields be named in such a way that they don’t collide?

===

The consensus below is to use lower case private property names, but then we have this issue.

class1{
    private string name; // This is scoped to the class.

    public void Set(){
      string firstName; // This is scoped to the method.
      .... // Lot of code.
      // Should use this.name but nothing prevents.
      // Now there is confusion if name is a class property or scoped to the method.
      name = firstName;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:11:24+00:00Added an answer on May 14, 2026 at 1:11 am

    Or ReSharper’s guidelines.

    Private properties, are cased like any other property.
    Private fields, are lower case, starting with an underscore.

        private string _foo = string.Empty;
        private string Bar { get; set; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm sure there is a quick and easy way to calculate the sum of
I have one field that I need to sum lets say named items However
This may be a simple fix - but I'm trying to sum together all
I have datatable and there two column which is type of string and I
My report Groups by two fields, the second being a date field. If I
There are two formulae which I am finding it difficult to represent in MATLAB
I'm trying to figure out the overall ratio for users. There is basically two
I would like to create a safe sum extension method that would have the
So here is the original query SELECT SUM(PickQty), SUM(ReqQty), AssignmentID, StopID FROM PickRequest GROUP
function get_total_adults() { $sql = SELECT SUM(number_adults_attending) as number_of_adults FROM is_nfo_rsvp; $result = mysql_query($sql)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.