hi
please help me on below topic
in c# there are already built in data type like int,float,char,string
then why there is need of value type and reference type
please tell me
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
Manas MohapatraRank #182 · 13.2K reputationPosted Aug 9, 2016, 2:19 AM EDT
Nitin SontakkeRank #264 · 9.6K reputationPosted Aug 9, 2016, 3:13 AM EDT
Vinay SinghRank #604 · 4K reputationPosted Aug 9, 2016, 3:17 AM EDT
As we know
int,boolandfloatare specific types, interfaces and delegates are kinds of type - just likestructandenumare kinds of value types.Pleaseexplanation of reference types and value types in this article. I'd be happy to expand on any bits which you find confusing.
The "TL;DR" version is to think of what the value of a variable/expression of a particular type is. For a value type, the value is the information itself. For a reference type, the value is a reference which may be null or may be a way of navigating to an object containing the information.
For example, think of a variable as like a piece of paper. It could have the value "5" or "false" written on it, but it couldn't have my house... it would have to have directions to my house. Those directions are the equivalent of a reference. In particular, two people could have different pieces of paper containing the same directions to my house - and if one person followed those directions and painted my house red, then the second person would see that change too. If they both just had separatepictures of my house on the paper, then one person colouring their paper wouldn't change the other person's paper at all.
for more detail have a look of the link