Even though we don’t import “System” Name-space , its possible to access various items included in “System” Name-space. like the aliases for various types (string, single, bool, decimal…), Object Class, and also functions of the Object Class. These items are visible through Intellisence.
And when we import System Name-space (using System) we get access to all the types in it (Array,Enum and lot more) and also the actual types (System.String , System.Float etc).
Can any one please tell my why is this ?
The c# type aliases {bool, byte, char, decimal, double, float, int, long, object, sbyte, short, string, uint, ulong, ushort } aren’t part of the BCL System namespace, they’re actually part of the C# language
It just so happens that anywhere where you use “string” as a type name, the C# compiler treats it as System.String when compiling. I believe (I may well be wrong!) that the using statements aren’t actually carried through to the MSIL that the compiler produces, so every reference to the type “string” is explicitly listed as “System.String” and every reference to StringBuilder (for example, in a class that has “using System.Text;” is expanded to “System.Text.StringBuilder”.