While your code is free to do whatever you want, in the Framework we try to use 
int instead of uint due to CLS compliant rules.

CLS compliance is basically a minimum set of rules that a language must follow 
to play nicely with other the runtime and .NET languages. Unsigned integers are 
not required to be supported by all languages, hence the usage of int instead 
of uint.

From: [email protected] [mailto:[email protected]] On 
Behalf Of Tom Rutter
Sent: Monday, May 09, 2011 5:14 PM
To: ozDotNet
Subject: Use of unsigned integers

I often see methods which take an int arg and the first thing they do is check 
if the int is non negative and then throw exception if it is. Would using a 
uint be better as the type checking would automatically get handled at compile 
time?
Does it depend on if its a public api?I heard once fxcop didn't like uints in 
public apis but it's not complaining for me now.

Any thoughts on this?

Reply via email to