To program the C# code it is not mandatory to use Visual Studio.NET. We can program it using some free tools such as notepad or any text editor. But it mandatory to install the .NET framework of required version.
The following program is just a snap of simple C# console app which can be written in a notepad:
class Basic
{
static void Main()
{
System.Console.WriteLine("first C# app"); //like printf in C or cout in C++
}
}
As OOP says "whatever you write should be enclosed within a container called as class to provide code access security - [ENCAPSULATION]", all the code above is written in a class named "Basic".
As every program needs an entry point to get executed , the Main() is defined - which is the entry point to our program. OOP says "you cannot access the members of a class untill and unless you create an instance (called as object to that class) to that class". To avoid this we declare Main() as static. As static members doesn't require an obiect of a class to access them, the Main() which we defined above will get executed.
The statement which we wrote within the Main() is helpful in displaying some content on the console (output window) . In this statement System is a namespace, Console is class within the System namespace and WriteLine is a static method within the Console class. All these are predefined and are present in BCLs. As WriteLine is a static method it also doesn't require the object of the 'Basic' class to access it.
The following program is just a snap of simple C# console app which can be written in a notepad:
class Basic
{
static void Main()
{
System.Console.WriteLine("first C# app"); //like printf in C or cout in C++
}
}
As OOP says "whatever you write should be enclosed within a container called as class to provide code access security - [ENCAPSULATION]", all the code above is written in a class named "Basic".
As every program needs an entry point to get executed , the Main() is defined - which is the entry point to our program. OOP says "you cannot access the members of a class untill and unless you create an instance (called as object to that class) to that class". To avoid this we declare Main() as static. As static members doesn't require an obiect of a class to access them, the Main() which we defined above will get executed.
The statement which we wrote within the Main() is helpful in displaying some content on the console (output window) . In this statement System is a namespace, Console is class within the System namespace and WriteLine is a static method within the Console class. All these are predefined and are present in BCLs. As WriteLine is a static method it also doesn't require the object of the 'Basic' class to access it.
1/28/2010 03:17:00 PM |
Category:
Basic C# Programming...
|
