开发者

Preprocessor defines

开发者 https://www.devze.com 2023-01-27 16:10 出处:网络
Fairly straight forward question, is it possible to write a C# preprocessor directive so I can do the following? :

Fairly straight forward question, is it possible to write a C# preprocessor directive so I can do the following? :

Clas开发者_开发知识库sZ<A, B, C, D, E, F>

to

ClassZ<T>

where

T = <A, B, C, D, E, F>


This is somewhat possible.

You can write

using ClassZT = ClassZ<A, B, C, D, E, F>;

Note that unless you put that inside your namespace block, you'll need to fully qualify every name.

However, you cannot make a parameter set the way you appear to be asking.


No. C# #define does not allow for macros or text replacements. It can only be used to define tokens for usage in #if directives.


If you are planning on implmenting the preprocessor yourself there is no reason you can't... But C# (at least the standard Microsoft version) doesn't have preprocessor macros like C or C++

0

精彩评论

暂无评论...
验证码 换一张
取 消