Ad Code

Responsive Advertisement

Program structure of C#

C++ language suffer from a criticism that it was not fully object oriented because as par the
rules of OOP programming every line of cod should be defined inside the class only but main
function in C++ program will always be outside the class.

NOTE- while design C++ the designers could not place Main inside the class because if Main
is inside the class it can execute only when called by using object of the class in which it was
present, whereas object is getting created main function only. (Circular dependency)

When the java language were designed the designers are given a permanent solution to the
problem of main by introducing “static method(function)”, which can execute without the
object of class. So if the main method is declared as static inside the class it can become the
entry point of the program where the object of the class created and rest of the members in
the class can execute as following.
While designing C# the developers of the language has followed the same guideline
prescribed by java in case of Main so in C# also Main method gets defined with in the class as
Static and the program structure looks exactly same as the java programs structure we have
seen above.

Suppose if your class contain only main method in it to execute the class we don’t reqired to
create object of the class for execution.

THE SOFTWARE REQUIREMENT, THE HARDWARE REQUIREMENT AND 
THE WEBSITE FOR c#.NET.

Hardware requirement-

1. 2.5-3 GB hard disk space for install

2. Min. 1 GB RAM in it.

Software required-

1. Windows XP with server pack 3 or windows vista (home premium business) or windows 7.

2. Visual Studio .Net 2010 or 2008.

3. Oracle DB 11g or SQL server 2008 or 2005.

4. MS office.

Books :-
C#3.0 unleashed (SAMS)
C# 2008 developers (SAMS)
Professional C# 2008 (work press).

Website :-

1. www.msdn.com

2. www.csharpcorner.com


1. Modifiers or few optional keywords like public, private, static etc. which can be used on a
cclass.

2. C# is a case sensitive language so in case of casing it adopts few conventions—

- All keywords will be in lower case only.

- All library function must be used in proper case only i.e. class name, Method name etc.
(WriteLine) – Proper case

Syntax of Main Method:-

- As discussed earlier must and should name should be declared as static if we want the execution to start from there.

- Main can be either a non value returning method and can also return a value of type int only.

- Main method can tack parameters also but only of type string [] array.

                                                Writing a First Program:-

i) to write a program in any .net language wee can use of any editor like Visual Studio or noted etc.
ii) developing a program in notepad


1. Open the notepad and write following code in it.



2. Now save the program in a desire location as Example.cs

Note- a C# program should use an extension of .cs and the VB program should use an extension of .vb

3. Compiling the program – to compile a C# program we required a C# compiler, which comes along with the visual studio software. It is a command line tool which has to be used from Visual; Studio command prompt. To use it –

Go to start menu  program  MS visual studio  visual studio tools  visual studio command prompt, click on it to open.

Now move into the folder ware your program has been saved. And used the C# compiler as following. And used the C sharp compiler as following

C:\......................................\vc>cd\
C:\>cd csharp4
C:\csharp4>csc Example.cs

If the program is compiled successfully without any error it creates a file Example.exe , which contains IL code in it.

4. Executing the program- Now from the command prompt run your exe file as following –

C:\csharp4>Example
ildasm : (intermediate language disassembly )-->
It is a tool that can be used for viewing that contained of the exe file generated after compilation which contains IL code in it. It can be used from visual studio command prompt as following

C:\csharp4>ildasm Example.exe



Reactions

Post a Comment

0 Comments