...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.
«aprile»
domlunmarmergiovensab
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011