class FirstProgram
{
static void Main()
{
System.Console.WriteLine("My first program in csharp..!");
}
}
output: My first program in csharp..!
{
static void Main()
{
System.Console.WriteLine("My first program in csharp..!");
}
}
output: My first program in csharp..!
Note: To compile the program we need 'Developer Command Prompt for VS' which we will get automatically after installing visual studio.
What is System.Console.WriteLine ?
- Console is a predefined class under the libraries of our language which provides with a set of static members to perform IO operations on standard I/O devices.
- The Console class contains methods like WriteLine, Write, ReadLine, Read, ReadKey to perform I/O operations.
- System is a namespace where a namespace is a logical container of types like Class, Structure, Interface, Enum and Delegate.
What is Namespace?
- Namespaces are used as logical containers in programming languages.
- Every predefined type in our libraries is under some namespace.
- We can also define our types under some namespaces and we will check out that process later.
- If a type is defined under any namespace then it is must to prefix with that particular namespace while consuming that type.
- To overcome the above problem we provided with an option known as importing a namespace with the help of "using directive".
- If we import a namespace into the program we can start consuming all the types under that namespace without prefixing it each and every time.
Example: using System;
Now the program can be written as,
using System;
class FirstProgram
{
static void Main()
{
Console.WriteLine("My first program in csharp..!");
}
}
{
static void Main()
{
Console.WriteLine("My first program in csharp..!");
}
}