Assignment C# with Example



Assignment C# with Example

var a = new List(); 
var b = a; 
a.Add(5); 
Console.WriteLine(a.Count); // prints 1 
Console.WriteLine(b.Count); //  prints  1  as  well 
Assigning to a variable of a List does not create a copy of the List. Instead, it copies the reference to 
the List. We call types that behave this way reference types. 

0 Comment's

Comment Form

Submit Comment