Files
WoofWare.PawPrint/WoofWare.PawPrint.Test/sourcesPure/CastClassBoxing.cs
2025-06-27 11:41:41 +01:00

31 lines
538 B
C#

public class Program
{
public struct Point
{
public int X;
public int Y;
public Point(int x, int y)
{
X = x;
Y = y;
}
}
public static int Main(string[] args)
{
Point p = new Point(10, 32);
// Box the value type
object boxed = p;
// Cast boxed value type to object (should succeed)
object obj = (object)boxed;
// Unbox
Point unboxed = (Point)obj;
return unboxed.X + unboxed.Y;
}
}