static void Main() { PointStruct ps1 = new PointStruct(); ps1.x = ps1.y = 22; PointStruct ps2 = new PointStruct(); ps2.x = ps2.y = 33; ps1 = ps2; ps2.x = ps2.y = 55; Console.WriteLine("ps1 is ({0}, {1})", ps1.x, ps1.y); Console.WriteLine("ps2 is ({0}, {1})", ps2.x, ps2.y); Console.WriteLine("ps1.Equals(ps2) results in " + ps1.Equals(ps2)); PointClass pc1 = new PointClass(); pc1.x = pc1.y = 22; PointClass pc2 = new PointClass(); pc2.x = pc2.y = 33; pc1 = pc2; pc2.x = pc2.y = 55; Console.WriteLine("pc1 is ({0}, {1})", pc1.x, pc1.y); Console.WriteLine("pc2 is ({0}, {1})", pc2.x, pc2.y); Console.WriteLine("pc1.Equals(pc2) results in " + pc1.Equals(pc2)); Console.WriteLine("pc1 == pc2 results in " + (pc1 == pc2)); }
static void Main() { PointStruct ps1 = new PointStruct(); ps1.x = ps1.y = 55; PointStruct ps2 = new PointStruct(); ps2.x = ps2.y = 55; PointClass pc1 = new PointClass(); pc1.x = pc1.y = 55; PointClass pc2 = new PointClass(); pc2.x = pc2.y = 55; Console.WriteLine("ps1.Equals(ps2) results in " + ps1.Equals(ps2)); Console.WriteLine("ps1.Equals(pc1) results in " + ps1.Equals(pc1)); Console.WriteLine("pc1.Equals(pc2) results in " + pc1.Equals(pc2)); Console.WriteLine("pc1 == pc2 results in " + (pc1 == pc2)); // Console.WriteLine("ps1 == ps2 results in " + (ps1 == ps2)); }
public static void Main() { // Console.WriteLine("sizeof(IntPtr)={0}", sizeof (PointClass)); { PointStruct ps1 = new PointStruct(10, 11); PointStruct ps2 = ps1; ps2.x = 20; ps2.y = 21; Console.WriteLine("sizeof(ps1)={0}", Marshal.SizeOf(ps1)); Console.WriteLine("ps1 = {0}", ps1); Console.WriteLine("ps2 = {0}", ps2); Console.WriteLine("ps2.Equals(ps1) = {0}", ps2.Equals(ps1)); Console.WriteLine("ps2 == ps1 = {0}", (ps2 == ps1)); } { PointClass pc1 = new PointClass(10, 11); PointClass pc2 = new PointClass(10, 11); pc2.x = 20; pc2.y = 21; // Ãß°¡ ÁÖ¼® Console.WriteLine("sizeof(ps1)={0}", Marshal.SizeOf(pc1)); Console.WriteLine("pc1 = {0}", pc1); Console.WriteLine("pc2 = {0}", pc2); Console.WriteLine("pc2.Equals(pc1) = {0}", pc2.Equals(pc1)); Console.WriteLine("pc2 == pc1 = {0}", (pc2 == pc1)); } { PointClass pc1 = new PointClass(10, 11); PointClass pc2 = pc1; pc2.x = 20; pc2.y = 21; Console.WriteLine("pc1 = {0}", pc1); Console.WriteLine("pc2 = {0}", pc2); Console.WriteLine("pc2.Equals(pc1) = {0}", pc2.Equals(pc1)); Console.WriteLine("pc2 == pc1 = {0}", (pc2 == pc1)); } }