5

I'm was messing around with some parsing of a binary file when I came across something I was wondering about.

The Stream.Positionproperty is of the type Int64or long. Why is this? Shouldn't it make more sense to use a UInt64 since the position in a stream can't be negative?

Anyone know what's the use of this being a signed long instead of an unsigned one?

Timo Willemsen
  • 8,717
  • 9
  • 51
  • 82
  • possible duplicate of [Why does .NET use int instead of uint in certain classes?](http://stackoverflow.com/questions/782629/why-does-net-use-int-instead-of-uint-in-certain-classes) – dtb Nov 16 '10 at 21:15
  • @dtb ya might want to [read this.](http://blog.stackoverflow.com/2010/11/dr-strangedupe-or-how-i-learned-to-stop-worrying-and-love-duplication/) –  Nov 16 '10 at 21:18
  • 1
    Dtb thanks for that link it cleared a lot up for me. I haven't found it in my searches because I thought it was something specific for the Stream class. Didn't thought other classes had the same *problem* too. – Timo Willemsen Nov 16 '10 at 21:21
  • @dtb I guess you took less away from it than I did. –  Nov 16 '10 at 21:27
  • @Will: I don't see your point. I just remembered some old post that asks a very similar question (because I happened to answer it). Linking that might be helpful. If four other people think this question is so similar that it should be closed, let it be closed. Are you telling me I'm contributing to SO in a wrong way? – dtb Nov 16 '10 at 21:33
  • @dtb sorry, I assumed you were one of the people voting to close. Guess I was wrong. –  Nov 16 '10 at 21:59

1 Answers1

10

UInt64 is not CLS Compatible, and all classes in the BCL need to be (at least on their public/protected stuff)

The real question is of couse why UInt64 isn't CLS Compatible, and that was already asked and answered :)

Community
  • 1
  • 1
Michael Stum
  • 177,530
  • 117
  • 400
  • 535
  • 1
    [Why we don't have unsigned types in the CLS](http://blogs.msdn.com/b/brada/archive/2003/09/02/50285.aspx) – dtb Nov 16 '10 at 21:17
  • Aah, actually it's pretty easy ^^ I understand it thanks a lot. Never thought it would've had anything to do with the CLS. – Timo Willemsen Nov 16 '10 at 21:19