Boxing and Unboxing

Posted by Karthikanbarasan under C# category on | Points: 40 | Views : 1985
This code samples how how to box and unbox

public static void Main() {
Point pint;
pint.x = pint.y = 1;
Object o = pint; // Boxes pint; o refers to the boxed instance
pint = (Point) o; // Unboxes o AND copies fields from boxed

Comments or Responses

Login to post response