Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure the C # command line compiler

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how to configure the C # command line compiler, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to know it.

1. Configure the C# command line compiler:

My computer-> Advanced-> Environment variables-> Path-> add "; C:\ Windows\ Microsoft.NET\ Framework\ v2.0.50727" (a path version of Path

Change as a result of the change. The csc.exe (C # command line compiler) is placed in this directory. Through csc /? To view all the parameters.

two。 Configure other .NET command line tools

After configuring the C# command line compiler, you need to configure other 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, if installed in C:\, it is "; C:\ Program Files\ Microsoft Visual Studio 8\ SDK\ v2.0\ Bin"

3. To compile the C # file through the csc command line compiler, here is an example

1) create a new text file named test.txt under disk D, enter the following text and save it as a test.cs file

/ / A simple C # application. UsingSystem; classTestApp {publicstaticvoidMain () {Console.WriteLine ("testament 1 and 2); Console.ReadKey ();}}"

2) run-> cmd-> D:\-> csc D:\ test.cs. After successful compilation, generate the test.exe executable file under disk D.

3) enter test.exe, enter, and display the result (Test! 1, 2, 2, 3)

4. Next, the Windows Forms program, test.cs, is generated by introducing the System.Windows.Forms namespace

Change it to the following and compile again

/ / A simple C # application. UsingSystem; / / be sure to add the following line: usingSystem.Windows.Forms; classTestApp {publicstaticvoidMain () {Console.WriteLine ("testament 1, Application 2, 3"); MessageBox.Show ("Hello...", "Application"); Console.ReadKey ();}}

5. Compile multiple source files using csc.exe

/ / HelloMessage.cs usingSystem; usingSystem.Windows.Forms; classHelloMessage {publicvoidSpeak () {MessageBox.Show ("Hello");}} / / Test.cs usingSystem; classTestApp {publicstaticvoidMain () {Console.WriteLine ("Testinghammer 1 ~ 2 ~ 3"); HelloMessageh=newHelloMessage (); h.Speak ();}}

Parameter / out: the location and name of the compilation result

Csc/out:e:\ a.exe test.cs HelloMessage.cs

Or compile all the cs files in the current directory: csc/out:e:\ a * cs

Thank you for reading this article carefully. I hope the article "how to configure the C# Command Line Compiler" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report