Pass
C#
Command-line compiler compilation
C#
File
1.
Configuration
C#
Command-line compiler
:
My computer
—
) Advanced
—
Environment variables
—
〉
Path
—
Tim
Add
"; C:\Windows\Microsoft.NET\Framework\v2.0.50727 "(Path
The last path though version
Change.
)
。
Csc.exe (C #
Command-line compiler
)
is placed in this directory. Pass
csc/?
To view all the reference
Number.
2.
Configure other
. NET
Command-line tools
My computer
—
) Advanced
—
Environment variables
—
〉
Path
—
Add
";D: \program
Files\Microsoft Visual Studio 8\sdk\v2.0\bin "(Path
Changes with the installation directory, such as
The fruit is installed in
C +
, it is
"; C:\Program Files\Microsoft Visual Studio 8\sdk\v2.0\bin "
3.
Pass
Csc
command-line compiler to compile
C#
File, here is an example
1)
In
D
Under a new disk named
Test.txt
Text file
,
Enter the following text to save as
Test.cs
File
//
A simple
C#
Application
.
Using System;
Class TESTAPP
{
public static void Main ()
{
Console.WriteLine ("Test! ");
Console.readkey ();
}
}
2)
Run
—
〉
Cmd
—
〉
D:\
—
〉
CSC D:\test.cs,
After compilation succeeds in
D
Under Disk generation
Test.exe
Executable file
3)
Input
Test.exe
, enter, show results
(test!)
4.
Next, by introducing
System.Windows.Forms
namespaces to generate
Windows Forms
Program
Test.cs
Modify to compile again as follows
//
A simple
C#
Application
.
Using System;
//
Be sure to add the following line
Using System.Windows.Forms;
Class TESTAPP
{
public static void Main ()
{
Console.WriteLine ("Test! ");
MessageBox.Show ("Hello ...", "Application");
Console.readkey ();
}
}
5.
Use
Csc.exe
Compiling multiple source files
HelloMessage.cs
Using System;
Using System.Windows.Forms;
Class HelloMessage
{
public void Speak ()
{
MessageBox.Show ("Hello");
}
}
Test.cs
Using System;
Class TESTAPP
{
public static void Main ()
{
Console.WriteLine ("Testing! ");
HelloMessage h = new HelloMessage ();
H.speak ();
}
}
Parameters
/out:
The location and name of the compilation result
Csc/out:e:\a.exe Test.cs HelloMessage.cs
or compile all of the current directory
Cs
File
: Csc/out:e:\a *cs
csc.exe compiling C # files