This project is read-only.
Upcast and downcast

Category:
Defining Types and Functions
Description: Use upcast and downcast
Code:
let UpcastDownCastSample1() = 
let a = 1
let upcastFunction(x) : obj = upcast x
let downcastFunction(x:obj) : int = downcast x
let objValue = upcastFunction(a)
printfn "name = %A" objValue
printfn "int = %d" (downcastFunction(objValue))

Execution Result:
name = 1
int = 1

Last edited Sep 14, 2011 at 3:30 AM by ttliu2000, version 1

Comments

elvincheng Jan 6, 2012 at 12:26 AM 
The 'upcast' and 'downcast' keyword also can be represented by the symbol ':>' and ':?>', respectively.