在 C# 中,如何将 DWORD 声明为 uint32?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/745425/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
In C#, How to declare DWORD as an uint32?
提问by CrashCodes
I guess the question is really about how to define a type as an existing primitive data type. Below clearly doesn't work, but I think you'll get the idea.
我想问题实际上是关于如何将类型定义为现有的原始数据类型。下面显然行不通,但我想你会明白的。
Type DWORD = typeof(UInt32);
private DWORD func1(int x)
{
return 123;
}
采纳答案by Mehrdad Afshari
There is no typedef
in C#. You can't use #define
macros to replace strings either (they are just conditional). The only rough equivalent is using DWORD = System.UInt32;
on top of your source file.
typedef
C# 中没有。您也不能使用#define
宏来替换字符串(它们只是有条件的)。唯一粗略的等效项位于using DWORD = System.UInt32;
源文件的顶部。
回答by dommer
What about
关于什么
using DWORD = System.UInt32;
Downside to this is that you'll have to do it in each file that you require it in.
这样做的缺点是您必须在需要它的每个文件中执行此操作。
回答by Steve
I think you are talking about type aliasing, the way to do that in C# is using the using
keyword.
我认为您在谈论类型别名,在 C# 中这样做的方法是使用using
关键字。
e.g.
例如
using DWORD = System.Uint32