3

What is the reasoning behind Interlocked.Read() only being defined for Int64 and not for UInt64? I wouldn't have thought there was any difference between the two types.

Nicholas
  • 1,392
  • 16
  • 38

1 Answers1

3

The Interlocked class is defined in mscorlib which is CLS-Compliant and UInt32 and UInt64 are, for better or for worse, not CLS-Compliant.

As for why they are not CLS-Compliant, see this SO article:

Community
  • 1
  • 1
Rick Sladkey
  • 33,988
  • 6
  • 71
  • 95
  • 1
    CLS compliance seems a silly reason not to define Interlocked operations for unsigned variables. The purpose of CLS compliance is to ensure that languages without certain optional features are not excluded from using library functions that would be useful to them if they were defined differently. A CompareExchange overload which accepts unsigned parameters would be useful to those languages with unsigned types, and useless to those without it, but defining an overload that way would not impair the usefulness of anything that *would otherwise be useful* in such a language. – supercat Feb 14 '11 at 17:38