Show line number Visual Studio(Applicable to all versions)

Lionsure 2020-08-30 Original by the website

Visual Studio does not display line number of code by default. It does not matter when writing the code, but when the code is debugged, it is difficult to find the line where the error occurred without the line number, so it is still necessary to display line number in Visual Studio.

Although Visual Studio is constantly updated and upgraded, the method of setting the line number has not changed. The following uses Visual Studio 2019 as an example to introduce the method of displaying line number in Visual Studio. For other versions, refer to it.

 

I. Show line number Visual Studio

(1) Quick steps (Show line number Visual Studio)

Tools → Options → Text Editor → Select the language(such as C#) to display the line number → check the "Line numbers" → OK.

 

(2) Detailed steps (Show line number Visual Studio, or Visual Studio row number)

1. Select "Tools", and the drop-down menu will pop up as shown in Figure 1:

display line number in Visual Studio

Figure 1

2. Select "Options" to open the dialog box as shown in Figure 2:

Show line number Visual Studio

Figure 2

3. Select "Text Editor", various programming languages are displayed under it, click it to display the line numbers in which language you want, and then check "Line numbers"(for example, C# is selected in Figure 2).

4. Generally speaking, just set your own common language. If you find it too cumbersome to set one by one, you can select "All Languages", and then check "Line numbers", all languages will display line numbers.

5. Maybe the version of Visual Studio is a little lower, and there is no option of "all languages", then you can only set one by one.

 

II. Remove line number in Visual Studio

Follow the above steps to open the dialog box shown in Figure 2, uncheck "Line numbers." and click "OK".