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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:36:02+00:00 2026-06-07T08:36:02+00:00

Im not sure because in Java getter/setter are looking a little bit different but

  • 0

Im not sure because in Java getter/setter are looking a little bit different but whats the “c# way” to code this stuff?

Option a.)

    private string name;

    public string Name
    {
        get { return name; }
        set { name = value; }
    }

    private int time;

    public int Time
    {
        get { return time; }
        set { time = value; }
    }

b.)

    private string _name;
    private int _time;

    public string name
    {
        get { return _name; }
        set { _name = value; }
    }

    public int time
    {
        get { return _time; }
        set { _time = value; }
    }

c.)

   public string name {get; set;}
   public int time {get; set;}

Ok there are some examples. What would look better? Should I write all the private variable declarations first then the properties or should I group my variable and property declaration next to each other.

  • 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-06-07T08:36:04+00:00Added an answer on June 7, 2026 at 8:36 am

    How about d, following .NET naming conventions:

    public string Name { get; set; }
    public int Time { get; set; } // Odd type for time, admittedly...
    

    Don’t bother writing the property manually yourself unless you do something non-trivial in it.

    If you do write the property implementation manually, it’s up to you how you name the private variable. Personally I’d use:

    private string name;
    public string Name
    {
        get { /* whatever */ }
        set { /* whatever */ }
    }
    

    … but if you want to use underscores, that’s your prerogative.

    As for ordering of members – that’s even more your own choice. Assuming you’re working with a team, talk with the team and see what the local convention is.

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

Sidebar

Related Questions

I'm not sure if this is the best way to ask this question but
I'm learning OOP in Java, but I'm not sure how to implement this reference
I need start off with code because I am not sure what terminology to
I'm not sure StackOverflow is the right place to ask this question, because this
I am having trouble with this setup mainly because I am not sure what
I'm rather sure I haven't found an answer to this because I'm not sure
The question title is a bit strange because I'm not exactly sure how to
I'm sure this must have been covered before because I'm sure I'm not the
Not sure whats going on here, or what could be the integer in this
Not sure how to ask this, but i'll give it a try: I have

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.