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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:08:51+00:00 2026-05-14T05:08:51+00:00

Looking at the new VB 2010 features, I stumbled upon support for Auto-Implemented Properties

  • 0

Looking at the new VB 2010 features, I stumbled upon support for Auto-Implemented Properties.

Since I’m working with C#, this seemed quite familiar, but I noticed that VB did add a feature I would love to have in C#: setting an arbitrary default value for the auto-implemented property:

Public Class Person

    Property Name As String = "Scott Guthrie"
    Property Age as Integer = 35

End Class

I really like the clean usage of auto-properties in C#. This would save us the effort of introducing a backing field and hooking it up to the property every time we simply need a default value, thereby cluttering up the code unnecessarily.

I was wondering why this wasn’t introduced in C# as well? What could be the rationale for not doing this? Is a syntax discussion going on, or are there technical limitations to implementing this?

  • 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-14T05:08:52+00:00Added an answer on May 14, 2026 at 5:08 am

    What about:

    public class Person
    {
        public Person() 
        {
             this.Name = "Scott Guthrie";
             this.Age = 35;
        }
        public string Name { get; set; }
        public string Age { get; set; }
    }
    

    in practice, that comes down to the same and isn’t that much extra work, I believe. But perhaps, for once in a long while, VB looks clearer then C#… 😉

    EDIT (rationale):
    You were asking for the rationale in your last comment under (and in) your original question. Thinking out loud, I think that the principle in C# that initialization code goes to one place and one place only, namely the constructor, is the reason for this decision. Adding another place where you have to look to find initialization code makes debugging harder and the code less clear.

    Obviously, an inline initialization value cannot contain other initializations or calculations (at least, very limited). While I agree that it can be more concise in the VB way, I would understand the C# team and Anders Hejlsberg if they said that they consider it a bigger advantage to have one place for initialization.

    EDIT: here’s what Microsoft says about it. In short, not for C# 4.0, but perhaps C# 5.0? Also:

    “It is not as easy as it sounds though:
    the next thing you want is for the
    constructor to initialize the backing
    field, but it can only do that through
    the setter, which might not be what
    you want.”

    and (just a commenter):

    “Lack of initialization or constructor
    control makes the feature practically
    worthless for properties returning a
    reference type.”

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

Sidebar

Related Questions

I'm very new to Visualforce. I'm looking at this page here: http://force.siddheshkabe.co.in/2010/11/displaying-aggregate-result-on.html So when
I've been looking at the new features in C++11 and it really looks like
I am testing out the new database project features of Visual Studio 2010 and
I've been looking into TFS2010 new build and deployment features with MSDeploy. So far
I'm new to TFS 2010 (Team Foundation Server 2010) and I'm looking forward to
Currently looking into learn new technology and silverlight is on the potential list. However,
I'm looking at a new computer which will probably have vista on it. But
I'm looking at a new project and we are wanting to use Flex (to
I'm looking at a new project where both Native and Managed approaches sound like
I have been looking at the new database server we are setting up for

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.