Remarks on Numeric Types

Dated Jan 2, 2026; last modified on Fri, 02 Jan 2026

Inconveniences of Unsigned Types in .NET

Languages like C++ come with convenient support for unsigned integer types where non-negative values make sense. std::size_t is the unsigned integer type of the sizeof and alignof operators. std::size_t is also used when indexing C++ containers.

In contrast, .NET tends to use signed integer types even where unsigned ones would be more intuitive, e.g.,

  • List<T>.Count returns an Int32
  • Indexing into a List<T> takes in an Int32 index

.NET is language independent. Languages like C#, F#, and Visual Basic target .NET implementations. The Common Language Specification (CLS) is the set of features that are common to all the languages. Of relevance is the fact that Byte, Int16, Int32, and Int64 are the only CLS-compliant integer types.

The use of signed integer types over unsigned ones also appears in other areas like LINQ helpers, e.g., Enumerable.Sum has overloads for Int32 and Int64 but not the unsigned versions.

References

  1. std::size_t - cppreference.com. en.cppreference.com . Accessed Jan 2, 2026.

https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1.count?view=net-10.0

  1. List<T>.Count Property (System.Collections.Generic) | Microsoft Learn. learn.microsoft.com . Accessed Jan 2, 2026.
  2. List<T>.Item[Int32] Property (System.Collections.Generic) | Microsoft Learn. learn.microsoft.com . Accessed Jan 2, 2026.
  3. Language independence and language-independent components - .NET | Microsoft Learn. learn.microsoft.com . Accessed Jan 2, 2026.
  4. c# - Signed vs. unsigned integers for lengths/counts - Stack Overflow. stackoverflow.com . Accessed Jan 2, 2026.
  5. Enumerable.Sum Method (System.Linq) | Microsoft Learn. learn.microsoft.com . Accessed Jan 2, 2026.