5

I was just wondering whether anyone knows why the property FileInfo.Length is of type long instead of ulong? I don't think the size of a file can ever be negative.

Was this a general design decision for the .NET framework, since other length properties (e.g. string.Length) are also of type long?

M4N
  • 94,805
  • 45
  • 217
  • 260

1 Answers1

8

ulong isn't a CLS-compliant type. The framework tends to use CLS-compliant types where possible.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • Why is there (sort of) a "mismatch" between CLS and C#? I mean, both specifications were made by Microsoft, probably at the same time. Or is there really a .NET language which does not support unsigned data types? – M4N Jul 07 '11 at 08:30
  • @M4N: I don't know, to be honest... but I wouldn't be surprised to find examples of .NET languages which don't support operator overloading, for example. I think it's reasonable to set a "lowest common denominator" of language features, although I wouldn't like to say whether it was pitched correctly or not. – Jon Skeet Jul 07 '11 at 08:31
  • I seem to remember that VB.NET had weaker support for unsigned types in the initial version, but I don't know details. – Jon Skeet Jul 07 '11 at 08:32
  • 1
    Half of the languages supported by Microsoft at the .NET introduction didn't support unsigned types (VB and J#). – Hans Passant Jul 07 '11 at 08:42