Mono, you should have heard of it, it is based on UNIX .NET Framework development platform. Sponsor Miguel de icaza may not be very familiar, in the world of free software, but the famous name is the initiator of the GNOME project.
Now Mono is still in the test phase, the latest version is 1.0.5, everyone can go to [URL] http://www.mono-project.com/ [/ url] download. Although it is just a test stage, it has enabled most of the libraries in Microsoft .NET Framework. And there is already a very beautiful IDE development tool, which is ambitious.
Mono can be used on a variety of system platforms. It is very simple to install in Windows, follow the prompt step to do it. I also tried to install under Linux (Fedora Core 3), prompts and some packages are not compatible, but it is not a big problem. Waiting for it, talk to everyone.
After you are installed in Windows, you can find Mono under the Start menu. Already taken the mono command line, so you don't have to set PATH like Java, you can use the MONO compiler directly.
Let's compile a C # program and feel Mono. This is a very simple C # source code guess.cs, guess digital games:
Using system;
Public Class Game
{
PRIVATE STRING NUMBER;
Private static int x, y;
PRIVATE INT Count = 0;
Public void init ()
{
Do {
Console.writeline ("Please Input Number:");
Number = console.readline ();
WHILE (Number.Length! = 4);
}
Public void play ()
{
/ / Generate random number
Int [] a = new int [10]; // Plastic array
// fill in the 0 to 9 ten numbers in a [0] to a [9]
For (int i = 0; i <10; i ) a [i] = i;
// Ten numbers randomly disrupt
Random Ran = new random ();
For (int i = 0; i <4; i )
{
INT t = ran.next ()% 10;
Int S;
s = a [i];
a [i] = a [t];
a [t] = s;
}
// Take four numbers in front of the four digits as a correct answer to guess numbers
String ready = a [0] .tostring () a [1] .tostring () a [2] .tostring () a [3] .tostring ();
Do {
X = 0;
y = 0;
INIT ();
For (int i = 0; i <= 3; i )
{
For (int J = 0; j <= 3; j )
{
IF (Number [i] == Ready [J])
{
IF (i == j)
x;
Else
Y;
}
}
}
COUNT;
Console.writeline ("{0} a {1} b", x.toString (), y.tostring ());
IF (count> 8)
{
Console.writeline ("-----------------");
Console.writeline ("-----------------");
Console.writeline ("you already lossed"); console.writeline ("The Right Answer IS {0}", Ready;
Console.writeline ("-----------------");
Console.readline ();
Return;
}
} while (Number! = Ready);
Console.writeline ("------------------------");
Console.Writeline ("OK! You are very very cleverness!");
Console.writeline ("------------------------");
Console.readline ();
}
}
Public class mygame
{
Public static void main ()
{
Game g = new game ();
g.Play ();
}
}
In fact, C # source code and Java are very like. Everything in C # in Java must belong to a class.
Let's compile it with mono. Enter it in Mono command line: MCS Guess.cs will generate a guess.exe file,
We can enter Mono Guess.exe in the terminal to run the program. Wonderful is this guess.exe file compiled with mono, can also run in Mono under Linux!
The purpose of writing this article is because many friends don't know what MONO is. I missed such a good programming tool losses! In fact, MONO needs to be in-depth research too much. This article is just a simple attempt. The Mono project originated in 2001, in fact, there are many introductions on Mono on the Internet. Interested friends can search, there are many wonderful articles. Write this. Waiting for the opportunity to write myself using Mono's experience under Linux.