This project is read-only.

Type casting

Type casting allows objects of one type to be interpreted as objects of another type. Not all types can be casted (like in C), so only three scenarios are allowed:
  • Casting an object of child class to parent class
  • Casting an object of parent class to child class
  • Casting a null value to any reference type

The casting is performed using the 'as' operator:

var obj = new child_type
var obj2 = obj as parent_type
var obj3 = null as string 

Last edited Mar 14, 2011 at 10:32 PM by impworks, version 1


No comments yet.