Is string a value type or a reference type?
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Priya LingeRank #785 · 2.9K reputationPosted Dec 4, 2011, 7:00 PM EST
1.String is a refrence type.
2. Its not value type as value-types need a known size for the stack etc. As a reference-type, the size of the reference is known in advance,
even if the size of the string isn't.
Hope this will help you.
Thanks.
Pravin MoreRank #1,419 · 1.2K reputationPosted Dec 4, 2011, 6:54 PM EST
A String is a reference type even though it has most of the characteristics of a value type .Strings a can be huge, and need to be stored on the heap. Value types are stored on the stack.
Thanks,
Pravin.
Satyapriya NayakRank #47 · 31.5K reputationPosted Dec 4, 2011, 8:02 PM EST
String is a reference type
Refer
http://www.yoda.arachsys.com/csharp/strings.html
Thanks