[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Paul Naude

2/16/2006 6:24:00 AM

I am sure there must be a special forum for this topic but why was it decided
to use zero based programming in .NET?

As an engineer, although we start measuring from zero, a complete unit is
counted as 1, thus you start to number items with 1 and not 0.

To program in zero base is something to get used to but when displaying info
to the user which has to be one based (no user I know like to see his first
racing horse being numbered 0), errors start brewing.

I was just wondering if there is a good solid reason why someone decided
that it should be that way (because it was so for a long time - because
someone just did it that way), or what, since in all practical appllications
we count starting with 1.

Does any sportsman have a 0 on his jersey?




1 Answer

David Pokluda

2/16/2006 6:10:00 PM

0

I think it is based on the way arrays really work -- indexes are offsets
from array base address in memory. Therefore the first element has offset 0.
That's why in C/C++ we have zero based arrays. Why in .NET? I guess because
authors of C# (the main language for .NET) were C/C++ developers. ;-)

I don't know -- this is just my explanation.

Regards,
David.

"Paul Naude" <PaulNaude@discussions.microsoft.com> wrote in message
news:24EC585A-5FC5-4CA6-AE0D-B8E956B0371E@microsoft.com...
>I am sure there must be a special forum for this topic but why was it
>decided
> to use zero based programming in .NET?
>
> As an engineer, although we start measuring from zero, a complete unit is
> counted as 1, thus you start to number items with 1 and not 0.
>
> To program in zero base is something to get used to but when displaying
> info
> to the user which has to be one based (no user I know like to see his
> first
> racing horse being numbered 0), errors start brewing.
>
> I was just wondering if there is a good solid reason why someone decided
> that it should be that way (because it was so for a long time - because
> someone just did it that way), or what, since in all practical
> appllications
> we count starting with 1.
>
> Does any sportsman have a 0 on his jersey?
>
>
>
>