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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T14:56:26+00:00 2026-05-10T14:56:26+00:00

I was wondering what people thought of using properties as object initializers in C#.

  • 0

I was wondering what people thought of using properties as object initializers in C#. For some reason it seems to break the fundamentals of what constructors are used for.

An example…

public class Person {     string firstName;     string lastName;      public string FirstName     {       get { return firstName; }       set { firstName = value; }     }      public string LastName     {       get { return lastName; }       set { lastName= value; }     } } 

Then doing object intialization with…..

Person p = new Person{ FirstName = 'Joe', LastName = 'Smith' }; Person p = new Person{ FirstName = 'Joe' }; 
  • 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. 2026-05-10T14:56:27+00:00Added an answer on May 10, 2026 at 2:56 pm

    What you see here is some syntatic sugar provided by the compiler. Under the hood what it really does is something like:

    Person p = new Person( FirstName = ‘Joe’, LastName = ‘Smith’ );

    Person _p$1 = new Person(); _p$1.FirstName = 'Joe'; _p$1.LastName = 'Smith'; Person p = _p$1; 

    So IMHO you are not really breaking any constructor fundamentals but using a nice language artifact in order to ease readability and maintainability.

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

Sidebar

Related Questions

I was wondering if people could post some examples of interesting websites and web
I'm just wondering what people are using for a Data Access Layer in Monotouch?
Just trying to canvas some opinions here. I was wondering how people go about
I'm wondering what's people using to correctly capitalize english strings since ''capitalize'' won't do
I was wondering what people thought of doing something like var x = obj.child.prop1;
Just wondering of what people think of using MonoTorrent and the torrent protocol as
I was wondering how people would approach the problem of merging two 3D objects?
I'm wondering how people are currently resetting their data / cleaning up test remnants
I was wondering if people would share their best practices / strategies on handling
I was discussing this at work, and was wondering where people start their designs?

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.