C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Version 1: The first uses the System.Console type—it omits the "using System" directive. It also uses the int alias in the C# language.
Int, uintVersion 2: This version changes the int alias to the System.Int32 type found in the System alias. The C# language automatically does this.
Version 3: This version adds the "using System" directive at the top. Now, the Console type can be accessed directly.
Also: Int32 can be accessed directly because it too is located in System. Many other common types require System.
Version 1: C#
class Program
{
static void Main()
{
System.Console.WriteLine(int.Parse("1") + 1);
}
}
Version 2: C#
class Program
{
static void Main()
{
System.Console.WriteLine(System.Int32.Parse("1") + 1);
}
}
Version 3: C#
using System;
class Program
{
static void Main()
{
Console.WriteLine(Int32.Parse("1") + 1);
}
}
Output
2
However: Because "int" is at the language level, you do not need to include System to use it.
Tip: You must include System.IO to get the input-output namespace as well. This can fix compile-time errors.
Microsoft: Another root namespace available in Visual Studio is the Microsoft namespace.
And: This contains some useful types, such as those required to do Microsoft Office interoperation.