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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
yuvaraj kPosted May 12, 2015, 7:22 AM
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
MahaPosted May 12, 2015, 11:03 AM
Pankaj Kumar ChoudharyPosted May 12, 2015, 8:19 AM
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......
Upendra Pratap ShahiPosted May 12, 2015, 8:12 AM
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....
Nanhe SiddiquePosted May 12, 2015, 7:28 AM
http://www.codeproject.com/Articles/32029/Reference-and-Value-Types-in-C
it may help you