- Category: Defining Types and Functions
- Description: Use upcast and downcast
- Code:
using System;
using System.Console;
def UpcastDownCastSample1()
{
def a = 10;
def upcastFunction(x) { x : object }
def downcastFunction(x) {x :> int }
def objValue = upcastFunction(a);
WriteLine($"name = $objValue");
WriteLine($"int = $(downcastFunction(objValue))")
}
UpcastDownCastSample1()
Samples used from "F# 3.0 Sample Pack" (
http://fsharp3sample.codeplex.com/) at Codeplex OpenSource Community for non-commercial usage. All copyrights and authorship on materials this publication based on, is belongs to Microsoft corp. Copyright © 2006-2011 Microsoft Corporation, . All rights reserved. Copyright and autorship for materials in Nemerle language belongs to Nemerle Project Team. Copyright © 2008-2011 Nemerle Project Team. All rights reserved.