使用int和UINT以及何时使用的差异 [英] Difference of using int and uint and when to use

查看:723
本文介绍了使用int和UINT以及何时使用的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么用INT和uint之间的区别?到目前为止,我所看到的所有的例子都使用int作为整数。使用UINT的任何优势?谢谢你。

What is the difference between using int and uint? All the examples I have seen so far are using int for integers. Any advantage of using uint? Thanks.

推荐答案

UINT 手段的符号的整型,你可以用它为那里的正常INT有-2G .. + 2G范围0 .. + 4G系列。

uint means unsigned int, you can use it for a 0 .. +4G range where the normal int has a -2G .. +2G range.

在使用它?几乎从不。这不是一个符合CLS类型,因此你应该的从不的装配体中的公共接口使用它。并非所有的.NET语言可以处理它。

When to use it? Almost never. It is not a CLS compliant type so you should never use it in the public interface of an assembly. Not all .NET languages can handle it.

其主要用途是在P / Invoke来非托管代码和一些罕见的情况下,位掩码。在.NET中,我们做的大部分bitmasking正常签署整数。

Their main use is in P/Invoke to unmanaged code and some rare bitmask situations. In .NET, we do most bitmasking with normal signed ints.

这篇关于使用int和UINT以及何时使用的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆