Difference between casting to a class and to an interface
From: yufufi (yufufi_at_ttnet.net.tr)
Date: 07/04/04
- Next message: Niki Estner: "Re: A Console .EXE"
- Previous message: Pollux: "Re: C# is a proprietary programming language ??"
- Next in thread: Mark Broadbent: "Re: Difference between casting to a class and to an interface"
- Reply: Mark Broadbent: "Re: Difference between casting to a class and to an interface"
- Reply: Niki Estner: "Re: Difference between casting to a class and to an interface"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 4 Jul 2004 16:17:48 +0300
lets say we have a 'shape' class which doesn't implement IComparable
interface..
compiler doesn't give you error for the lines below..
shape b= new shape();
IComparable h;
h=(IComparable)b;
but it complains for the following lines
shape b= new shape();
int a;
a=(int)b;
error is Cannot convert type 'shape' to 'int'
is there difference between casting to a class and casting to an interface
?? what does the compiler checks when it is casting to an interface (or does
it check anything ?)
Thanx a lot,
yufufi
- Next message: Niki Estner: "Re: A Console .EXE"
- Previous message: Pollux: "Re: C# is a proprietary programming language ??"
- Next in thread: Mark Broadbent: "Re: Difference between casting to a class and to an interface"
- Reply: Mark Broadbent: "Re: Difference between casting to a class and to an interface"
- Reply: Niki Estner: "Re: Difference between casting to a class and to an interface"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|