如何在C#中仅编译一个文件? [英] How to compile just one file in c#?

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

问题描述

在VC ++中,我可以按CTRL + F7来编译单个文件,或者右键单击源文件或对其进行编译. 可以在C#中编译一个文件(或当前文件)吗?

In VC++ I can press CTRL+F7 to compile a single file, or right click on a source file ot compile it. Is it possible to compile a single file (or current file) in C#?

例如,我想知道当前文件中是否有任何错误,而不必编译所有文件.

I would like to for example know if my current file has any errors in it without having to compile everything.

推荐答案

否在C#中无法做到这一点.

No it is not possible to do this in C#.

与C ++不同,不能自行对C#文件进行合理的编译以确定它是否有任何错误. C ++通过#include语句实现了这一点,该语句允许.cpp文件理解可用类型的声明.这些声明定义了当前文件所依赖的类型的结构,并允许编译器确保根据规范使用它们.

Unlike C++ a C# file cannot be reasonably compiled on it's own to determine if it has any errors. C++ achieves this through #include statements which allows a .cpp file to understand the declaration of types available. These declarations define the structure of types the current file depends on and allows the compiler to ensure they are used according to specification.

此过程在C#中隐式处理.可用的声明集就是所有已编译文件中所有声明的集,否则可以访问这些声明.无法以C ++的方式转发声明依赖,因此也无法确保在单个文件中正确使用依赖.

This process is handled implicitly in C#. The set of declarations available is simply the set of all declarations in all compiled files which are otherwise accessible. There is no way to forward declare dependencies in the manner C++ does and hence no way to ensure they are being used correctly within a single file.

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

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