如何在multi-files中分享"using"?

How to share the "using" in multi-files?

我想把一些c\c++ dll封装到c#中,需要写一些"using"语句来转换一些类型,比如

using FoorInteger = int;

但它只适用于单个文件。我必须把它复制到其他文件中。

如何让它在 multi-files 中像 c\c++ headers 中的“#define”一样工作?

它在 C/C++ 中工作,因为 #include directive 告诉编译器 "take everything from this other file and put it in this file"。因此,您包含的文件中的任何 #define 语句也在具有 #include 指令的文件中定义。

C#中没有这样的东西。还有其他preprocessor directives类似C/C++,但没有#include。由于您不能 "include" 另一个文件,因此无法告诉编译器包含来自另一个文件的 using 指令。

您需要将 using 指令复制到每个使用它的文件。