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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T19:45:47+00:00 2026-05-16T19:45:47+00:00

I’ve read some article about String.Empty vs and I also do test by my

  • 0

I’ve read some article about String.Empty vs “” and I also do test by my self. Different between them are below.

String.Empty

L_0001: ldsfld string [mscorlib]System.String::Empty

“”

L_0001: ldstr ""

After I talk with my friends they argue that String.Empty is faster than “” because under the hood (at assembly level) ldstr do more 1 circle than ldsfld. (I can’t remember steps that make them different)

I want to know how can I check about this aspect of performance.

  • 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-16T19:45:47+00:00Added an answer on May 16, 2026 at 7:45 pm

    The ldsfld operation pushes the value of a static field onto the evaluation stack, while the ldstr pushes a reference to a meta data string literal.

    The performance difference (if any) would be minimal. Newer versions of the compiler actually substitutes "" for String.Empty.

    You should also consider the readability and maintainability of the code. Using String.Empty it’s clearer that you actually mean an empty string and not just forgot to type something in the string literal.

    Edit:

    I took a look at the native code created.

    C# 3, release mode, x86:

            string a = String.Empty;
    0000002a  mov         eax,dword ptr ds:[0356102Ch]
    0000002f  mov         dword ptr [ebp-8],eax
            string b = "";
    00000032  mov         eax,dword ptr ds:[0356202Ch]
    00000038  mov         dword ptr [ebp-0Ch],eax
    

    C# 3, release mode, x64:

            string a = String.Empty;
    0000003b  mov         rax,12711050h 
    00000045  mov         rax,qword ptr [rax] 
    00000048  mov         qword ptr [rsp+28h],rax 
            string b = "";
    0000004d  mov         rax,12713048h 
    00000057  mov         rax,qword ptr [rax] 
    0000005a  mov         qword ptr [rsp+30h],rax 
    

    So, in the end the code is identical.

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
I've got a string that has curly quotes in it. I'd like to replace
Specifically, suppose I start with the string string =hello \'i am \' me And
I am reading a book about Javascript and jQuery and using one of the

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.