Tuesday, January 15, 2013

C# tutorial-1-Write and compile a C# Program Without visual studio

c#tutorial-1First i would like to say due to my hectic schedule my activities on Learn and Earn is very low in recent Days but i will try to be more active now.So Welcome to the new series of tutorials on C#.net on Learn and Earn.C# is one of the powerful pure Object Oriented Programming languages like Java introduced by Microsoft and one the most popular software development language.So let’s start the tutorial series with very first hello world program tutorial. To make a C# program you need an IDE which consists an editor, compiler, interpreter and debugger called Visual Studio which provides all these facilities and an environment (called Framework).

We will discuss about Visual studio installation and framework in the coming tutorials, In this tutorial we will be making a hello world program in notepad itself just like Java programs without any IDE.As you may know Microsoft Operating System comes with built in Framework (2.0+) in windows Xp/7 and windows 8 therefore you just need any version of Windows to complile this program.

So here are the steps needed to make Hello World C# Program in Notepad....


1. Open Notepad or any other text editor like notepad++(Recommended).

2.Now Type this Code in the editor..

Using System;
Namespace Helloworldapplication

{

Class Abc
{

Static Void Main (String Args [])
{
Console.Writeline (“Hello User Welcome Abroad in Geeks Village”);
}

}

}

Now lets understand the namespaces,logic and Program fuctions...


Explanation-


Using system-This is similar to standard libraries which you all are used to include in your C++ application and Importing Packages in Java application. In C# system is the father of all namespaces(Namespaces consists Number of classes).System is also a Namespace which consists various useful classes to make a C# application and by using system Namespace in the program we are using console.writeline function which is defined Under System Namespace. If we write System.Console.Writeline () instead of Console.Writeline then we don’t have to write using system as we are accessing the required directly from Namespace.

Namespace Helloworldapplication:In C#.net to enhance the level of security classes is also binded in Namespace.

Static Void Main(String Args[])-Now in pure Object Oriented Programming Language so every program uses object Concept So every program is made inside class therefore it requires object initialization during compilation to access main() but it is not possible So function is made static so that it doesn’t require any object initialization at compile time.

Console.Writeline()-used to print something on screen in console application.

Now the Next Steps


3.save the file with .cs extension.

4.Now run cmd(command promt) and type csc Helloworldapplication.cs(this will compile your program) where .cs is the saved file name.

5.To run the program type Helloworldapplication.

and done you see the output on the same command promt screen,just make sure to direct the directory as C:\windows in notepad and to save the file in same directory.I hope you will enjoy this new learning series on Learn and Earn.

1 comment:

  1. [...] all are enjoying new year 2013 and  C# tutorials series on Learn and Earn.Last time we learnt to write and Debug a C# program using notepad and Command Prompt.So if you love to write code on notepad just like java then you are more than [...]

    ReplyDelete