UInt16的数组,C#中的后缀是什么?
我正在尝试初始化内联 UInt16 数组。对于 int 我可以执行以下操作:
int[] int_array = new[]{0,0,0,0};
同时使用 UInt16 在没有强制转换的情况下无法工作:
UInt16[] uint16_array= new[]{(UInt16)0,(UInt16)0};
这些强制转换非常烦人。 我想知道 C# 中是否有任何后缀来消除分配的歧义(例如浮点数的 0.0f)。
I'm trying to initialize inline an array of UInt16. For int I can do the following:
int[] int_array = new[]{0,0,0,0};
meanwhile using UInt16 doesn't work without a cast:
UInt16[] uint16_array= new[]{(UInt16)0,(UInt16)0};
It's quite annoying do those casts.
I was wondering if there is any suffix in C# to disambiguate the assignment (like 0.0f for float).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我认为没有,但你为什么不这样做呢
I don't think there is one, but why don't you do this instead
C# 没有无符号 16 位整数的类型后缀。 VB.NET 确实如此,仅供参考:
这里是 另一个资源列出了不同的后缀。
C# doesn't have a type suffix for unsigned 16-bit integers. VB.NET does though, just for reference:
Here's another resource that lists the different suffixes.
这是比科里的更短的方法:(
或)
Here's an even shorter way than Corey's:
(or)
http://msdn.microsoft.com/en- us/library/aa664674(v=VS.71).aspx
不幸的是没有缩写后缀。
http://msdn.microsoft.com/en-us/library/aa664674(v=VS.71).aspx
Unfortunately no suffix for short.