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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:49:24+00:00 2026-06-04T17:49:24+00:00

Today I was creating a default parameter value in a constructor. public SomeClass (String

  • 0

Today I was creating a default parameter value in a constructor.

public SomeClass (String something = String.Empty)
{
   // ...
}

The compiler complained.

Default parameter value for “something” must be a compile-time
constant.

I was under the impression that Empty on the String class was a compile-time constant.

.field public static initonly string Empty

Am I missunderstanding the meaning of compile-time constant, or is it just more wackyness that I need to accept?

  • 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-06-04T17:49:25+00:00Added an answer on June 4, 2026 at 5:49 pm

    The accepted answer to this SO Question Why isn’t String.Empty a constant? is:

    The reason that static readonly is used instead of const is due to use with unmanaged code, as indicated by Microsoft here in the Shared Source Common Language Infrastructure 2.0 Release. The file to look at is sscli20\clr\src\bcl\system\string.cs.

    The Empty constant holds the empty string value. We need to call the String constructor so that the compiler doesn’t mark this as a literal.

    Marking this as a literal would mean that it doesn’t show up as a field which we can access from native.

    I found this information from this handy article at CodeProject.

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

Sidebar

Related Questions

Today I was creating new instances and I noticed something weird on it. I
Today i was trying to study about frameset by creating a few pages ,
I ran into a little problem today when I was creating a really quick
This is a follow-up to another question I asked earlier today. I am creating
today I started creating and using 9-Pacth images. But my Device does not recognize
Today morning I wake with this weird issue where mongoid was creating a record
I just noticed today that a website I am creating has the WWW or
So, I'm just beginning C# today in hopes of creating a screen shot program.
Today my question is how would I go about creating a view in a
I came across some weird behavior today around creating an object from the return

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.