Troberg
Sinister eater
- Joined
- 27 Jun 2001
- Messages
- 17,712
Jag har alltid betraktat C# som ett lite pedofilt språk, en neddumning av C++ (i den mån C++ nu kan betraktas som ett språk och inte bara en precompiler till C) med rippad Java-syntax. Idag såg jag följande kodexempel som visar att det inte är pedofilt i alla fall:
<pre>
//interface definition
Public interface IChild{
bool IsHuman();
void lie();
}
//class definition
Pubic Pinocchio: IChild {
IChild.IsHuman() //explicit interface implementation
{ }
public void Lie(); //regular interface implementation
}
//using the object
static void main()
{
// Visual studio will not display
// the isHuman mwthod in the intellisence.
Pinocchio o = new Pinocchio();
((IChild)o).IsHuman(); // using the IsHuman method explicitly.
o.Lie();
} </pre>
När man försöker kompilera den kodsnutten får man något i stil med följande felmeddelande:
<pre> A Class implementing IChild can't contain any 'Pubic' keywords </pre>
Antagligen inte helt sant, men nära nog...
<pre>
//interface definition
Public interface IChild{
bool IsHuman();
void lie();
}
//class definition
Pubic Pinocchio: IChild {
IChild.IsHuman() //explicit interface implementation
{ }
public void Lie(); //regular interface implementation
}
//using the object
static void main()
{
// Visual studio will not display
// the isHuman mwthod in the intellisence.
Pinocchio o = new Pinocchio();
((IChild)o).IsHuman(); // using the IsHuman method explicitly.
o.Lie();
} </pre>
När man försöker kompilera den kodsnutten får man något i stil med följande felmeddelande:
<pre> A Class implementing IChild can't contain any 'Pubic' keywords </pre>
Antagligen inte helt sant, men nära nog...