Hello!!
You may correct me if I have made any wrong assumptions.
Below I have some simple classes.
When you have this t.ToString() below it's the ToString() method in Object
class that is called
and when you have this t.GetType() below it's the GetType() method in the
Object class that is called.
When you have 123.ToString() it's the ToString method in the string class
that is called. When you have 123.GetType() it's the GetType that is called
in the string class. Is this right understood.
One more question.
I just wonder how can the Object class know what the class is because you
just call a method
ToString or GetType in the Object class. For example when you do
t.ToString() or t.GetType()how can the Object class know that the Test
should be written.
class Test
{}
class myApp
{
public static void Main()
{
Test t = new Test();
Console.WriteLine("ToString: {0}", t.ToString() );
Console.WriteLine("Type: {0}",t.GetType() );
Console.WriteLine("ToString: {0}", 123ToString() );
Console.WriteLine("Type: {0}", 123.GetType() );
}
//Tony