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

  • Home
  • SEARCH
  • 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 6968605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:28:23+00:00 2026-05-27T16:28:23+00:00

I learned c# recently, so when I learned to write properties, I was taught

  • 0

I learned c# recently, so when I learned to write properties, I was taught to do it like this:

public string Name { get; set; }

Auto properties are great! But now I’m trying to do something a little more complicated, so I need to write a custom pair of accessors.

private string _Name;
public string Name {
    get { return _Name; }
    set { _Name = value }
}

I know the compiler makes a private instance variable down in it’s murky depths when one uses autos, but I’m spoiled and don’t want that private variable sitting around looking pointless.

Is there a way to use custom accessors without a private variable?

  • 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-27T16:28:24+00:00Added an answer on May 27, 2026 at 4:28 pm

    Properties don’t need backing variables (fields) at all. While they can be used for encapsulating simple fields you can also use them to access other data.

    public Decimal GrandTotal { get { return FreightTotal + TaxTotal + LineTotal; } }
    

    or

    public string SomeStatus { get { return SomeMethodCall(); } }
    

    If the goal is to simply encapsulate some field with a property you would need some sort of backing field if you are not using automatic properties.

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

Sidebar

Related Questions

I've recently learned to write my own WebControls, but I'm still hazy on the
I recently asked about functional programs having no side effects, and learned what this
I've recently started learning C#. I just learned about properties and decided to make
I recently learned that I can get hg log to print the history in
Introduction Hello folks, I recently learned to program in C! (This was a huge
I recently learned about strides in the answer to this post , and was
UPDATE: I recently learned from this question that in the entire discussion below, I
I've recently learned that i shouldn't store html encoded data in the database, but
I've just recently learned C# and am interested in .net but I don't know
I recently learned that when using onclick, for a button, the field name 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.