别名关键字(如类型定义)在C#中? [英] alias keyword (like typedef) in C#?
问题描述
我有2个库在不同平台上:(有不同的情况,好像一切是相同的(方法名称,参数顺序等等)。如何创建一个别名,所以我目前的拼写平台将工作当我编译为平台b(我真的很讨厌做的情况下,不同的包装)
I have 2 libs that have different case on different platforms :(. It seems like everything else is the same (method names, param order, etc). How can i create an alias so my current spelling for platform a will work when i compile for platform b (I would really hate to make a wrapper for case difference)
推荐答案
您可以使用using关键字创建一个别名:
You can use the using keyword to create an alias:
using MyName = YourNamespace.YourSubNamespace.YourType;
您可以有条件地再包括使用#if指令别名但是你需要在每一个源文件的顶部要做到这一点:没有#包括 - 像指令,允许您创建的别名文件,并将它们导入到每一个源文件。所以,如果你是在做这在一个大的代码库计划那么它可能是值得考虑的另一种方法,如包装的方法。
You could then conditionally include the aliases using a #if directive. However you would need to do this at the top of every source file: there's no #include-like directive to allow you to create a file of aliases and import them into each source file. So if you are planning on doing this in for a large codebase then it may be worth considering another approach such as the wrapper approach.
这篇关于别名关键字(如类型定义)在C#中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!