Search code examples
c#performanceint32uint32

In C# is there any significant performance difference for using UInt32 vs Int32


I am porting an existing application to C# and want to improve performance wherever possible. Many existing loop counters and array references are defined as System.UInt32, instead of the Int32 I would have used.

Is there any significant performance difference for using UInt32 vs Int32?


Solution

  • I don't think there are any performance considerations, other than possible difference between signed and unsigned arithmetic at the processor level but at that point I think the differences are moot.

    The bigger difference is in the CLS compliance as the unsigned types are not CLS compliant as not all languages support them.