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.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
uintmeans unsigned int, you can use it for a 0 .. +4G rangewhere the normal (signed) int has a -2G .. +2G range.
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.
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.