Wednesday, June 8, 2011

how to run c sharp on linux


How to Run C# on Linux OS
Here i am going to explane how to run C#(not GUI based ) on linux OS step wise .
1) Installation Process
a) Go to the following web site
http://go-mono.com/sources-stable/
b) dowanload mono-1.2.5.2.tar.bz2
c) go on terminal (command prompt for windows user )
d) login to root user
e) move mono-1.2.5.2.tar.bz2 to /usr/local/src by using following code
mv mono-1.2.5.2.tar.bz /usr/local/src
f) also move to src directory
cd /usr/local/src
g) type the following command to untar ( ie unzip for windows user ) the package
tar -xjf mono-1.2.5.2.tar.bz2
a new directory is created named " mono-1.2.5.2 "
h) move to that directory and type
./configure (dot then back forward slash )
after the configeratin will finish type
make
after make is created type
make install
All these process take 30 to 35 minute so be clam and coll till the process ends .
After make is installed we are now redy to run and execute c# programe .
2) Runing and Executing the C# programe
I follow the same old method of learning a programin language ie by writing the same old our Hello word program .



a) open any text editor in linux (vim , vi etc )
vim hello.cs
here .cs is C# file extension
for writing on vim editor you have to change your mode from comman to insert . for this press " i ";
// Hello World in C Sharp
class Hello {
static void Main() {
System.Console.WriteLine("Hello World");
}
}
To exit from the vim editor with saving the file type ESC and then Type "wq" and press enter.
(ESC changes insert mode to command mode, wq stands for "write and quit " )
b) Here our first programe is written and saved . now we have to compile it and run it.
To compile it simply type on command prompt
mcs hello.cs
if there is no error then hello.exe is creted else it will return error message
To run this programe type on terminal
mono hello.cs
it will print " Hello World " on terminal

No comments:

Post a Comment

Your comment is pending for approval

AngularJS Basics - Part 1

                                                                  AngularJS What is AngularJS ·          Framework by googl...