Difference between Reference types and Value types in .net ?
i want to know that how do reference types and values types differ in .net ?
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
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 19, 2011, 4:30 PM EDT
Please refer to the C# Corner article on this topic:
http://www.c-sharpcorner.com/UploadFile/gowth/4518/
TulasiRank #2,544 · 549 reputationPosted Oct 19, 2011, 9:37 PM EDT
struct are value types or reference types in .NET?
Most programming languages provide built-in data types, such as integers and floating-point numbers, that are copied when they are passed as arguments (that is, they are passed by value). In the .NET Framework, these are called value types. The runtime supports two kinds of value types:
1. Built-in value types
The .NET Framework defines built-in value types, such as System.Int32 and System.Boolean, which correspond and are identical to primitive data types used by programming languages.
2. User-defined value types
Your language will provide ways to define your own value types, which derive from System.ValueType. If you want to define a type representing a value that is small, such as a complex number (using two floating-point numbers), you might choose to define it as a value type because you can pass the value type efficiently by value. If the type you are defining would be more efficiently passed by reference, you should define it as a class instead.
Variables of reference types, referred to as objects, store references to the actual data. This following are the reference types:
3. class
4. interface
5. delegate
This following are the built-in reference types:
1. object
2. stringPrabhu RajaRank #861 · 2.6K reputationPosted Oct 19, 2011, 11:03 PM EDT
Check out this Article By Puneet Walecha
http://www.c-sharpcorner.com/UploadFile/e7ad16/8634/
VulpesRank #55 · 29.2K reputationPosted Oct 20, 2011, 1:04 AM EDT