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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:49:01+00:00 2026-05-15T14:49:01+00:00

We have Object and ValueType …. And String …. String is derived from object,

  • 0

We have Object and ValueType…. And String….

String is derived from object, but it is immutable. Is it considered a type of it’s own as it doesn’t behave like other objects? Is it the only object that has this immutable behaviour? Is it the runtime, compiler or library that defines this? And are there other cases like this in .Net?

Edit: Yes, I too create classes that isn’t allowed to change after constructed; immutable objects. But isn’t string more special than 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-15T14:49:01+00:00Added an answer on May 15, 2026 at 2:49 pm

    string is a reference type. There are plenty of other immutable types though, and you can create your own: just don’t provide any members which change the state! Here’s an example:

    public class Int32Wrapper
    {
        private readonly int value;
        public int Value { get { return value; } }
    
        public Int32Wrapper(int value)
        {
            this.value = value;
        }
    }
    

    Of course, string also overloads == and !=, overrides Equals and GetHashCode etc… all of which can be done in your own types too.

    string does have some genuinely special properties though:

    • It’s the only reference type for which there’s a literal format in IL (and in supporting languages)
    • There are IL instructions which specifically use strings
    • Other than arrays, string is the only type where the size of the object which varies by instance. (Other types vary depending on the CLR you’re using, but for any one CLR, all instances of other types will have the same size – strings and arrays vary by content.)
    • If you call new String(new char[0]) repeatedly, you’ll get the same reference every time
    • It interacts with the interop marshaller in magical ways 🙂
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 436k
  • Answers 436k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think that your selector is working just fine -… May 15, 2026 at 3:51 pm
  • Editorial Team
    Editorial Team added an answer Well after a bit of research, I have found a… May 15, 2026 at 3:51 pm
  • Editorial Team
    Editorial Team added an answer Here is one that would work for .NET, following your… May 15, 2026 at 3:51 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.