Hmmm... Nobody likes hearing theory for long time… just taking a break…
Lets overview some sample codes.
To start with let’s see the structure of a basic C# program. Even if don’t catch up the code, just understand the terms, so that I can use those terms in explaining codes in detail.
Note I use Visual Studio 2008, with a black theme for Coding. (I don’t like the normal white background for many reasons… )
See this code.

The Output of this program will be like this. (Note this is just a simple program with Console output.)
Ok I will explain each line.

Line 1: using System;
- This tells the compiler that this program uses types from the System namespace. This is a default namespace in .Net. I used this for getting the function WriteLine() 
Line 2 : namespace SampleCodeBlogspot
- I declared a new namespace for my program called SampleCodeBlogspot. Note that after declaring namespace, I put curly braces { }. 
Line 4: class testApp
- Declared a new class type for my program as testApp. Any members declared after this class inside curly braces, will automatically becomes members of this class. 
Line 6 : static void Main()
- In my program, Main is the only member of the testApp class. 
- Main is a special function used by the compiler as the starting point of the program. 
Line 8 : Console.WriteLine(" Hello, this is from Midhun's Blogspot.");
- My programs have only a simple statement which uses the Class Console in the namespace System, to print out the message to a window on the screen. 
Note:
- A C# program consists of one or more type declaration . In my sample program I have only one type. class testApp set 
- A namespace is a set of type declarations associated with a name. This sample Program creates a new namespace called SampleCodeBlogspot and uses a predefined namespace called System 
- Every C# program must have one class with a method ( or known as Function ) called Main. The starting point of execution of every C# program is at the first instruction in Main. 
- A statement is a source code instruction describing a type or telling program to perform an action. A simple statement is always terminated by a semi colon. - Console.WriteLine(" Hello."); 
 
Well.. We can start off like this. Let’s see more in the next blog..
 
1 comment:
Nice fill someone in on and this mail helped me alot in my college assignement. Say thank you you as your information.
Post a Comment