csc.exe compiling C # files

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.