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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:18:43+00:00 2026-05-15T11:18:43+00:00

Why was String designed as a reference type instead of value type? From the

  • 0

Why was String designed as a reference type instead of value type?

From the modeling perspective I would have modeled it as a value type since it represents something without identity. It doesn’t have distinguishing attributes. (E.g I can’t make any difference between one string “a” and another string “a”)

I know that I would have had serious performance problems having long strings stored on the stack. Probably it’s impossible, as strings get very long, because stack is limited in size.

If it weren’t for the performance why would you design System.String as a reference type?
(Assume any possible string is at most 16 bytes long)

  • 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-15T11:18:44+00:00Added an answer on May 15, 2026 at 11:18 am

    Structs need to be fixed size. Think of a string[], for example. The only way you could have string as a value-type would be to store just the pointer. Which is essentially what we achieve by using a reference-type.

    Of course, it is also hugely beneficial that we don’t copy the string every time we assign it.

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

Sidebar

Related Questions

How do I reference a constant string in my .designer.cs file? A straight forward
The code below is designed to take a string in and remove any of
I have a class that is designed to dynamically load a .dll or .so
I have a UserControl that is part of a Class library. I reference this
I have a simple function that's designed to copy a section of an xml
JasperReports newbie here. I have read the tutorial and the quick reference and read
I have an control that inherits from another control (TxTextControl). I have a SelectedText
Is there an open source, reference implementation of a simple, correctly designed, best practiced,
I have a question very similar to How do I allocate a std::string on
I have this VBA below that is designed to loop through each WS and

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.