的typedef [英] typedef
本文介绍了的typedef的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想给C#中的类型别名,所以我可以说SOMETYPEID指的是
int等,我怎样才能在C#上做这个?
类似于c ++中的typedef long SOMETYPEID
解决方案
使用指令
例如
A级{
}
使用B = A;
B b;
" Mr.Tickle" <先生****** @ mrmen.com>在消息中写道
新闻:eE ************** @ TK2MSFTNGP11.phx.gbl ...我想给一个C#中类型的别名所以我可以说SOMETYPEID将
引用到int等,我怎样才能在C#上执行此操作?
类似于c ++中的typedef long SOMETYPEID
嗨先生Tickle,
你可以使用* using *指令
使用SOMETYPEID = System.Int32;
因为c#没有像头文件那样的东西而且这些alises不是
作为元数据嵌入到程序集中你可以只在文件
中使用它你放这个声明。
HTH
B \ rgds
100
" Mr.Tickle" <先生****** @ mrmen.com>在消息中写道
新闻:eE ************** @ TK2MSFTNGP11.phx.gbl ...我想给一个C#中类型的别名所以我可以说SOMETYPEID将
引用到int等,我怎样才能在C#上执行此操作?
类似于c ++中的typedef long SOMETYPEID
嗨先生Tickle,
" Mr.Tickle" <先生****** @ mrmen.com>在消息中写道
新闻:eE ************** @ TK2MSFTNGP11.phx.gbl ...我想给一个C#中类型的别名所以我可以说SOMETYPEID将
引用到int等,我怎样才能在C#上执行此操作?
类似于c ++中的typedef long SOMETYPEID
本身没有typedef。你可以做这样的事情:
使用SOMETYPEID = System.Int64;
上面的主要缺点是它必须包含在你想要使用SOMETYPEID的每个
代码文件中。
问候,
Dan
I want to give an alias for a type in C# so i can say SOMETYPEID refers to
int etc, how can I do this on C#?
something like typedef long SOMETYPEID in c++
解决方案
the "using directive"
for example
class A{
}
using B = A;
B b;
"Mr.Tickle" <Mr******@mrmen.com> wrote in message
news:eE**************@TK2MSFTNGP11.phx.gbl...I want to give an alias for a type in C# so i can say SOMETYPEID refers to int etc, how can I do this on C#?
something like typedef long SOMETYPEID in c++
Hi Mr. Tickle,
you can use *using* directive
using SOMETYPEID = System.Int32;
Because c# doesn''t have anything like header files and this alises are not
embeded as a metadata in the assemblies you can use it only in the file
where you put this declaration.
HTH
B\rgds
100
"Mr.Tickle" <Mr******@mrmen.com> wrote in message
news:eE**************@TK2MSFTNGP11.phx.gbl...I want to give an alias for a type in C# so i can say SOMETYPEID refers to int etc, how can I do this on C#?
something like typedef long SOMETYPEID in c++
Hi Mr. Tickle,
"Mr.Tickle" <Mr******@mrmen.com> wrote in message
news:eE**************@TK2MSFTNGP11.phx.gbl...I want to give an alias for a type in C# so i can say SOMETYPEID refers to int etc, how can I do this on C#?
something like typedef long SOMETYPEID in c++
There is no typedef per se. You could do something like this, though:
using SOMETYPEID = System.Int64;
The primary drawback to the above is that it must be included in every
code file where you would want to use SOMETYPEID.
Regards,
Dan
这篇关于的typedef的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文