Something I\'ve been thinking about from time to time: Why is the typeof operator needed in C#? Doesn\'t the compiler know that public class Animal is a type ju
Not having typeof does cause ambiguity:
class foo
{
public static string ToString()
{
return "Static";
}
}
public class Program
{
private static void Main(string[] args)
{
Console.WriteLine(foo.ToString());
Console.WriteLine(typeof(foo).ToString());
}
}
foo and typeof(foo) are not referring to the same thing, and forcing the compiler to pretend they are is a bad idea, even if we ignore this ambiguity.