This just struck me as an oversight by Microsoft. Since arrays and other data-structures within the .NET framework begin from zero (zero-based) why don't we have a line 0 within the code view in Visual Studio?

Ponder that one :-)

  • Visual Studio is older than .NET. By a lot. (True, it is written in another zer-based language, but my point is no .NET convention should be assumed to drive Visual Studio decisions.) Commented Aug 18, 2011 at 14:09
  • en.wikipedia.org/wiki/Natural_number
    – StuperUser
    Commented Aug 18, 2011 at 14:09
  • Because no one answering this question has a sense of humour? ;-)
    – Arjailer
    Commented Aug 18, 2011 at 14:53
  • 2
    Every commercial product has a product manager / marketing director, whose job it is to maximize the friendliness and minimize the shock value to buyers, so they buy. Only programmers think zero is the first number. Commented Aug 18, 2011 at 16:10
  • 1
    @MikeDunlavey, but the point is, Visual Studio is made for programmers!
    – svick
    Commented May 8, 2012 at 0:47

6 Answers 6


Because they did a good job at separating the user model from the programming model, that's why. The same reason why most apps don't ask you, for example,

Please enter a varchar(200) representing your name.

Take a lesson from that.

  • 2
    Great answer. A lot of programmers can benefit from thinking like a user again. Commented Aug 18, 2011 at 21:40
  • I agree with this answer, but I don't think this answer is necessarily as obvious as JohnFx's tone would imply. In the case of Visual Studio (or any IDE), there's no difference between the "user model" and the "programming model", since all users are likely programmers. If I am writing software for some aliens who use a base-37 numerical system, my user model will necessarily display integers in base-37. So, if I'm writing an IDE for programmers, who are most likely used to thinking in zero-based indexing, isn't that also my user model?? Commented Jul 17, 2014 at 21:06
  • I strongly disagree. Just because the user is a programmer does not make zero based counting part of the user model. Programmers only use zero based systems because the compiler expects it. Now if you were writing software where a COMPUTER was the user I would agree. I've been a programmer all my life and I do not count real world objects starting with zero.
    – JohnFx
    Commented Jul 18, 2014 at 20:34
  1. All arrays and data-structures are indexed based on zero, not just in .NET.
  2. Array indexes are numbered for the computer, text lines in a document are numbered for us.
  3. See screenshot :)

enter image description here

  • 12
    "All array and data-structures are indexed based on zero" -- this is not true, all arrays are not zero-indexed, though it's quite common these days. Many historical languages used mathematical-style 1-based indexing (Fortran and COBOL come to mind) but even the more modern Lua uses 1-based indexing. Commented Aug 18, 2011 at 12:21
  • 1
    @Dean Harding I meant they are - internally. Numbering them from 1 is sort of syntax sugar. At least this is my understanding...? Anyhow, .NET standard is much more of a rule than an exception in this aspect. Commented Aug 18, 2011 at 12:24
  • Worth noting than VS is not the only editor doing this and that it would be harsh to blame it for its behavior. Even Emacs numbers lines starting from 1 (and rightly so, as you pointed out).
    – haylem
    Commented Aug 18, 2011 at 13:36
  • 1
    @Dean - Actually in fortran you can start the lower index at whatever you want a(0:19), a(-19,19) ... it is only by default that they start at one a(19) assumes the lower bound is 1. I do understand the point you were trying to make however.
    – Rook
    Commented Aug 18, 2011 at 14:28
  • 2
    Inception or recursion?
    – Kevin
    Commented Aug 18, 2011 at 15:25

There is a difference between counting and indexing. The index can start at any number (some languages support that), but for many reasons it is most often practical to have it start at zero. Counting also starts at zero, but as soon as one does count a set that is not empty, the first element is 1, and so on.


Because it is not natural to assume that the first line is the 0th line. Much like it's not natural either that arrays first element is at 0. However that's the first number that can be used in an unsigned integer to index an array with. So instead of wasting one element we use it.

  • 4
    In the case of counting, you say how many elements you have. While in indexing, you merely tell the difference to the base index.
    – Ingo
    Commented Aug 18, 2011 at 13:12

By convention, normal humans count starting from 1, while many programmers and some mathematicians count starting from 0.

The question you have raised about line numbers is not specific to Microsoft Visual Studio. It applies to every other text editor tool, because counting lines from 1 has been adopted as a universal convention in software.

The countless other tools that count text lines from 1 include Windows Notepad, IDE text editors, text editors on Linux, Firefox's JavaScript console, compiler error messages, and so on and so forth.

While it wouldn't be wrong to count lines starting from 0, it would break the established convention and cause a massive amount of confusion to everyone involved, from the developers to the users.

See also:

  • "massive amount of confusion"? Probably not...
    – Kenneth
    Commented Aug 18, 2011 at 14:11
  • I don't know any mathematicians (and I do know quite a few) that start counting from one. They deal with 0 when needed in where needed, but in real life they all count from one.
    – Rook
    Commented Aug 18, 2011 at 14:26
  • Except for numbering floors in European countries. For some reason that is zero based.
    – JohnFx
    Commented Jan 9, 2018 at 21:56
  • @Kenneth Yes it would. If a compiler told you an error occurred on line 5 (1-based, as per convention), but you jump to line 5 (0-based, as per the question) in your text editor, that is exactly the problem that would happen by breaking conventions.
    – Nayuki
    Commented Oct 20, 2023 at 4:37

A link which counters some of Dijkstra's points (in an article which is sooner or later gonna come out in this discussion).

Why numbering should start at one

Not the answer you're looking for? Browse other questions tagged or ask your own question.