The is operator is used to check if an object is of a given type:
is
var a = 1 a is int // true a is float // false
An object can be casted to another type using the as operator:
as
var one = 1 as object // boxing var obj = getObject () var casted = obj as SomeClass
Type casting plays an important role in type inference system. For example, it lets you initialize a variable with a null value:
null
var b = null as string
There was an error while loading. Please reload this page.