ushort 等价物
我有一个 C# 应用程序,我正在尝试将其转换为 java。 C# 应用程序有一些 ushort 类型的变量。 java中有类似的东西吗?
谢谢
I have an application in C# that I'm trying to convert to java. The C# app has a few variables that are of type ushort. Is there an equivalent in java?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
就大小而言最接近的等价物是
char
,因为 Java 没有无符号类型,但它在 Java 中重载以提供与单个字符相关的附加语义。一般来说,只需选择下一个最大的整数类型(在本例中为 int)。 (您不是唯一一个不过想要它。)The closest equivalent in terms of size is
char
, since Java doesn't have unsigned types, but it's overloaded in Java to provide additional semantics related to individual characters. In general, just pick the next largest integral type (int
, in this case). (You're not the only one who wants it, though.)您可能知道,Java 没有无符号数字< /a>.这意味着您将不得不采用另一种解决方案。在此类情况下,通常最简单的方法是使用下一个较大的类型,例如 int(它只是一个 32 位有符号整数)。
As you may be aware, Java has no unsigned numbers. This means you're going to have to go with another solution. It's generally easiest to just use the next larger type in cases like these, such as
int
(which is simply a 32-bit signed integer).