Why do most .NET libraries use signed integers for indices?  
Author Message
KevinHall





PostPosted: .NET Base Class Library, Why do most .NET libraries use signed integers for indices? Top

I'm developing a .NET wrapper around a C++ library that uses size_t (which is unsigned) for indices, and someone pointed out to me that most .NET libraries use signed integers instead. I was wondering if there were any good reasons for this and if i should make my wrapper accept signed indices or continue to use unsigned indices.

Many thanks!

- Kevin Hall




.NET Development25  
 
 
RayV





PostPosted: .NET Base Class Library, Why do most .NET libraries use signed integers for indices? Top

If my understanding is correct, unsigned integers are not CLS-compliant. This would be a big reason to exclude them from classes used in the base class library. Conversely, if you want to be CLS-compliant, you have to limit yourself to integers of the signed variety (at least in your external API).

Also see this overview.