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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:06:34+00:00 2026-05-16T03:06:34+00:00

I read recently that the C# and CLI standards define different ways to handle

  • 0

I read recently that the C# and CLI standards define different ways to handle value types and constructors.

According to the CLI specification value types can’t have parameterless constructors, whereas in the C# specification value types have a default parameterless constructor. If, according to the CLI specification, you need to create a value without specifying any parameters, there’s a special instruction to do that with.

So my questions are

  • why would the C# designers intentionally deviate from the CLI standard – what benefit was there to this, and why doesn’t the CLI allow this functionality?
  • in my limited experience, any time I find myself using a ‘special instruction’ to allow for functionality that wasn’t initially intended, it’s usually a bit of a hack. How is this different?
  • 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-16T03:06:35+00:00Added an answer on May 16, 2026 at 3:06 am

    In various places, it makes sense from a consistency point of view to think of value types as having a parameterless constructor. You can always create a value without providing any arguments, and that’s true in both the CLI and C#. In C#, you can just use standard constructor syntax:

    int x = new int();
    

    rather than there being one syntax for this and a different syntax for invoking a “real” constructor.

    Note that as of C# 2, there’s the default value operator which I suppose could have been used instead:

    int x = default(int);
    

    That feels closer to the IL generated, really. I suppose it’s just possible that if we’d had that to start with, C# wouldn’t have “pretended” that all value types have parameterless constructors.

    On the other hand, consider generics:

    public void Foo<T>() where T : new()
    {
        T t = new T();
    }
    

    Should that be allowed for value types? It is – but if C# didn’t allow new int() then it wouldn’t make much sense to allow it in a generic form…

    One interesting point you may want to look at in more depth – although C# won’t let you define a custom value type parameterless constructor, you can do so in IL, and C# will sometimes use it (and sometimes not) depending on the context. See my blog entry for more details.

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

Sidebar

Related Questions

I read recently (I can't recall where, or I'd return to that source) that
I recently read a text regarding buffer overflows that mentioned that setting breakpoints can
I recently read that php applications can be deployed on Google App Engine using
I recently read that you can predict the outcomes of a PRNG if you:
I recently read somewhere that one of ways of tuning SQL query is that
I recently read that because of how InnoDB recalculates the AUTO_INCREMENT value when the
I've read recently that iOS is message based. Is that similar to an event-based
I recently read that getters/setters are evil and I have to say it makes
I recently read in a presentation on Scribd that Facebook had benchmarked a variety
I recently read through Code Complete, and it recommends that I create a project

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.