...codice che mi ha fatto meditare

Incuriosito dal post di Adrian , "System.Object come tipo base di un tipo interfaccia?", ho provato a scrivere due righe di codice...

 

interface IInterface{
}
class InterfaceUser: IInterface{
}
//..
InterfaceUser iu = new InterfaceUser();
IInterface i = iu;
string sByIInterface = i.ToString(); //why is it possible?
string sByInterfaceUser = iu.ToString();
MessageBox.Show(
string.Format( "ToString By Default Class Interface = {0}\nImplicit ToString By Second Interface = {1}",  
sByInterfaceUser, sByIInterface), "Interface Test"); 

I miei commenti? Per ora ci sto ankora meditando...

posted @ lunedì 28 giugno 2004 14:00

Print
Comments have been closed on this topic.
«maggio»
domlunmarmergiovensab
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567