Reference and value tpye
what are the value Type and reference type in C#?
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
yuvaraj k21 reputationPosted May 12, 2015, 3:22 AM EDT
reference types represent the address of the variable.
Stored On Heap..
Eg:
int[] Array1 = new int[10];
Value Type:
its contents in memory allocated on the stack
eg:
int Yuvaraj = 10;
================
refered by...
Publictutorials.com
Nanhe SiddiqueRank #1,103 · 1.7K reputationPosted May 12, 2015, 3:28 AM EDT
http://www.codeproject.com/Articles/32029/Reference-and-Value-Types-in-C
it may help you
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted May 12, 2015, 4:12 AM EDT
https://msdn.microsoft.com/en-us/library/4d43ts61(v=vs.90).aspx
http://www.codeproject.com/Articles/76153/Six-important-NET-concepts-Stack-heap-value-types
read above articles....
Pankaj Kumar ChoudharyRank #80 · 24.4K reputationPosted May 12, 2015, 4:19 AM EDT
reference parameters basically never pass the value of a variable used in the method calling, instead they use the variable themselves. Rather than creating a new storage for that variable in the method declaration.the very same storage space is used, so the value of the variable in the member method and the value of the reference
for example:
public void call(ref int n1, int n2)
{
unsafe
{
Console.WriteLine((int)&n2);
}
}
unsafe static void Main(string[] args)
{
int ab;
ab = 1032;
Demo dm = new Demo();
dm.call(ref ab, ab);
Console.ReadKey();
}
here n2 also contain space in memory but n1 does not contain any space in memory because address of ab(in main) and n1 is same......
MahaRank #2,573 · 543 reputationPosted May 12, 2015, 7:03 AM EDT