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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:18:29+00:00 2026-05-14T04:18:29+00:00

When we define a property like public string Name {get; set;} dot net can

  • 0

When we define a property like

    public string Name {get; set;}

dot net can make our properties code. but when we use

    public string Name {get;}
    public string Name {set;}

we face with

'Hajloo.SomeThing.PropertyName.set' must declare a body because it is not marked abstract or extern. Automatically implemented properties must define both get and set accessors.

Actually why the compiler can’t determine the property and make code automatically? What’s the problem?

  • 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-14T04:18:30+00:00Added an answer on May 14, 2026 at 4:18 am

    Because the auto-implemented properties generate their own backing store for the property values. You have no access to the internal store.

    Implementing a property with

    • just get : means you can only retrieve the values. You can’t ever set the property value (even in the containing class)
    • just set : means you can only set the values. You can’t retrieve the property value.

    for a normal property

    private int _data;
    public int Data{  get { return _data } };
    

    Here the parent class can do the following somewhere else in the class ( which it can’t with auto props)

    _data = 100;

    Note: You can define an auto-prop like this (which is how I use it the most).

    public int Data { get; private set;}
    

    This means that the property can’t be set by external clients of the class. However the containing class itself can set the property multiple times via this.Data = x; within the class definition.

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

Sidebar

Related Questions

I can't get rid of compiler warning when I define property inside protocol. Strange
I have a hierarchical data classes like public class MyNode { public string Name
I'd like to use the image property tag constants defined in GDI+ from .NET.
If we define a property as public property and in this property we have
In XAML, you can define a size property (such a length or width) in
I need to get the value of a property defined in a lambda public
Here is my class : public class PrimtivePropertyProxy<T> : FrameworkElement { public string Name
I have defined my struct like this: struct Test { private string assayName; public
Say I have a type that implements a property with a string type: public
I have a State class defined like this: Public Class State Public Property StateId

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.