如何在包括C#多个源文件 [英] How to include multiple source files in C#

查看:147
本文介绍了如何在包括C#多个源文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想学习C#从C ++背景的,但我无法弄清楚如何链接两个源文件在一起。我有一个相对简单的程序调用test.cs中和main.cs.所有我想要做的就是在main.cs说:结果
的#include<test.cs中>



我已经能够想出最接近的是:



<为pre> <为code><编译包括=test.cs中/编译>



但是编译器不承认这个。所以,我怎么能包括在我的主多个源文件?


解决方案

您传递的源文件到的compiler

  CSC.EXE /目标:库source1.cs source2.cs 

如果您使用Visual Studio时您创建一个新的.NET项目,你可以,只要你喜欢,他们将被自动编译添加尽可能多的源文件。


I am trying to learn C# coming from a C++ background, but I cannot figure out how to link two source files together. I have a relatively simple program called test.cs and a main.cs. All I want to do is in main.cs say:
#include <"test.cs">.

The closest I've been able to come up with is:

<Compile Include="test.cs"/Compile>

However the compiler does not recognize this. So how can I include multiple source files in my main?

解决方案

You pass the list of source files to the compiler:

csc.exe /target:library source1.cs source2.cs

If you use Visual Studio when you create a new .NET project you can add as many source files as you like and they will automatically be compiled.

这篇关于如何在包括C#多个源文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆