-
Notifications
You must be signed in to change notification settings - Fork 89
Upcast and downcast
CodingUnit edited this page Nov 28, 2011
·
3 revisions
- 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()
- Execution Result:
name = 10
int = 10
- Copyright