/// <summary>
/// reference type is allocate on HEAP,
/// the assignment statement just set a pint to the object.
/// the reference object memory collection on app exit!
/// </summary>
using System;
using System.Collections.Generic;
/// <summary>
/// class is reference type; struct is value type
/// </summary>
class /*struct*/ Point
{
public int X{get;set;}
public int Y{get;set;}
}
public class MyClass
{
public static void Main()
{
Point p = new Point{X=3,Y=4};
Point p1 = p;
p.X=100; //X=100,Y=4
Console.WriteLine("X={0},Y={1}",p1.X,p1.Y);
Console.ReadKey();
}
}
/// reference type is allocate on HEAP,
/// the assignment statement just set a pint to the object.
/// the reference object memory collection on app exit!
/// </summary>
using System;
using System.Collections.Generic;
/// <summary>
/// class is reference type; struct is value type
/// </summary>
class /*struct*/ Point
{
public int X{get;set;}
public int Y{get;set;}
}
public class MyClass
{
public static void Main()
{
Point p = new Point{X=3,Y=4};
Point p1 = p;
p.X=100; //X=100,Y=4
Console.WriteLine("X={0},Y={1}",p1.X,p1.Y);
Console.ReadKey();
}
}