How does Visual Studio / intellisense know what to do with a variable declared as var, even if you did not specify the required declaration usingat the top?
For example, I have a class MyDomainObjectdefined in a different namespace. If I do not declare using TheOtherNameSpace;in the file, the following code will not compile:
private void Foo()
{
MyDomainObject myObj = new MyDomainObject();
}
But if I use var
var myObj = new MyDomainObject();
This compiles and intellisense knows exactly what I can with it.
So how the hell knows what a type is without using?
(And aside, if he knows without using, why should we usingeven ?!)
Richk source
share