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 379463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:53:39+00:00 2026-05-12T14:53:39+00:00

In a book I been reading they use a capital letter for public methods

  • 0

In a book I been reading they use a capital letter for public methods and properties. I know there are some other conventions like you put “_” in front of private variables. For me I don’t like that way and like this way better but just wondering about stuff in the method.

So

public void MyMethod()
{
}

public string MyProperty {get; set;

}

and for private

private void myMethod()
{
}

But how about in the method?

like

public void MyMethod()
{
   string MyVariable = null;
   // or
   string myVairable = null;
}

Also how about if you have sort of a global variable like

public class Test
{
   private string bob;

   public Test()
   {
      bob = null;
   }
}

so should it be lowercase(since it is private)? Also on a side note would it better just make it a property but instead of a public property just have it private.

  • 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-12T14:53:39+00:00Added an answer on May 12, 2026 at 2:53 pm

    Here are your code examples as they would be if they followed official Microsoft code style guidelines (enforced by StyleCop and FxCop)

    public void MyMethod()
    {
    }
    
    public string MyProperty { get; set; }
    
    private void MyMethod()
    {
    }
    
    public void MyMethod()
    {
       string myVariable = null;
    }
    
    public class Test
    {
       private string bob;
    
       public Test()
       {
          this.bob = null;
       }
    }
    

    Some highlights from the spec: all fields should be private and lower case (except if they’re constant). All methods should be Capitalised, whatever the access. If you want to expose a field (i.e. make it public or protected), use a property (which should be capitalized if it’s protected or public). If you have automatic getters and setters for properties (i.e. just get; and set;), they can be on one line, otherwise on separate lines (if there’s more code). Always name fields starting with lower case a-z, not underscores. Braces should be on a new line. Always reference non-static members (i.e. properties, methods, fields) with this. to distinguish them from variables and to avoid ambiguity.

    There’s a huge list but these are the most relevant to your examples. Look at code.msdn.microsoft.com/sourceanalysis

    And what you call ‘global’ in your question is in fact a ‘field’. These should never be exposed (as I said above) because you’re exposing your implementation when in fact your behaviour is all you should expose on the interface to a type. Properties allow you to specify an interface and, even if they’re implemented as automatic properties now, you can change the getters and setters later without changing the interface.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm reading the Rails 3 In Action book and they introduce some BDD with
I've been reading the Beginning iPhone 4 Development book and they have one tutorial
I have been reading some recipes in the Perl Hacks book. Recipe #24 Query
Ok I am new to MongoDB and been reading a book about it, some
I have been reading The Little Book of Semaphores and in page 41 there
I've been reading a book on Zend framework and there's this HTML/PHP code section
I've been reading a book on the cocos2d framework for ios5 for a few
I've been reading O'Reilly book Dojo - The Definitive Guid but somethings are still
I've been reading a book which is in C#. I'm a VB.NET developer (and
I have been reading from the book The C Programming Language learning C, and

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.