Visual studio code microsoft

Visual studio code microsoft

Узнайте, как использовать редактор кода

В этом 10-минутном введении, посвященном редактору кода в Visual Studio, мы добавим код в файл, чтобы рассмотреть некоторые способы, упрощающие написание, понимание кода и навигацию по нему в Visual Studio.

Установите Visual Studio бесплатно со страницы скачиваемых материалов Visual Studio, если еще не сделали этого.

Установите Visual Studio бесплатно со страницы скачиваемых материалов Visual Studio, если еще не сделали этого.

Эта статья предполагает, что вы уже знакомы с языком программирования. В противном случае рекомендуется сначала посмотреть одно из кратких руководств по языкам программирования Python или C# либо по созданию консольного приложения с помощью Visual Basic или C++.

Чтобы выполнять действия, описанные в этой статье, выберите нужные параметры C# для Visual Studio. Сведения о настройке параметров для интегрированной среды разработки (IDE) вы найдете в этой статье.

Создание файла кода

Для начала создайте файл и добавьте в него код.

Запустите Visual Studio. Нажмите клавишу ESC или нажмите Продолжить без кода в окне запуска, чтобы открыть среду разработки.

В меню Файл в строке меню выберите пункты Создать>Файл.

В диалоговом окне Новый файл в разделе Общие выберите Класс Visual C# и нажмите кнопку Открыть.

Новый файл открывается в редакторе с каркасом класса C#. (Обратите внимание, что нам не нужно создавать полный проект Visual Studio, чтобы получить некоторые преимущества редактора кода. Вам нужен только файл кода!)

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Запустите Visual Studio. Нажмите клавишу ESC или щелкните команду Продолжить без кода в окне запуска, чтобы открыть среду разработки.

В меню Файл в строке меню выберите элементы Создать>Файл или нажмите клавиши CTRL+N.

В диалоговом окне Новый файл в разделе Общие выберите Класс Visual C# и нажмите кнопку Открыть.

Новый файл открывается в редакторе с каркасом класса C#.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Использование фрагментов кода

Visual Studio предоставляет удобные фрагменты кода, позволяющие быстро и легко создавать часто используемые блоки кода. Фрагменты кода доступны для различных языков программирования, включая C#, Visual Basic и C++.

Давайте добавим фрагмент void Main C# в файл.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Два раза нажмите клавишу TAB, чтобы вставить фрагмент кода.

Для разных языков программирования доступны различные фрагменты кода. Вы можете просмотреть фрагменты кода, доступные для используемого языка, выбрав Изменить>IntelliSense>Вставить фрагмент и указав папку вашего языка. Для C# список выглядит следующим образом.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Два раза нажмите клавишу TAB, чтобы вставить фрагмент кода.

Для разных языков программирования доступны соответствующие фрагменты кода. Вы можете просмотреть фрагменты кода, доступные для используемого языка. Для этого выберите элементы Изменить>IntelliSense>Вставить фрагмент или нажмите клавиши CTRL+K и CTRL+X, а затем укажите папку для своего языка программирования. Для C# список фрагментов кода выглядит следующим образом.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Список включает фрагменты кода для создания класса, конструктора, цикла for, операторов if и switch и многое другое.

Закомментирование кода

Панель инструментов, которая находится в строке кнопок под строкой меню в Visual Studio, поможет повысить продуктивность написания кода. Например, можно переключить режим завершения IntelliSense (IntelliSense — это помощник в написании кода, который отображает список подходящих методов и многое другое), увеличить или уменьшить отступ строки или закомментировать код, который вы не хотите компилировать. В этом разделе мы закомментируем код.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Символы комментария C# // добавляются в начало каждой выбранной строки, чтобы закомментировать код.

Панель инструментов текстового редактора, которая представляет строку с кнопками под строкой меню в Visual Studio, делает написание кода более продуктивным. Например, вы можете переключить режим завершения IntelliSense, увеличить либо уменьшить отступ для строк или закомментировать фрагмент кода, который не нужно компилировать.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Давайте закомментируем некоторую часть кода.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Символы комментария C# // добавляются в начало каждой выбранной строки, чтобы закомментировать код.

Если нужно раскомментировать строки, выберите их, а затем нажмите кнопку Раскомментировать выбранные строки на панели инструментов текстового редактора. Если вы предпочитаете использовать клавиатуру, нажмите клавиши CTRL+K, CTRL+U.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Свертывание блоков кода

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Просмотр определений символов

Щелкните правой кнопкой мыши любой из экземпляров string и выберите пункт Показать определение в контекстном меню. Или нажмите Alt+F12.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Закройте окно просматриваемого определения, щелкнув небольшое поле со знаком «x» в его правом верхнем углу.

В редакторе Visual Studio можно легко проверить определение типа, метода или переменной. Один из способов — перейти к файлу, который содержит определение. Для этого выберите команду Перейти к определению или нажмите клавишу F12 в любом месте, где указана ссылка на этот символ. Сделать это еще быстрее и даже без перемещения фокуса с кода можно, щелкнув команду Показать определение.

Щелкните правой кнопкой мыши любой из экземпляров string и выберите пункт Показать определение в контекстном меню. Или нажмите клавиши ALT+F12.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Закройте окно просматриваемого определения, щелкнув небольшое поле со знаком Х справа в верхнем углу.

Использование IntelliSense для завершения слов

Технология IntelliSense крайне полезна при написании кода. Она может отображать сведения о доступных членах типа или сведения о параметрах для различных перегрузок метода. Вы также можете использовать IntelliSense для завершения слова после того, как ввели достаточно знаков для однозначного его определения. Давайте добавим строку кода для вывода упорядоченных строк в окне консоли — это стандартное место для отображения выходных данных программы.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Чтобы вставить оставшуюся часть слова query с помощью функции завершения слов IntelliSense, нажмите клавишу Tab.

Технология IntelliSense крайне полезна при написании кода. Она может отображать сведения о доступных членах типа или сведения о параметрах для различных перегрузок метода. Вы также можете использовать IntelliSense для завершения слова после того, как ввели достаточно знаков для однозначного его определения.

Давайте добавим строку кода для вывода упорядоченных строк в окне консоли — это стандартное место для отображения выходных данных программы.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Чтобы вставить оставшуюся часть слова query с помощью функции завершения слов IntelliSense, нажмите клавишу TAB.

Рефакторинг имени

Поместите курсор на определение переменной _words и выберите пункт Переименовать в контекстном меню или нажмите клавиши CTRL+R, CTRL+R.

В верхней правой части редактора отображается всплывающее диалоговое окно Переименование.

Введите нужное имя words. Обратите внимание, что ссылка на words в запросе также переименовывается автоматически. Перед нажатием клавиши ВВОД установите флажок Включить комментарии во всплывающем окне Переименование.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Нажмите клавишу ВВОД.

Поместите курсор на определение переменной someWords и выберите команду Переименовать в контекстном меню или нажмите клавишу F2.

Справа в верхней части окна редактора отобразится диалоговое окно Переименование.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Введите имя unsortedWords. Вы увидите, что ссылка на unsortedWords в операторе назначения query также переименовывается автоматически. Прежде чем нажать клавишу ВВОД или щелкнуть действие Применить, установите флажок Включить комментарии во всплывающем окне Переименовать.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Нажмите клавишу ВВОД или щелкните команду Применить в диалоговом окне Переименование.

Оба вхождения someWords в коде, а также текст someWords в комментарии к коду были переименованы.

Navigate code

Visual Studio provides numerous ways to navigate code in the editor. This topic summarizes the different ways you can navigate your code, and provides links to topics that go into more detail.

Navigate Backward and Navigate Forward commands

You can use the Navigate Backward (Ctrl+) and Navigate Forward (Ctrl+Shift+) buttons on the toolbar to move the insertion point to previous locations, or to return to a more recent location from a previous location. These buttons retain the last 20 locations of the insertion point. These commands are also available on the View menu, under Navigate Backward and Navigate Forward.

Navigation bar

You can use the navigation bar (the drop-down boxes at the top of the code window) to navigate to code in a codebase. You can choose a type or member to go directly to it. The navigation bar appears when you edit code in a Visual Basic, C#, or C++ code base. In a partial class, members defined outside the current code file may be disabled (they appear in gray).

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

You can navigate around the drop-down boxes as follows:

To navigate to another project that the current file belongs to, choose it in the left drop-down.

To navigate to a class or type, choose it in the middle drop-down.

To navigate directly to a procedure or other member of a class, choose it in the right drop-down.

To shift focus from the code window to the navigation bar, press the shortcut key combination Ctrl+F2.

To shift focus from box to box on the navigation bar, press the Tab key.

To select the navigation bar item that has focus and return to the code window, press the Enter key.

To return focus from the navigation bar to the code without selecting anything, press the Esc key.

To hide the navigation bar, change the Navigation bar option in the Text Editor All Languages settings (Tools > Options > Text Editor > All Languages), or you can change the settings for individual languages.

Find all references

Finds all the references to the selected element in the solution. You can use this to check possible side-effects of a large refactoring, or to verify «dead» code. Press F8 to jump between results. For more information, see Find references in your code.

InputFunction
KeyboardPlace your text cursor somewhere inside the type name, and press Shift+F12
MouseSelect Find All References from the right-click menu

Reference highlighting

When you click a symbol in the source code, all instances of that symbol are highlighted in the document. The highlighted symbols may include declarations and references, and many other symbols that Find All References would return. These include the names of classes, objects, variables, methods, and properties. In Visual Basic code, keywords for many control structures are also highlighted. To move to the next or the previous highlighted symbol, press Ctrl+Shift+Down Arrow or Ctrl+Shift+Up Arrow. You can change the highlighting color in Tools > Options > Environment > Fonts and Colors > Highlighted Reference.

Go To commands

Go To has the following commands, which are available in the Edit menu under Go To:

Go To Line (Ctrl+G): Move to the specified line number in the active document.

Go To All (Ctrl+T or Ctrl+,): Move to the specified line, type, file, member, or symbol.

Go To File (Ctrl+1, Ctrl+F): Move to the specified file in the solution.

Go To Recent File (Ctrl+1, Ctrl+R): Move to the specified, recently visited file in the solution.

Go To Type (Ctrl+1, Ctrl+T): Move to the specified type in the solution.

Go To Member (Ctrl+1, Ctrl+M): Move to the specified member in the solution.

Go To Symbol (Ctrl+1, Ctrl+S): Move to the specified symbol in the solution.

In Visual Studio 2017 version 15.8 and later, the following Go To navigation commands are also available:

Go To Next Issue in File (Alt+PgDn) and Go To Previous Issue in File (Alt+PgUp)

Go To Last Edit Location (Ctrl+Shift+Backspace)

See more about these commands in the Find code using Go To commands topic.

Go To Definition

Go To Definition takes you to the definition of the selected element. For more information, see Go To Definition and Peek Definition.

InputFunction
KeyboardPlace your text cursor somewhere inside the type name, and press F12
MouseRight-click on the type name and select Go To Definition OR press Ctrl and click on the type name

Peek Definition

Peek Definition displays the definition of the selected element in a window without navigating away from your current location in the code editor. For more information, see How to: View and edit code by using Peek Definition and Go To Definition and Peek Definition.

InputFunction
KeyboardPlace your text cursor somewhere inside the type name, and press Alt+F12
MouseRight-click on the type name and select Peek Definition OR press Ctrl and click on the type name (if you have the Open definition in peek view option checked)

Go To Implementation

Using Go To Implementation, you can navigate from a base class or type to its implementations. If there are multiple implementations, you will see them listed in the Find Symbol Results window:

InputFunction
KeyboardPlace your text cursor somewhere inside the type name, and press Ctrl+F12
MouseRight-click on the type name and select Go To Implementation

Go To Base

Using Go To Base, you can navigate up the inheritance chain of the selected element. If there are multiple results, you will see them listed in the Go To Base window:

InputFunction
KeyboardPlace your text cursor somewhere inside the type name, and press Alt+Home
MouseRight-click on the type name and select Go To Base

Call Hierarchy

You can view calls to and from a method in the Call Hierarchy window:

InputFunction
KeyboardPlace your text cursor somewhere inside the type name, and press Ctrl+K, Ctrl+T
MouseRight-click on the member name and select View Call Hierarchy

Next Method and Previous Method commands (Visual Basic)

In Visual Basic code files, use these commands to move the insertion point to different methods. Choose Edit > Next Method or Edit > Previous Method.

Structure Visualizer

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To disable structure guide lines, go to Tools > Options > Text Editor > General and clear the Show structure guide lines box.

Enhanced scroll bar

You can use the enhanced scroll bar in a code window to get a bird’s-eye view of your code. In map mode, you can see previews of the code when you move the cursor up and down the scroll bar. For more information, see How to: Track your code by customizing the scroll bar.

CodeLens information

You can find info about specific code, like changes and who made those changes, references, bugs, work items, code reviews, and unit test status when you use CodeLens in the code editor. CodeLens works like a heads-up display when you use Visual Studio Enterprise with Team Foundation Server. See Find code changes and other history.

Welcome to the Visual Studio IDE

An integrated development environment (IDE) is a feature-rich program that supports many aspects of software development. The Visual Studio IDE is a creative launching pad that you can use to edit, debug, and build code, and then publish an app. Over and above the standard editor and debugger that most IDEs provide, Visual Studio includes compilers, code completion tools, graphical designers, and many more features to enhance the software development process.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The preceding image shows Visual Studio with an open project that shows key windows and their functionality:

In Solution Explorer, at upper right, you can view, navigate, and manage your code files. Solution Explorer can help organize your code by grouping the files into solutions and projects.

The central editor window, where you’ll probably spend most of your time, displays file contents. In the editor window, you can edit code or design a user interface such as a window with buttons and text boxes.

In Git Changes at lower right, you can track work items and share code with others by using version control technologies like Git and GitHub.

Editions

Visual Studio is available for Windows and Mac. Visual Studio for Mac has many of the same features as Visual Studio for Windows, and is optimized for developing cross-platform and mobile apps. This article focuses on the Windows version of Visual Studio.

There are three editions of Visual Studio: Community, Professional, and Enterprise. See Compare Visual Studio editions to learn about which features are supported in each edition.

Popular productivity features

Some popular features in Visual Studio that improve your productivity when developing software include:

Squiggles are wavy underlines that alert you to errors or potential problems in your code as you type. These visual clues help you fix problems immediately, without waiting to discover errors during build or runtime. If you hover over a squiggle, you see more information about the error. A lightbulb might also appear in the left margin showing Quick Actions you can take to fix the error.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Refactoring includes operations such as intelligent renaming of variables, extracting one or more lines of code into a new method, and changing the order of method parameters.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

IntelliSense is a set of features that display information about your code directly in the editor and, in some cases, write small bits of code for you. It’s like having basic documentation inline in the editor, so you don’t have to look up type information elsewhere.

The following illustration shows how IntelliSense displays a member list for a type:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual Studio menus, options, and properties can seem overwhelming at times. Visual Studio search, or Ctrl+Q, is a great way to rapidly find IDE features and code in one place.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

For information and productivity tips, see How to use Visual Studio search.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

For information and productivity tips, see How to use Visual Studio search.

Collaboratively edit and debug with others in real time, regardless of your app type or programming language. You can instantly and securely share your project. You can also share debugging sessions, terminal instances, localhost web apps, voice calls, and more.

The Call Hierarchy window shows the methods that call a selected method. This information can be useful when you’re thinking about changing or removing the method, or when you’re trying to track down a bug.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

CodeLens helps you find code references, code changes, linked bugs, work items, code reviews, and unit tests, without leaving the editor.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The Go To Definition feature takes you directly to the location of a function or type definition.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The Peek Definition window shows a method or type definition without opening a separate file.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Install Visual Studio

In this section, you create a simple project to try out some of the things you can do with Visual Studio. You use IntelliSense as a coding aid, debug an app to see a variable value during app execution, and change the color theme.

To get started, download Visual Studio and install it on your system. The modular installer enables you to choose and install workloads, which are groups of features needed for the programming languages or platforms you want. To follow the steps to create a program, be sure to select the .NET Core cross-platform development workload during installation.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To get started, download Visual Studio and install it on your system. In the modular installer, you choose and install workloads, which are groups of features you need for the programming languages or platforms you want. To use the following steps to create a program, be sure to select the .NET desktop development workload during installation.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

When you open Visual Studio for the first time, you can sign in by using your Microsoft account or your work or school account.

Create a program

Dive in and create a simple program.

Open Visual Studio.

The start window appears with options for cloning a repo, opening a recent project, or creating a new project.

Choose Create a new project.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The Create a new project window opens and shows several project templates. A template contains the basic files and settings required for a given project type.

To find the template we want, type or enter .net core console in the search box. The list of available templates is automatically filtered based on the keywords you entered. You can further filter the template results by choosing C# from the All language drop-down list, Windows from the All platforms list, and Console from the All project types list.

Select the Console Application template, and then click Next.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In the Configure your new project window, enter HelloWorld in the Project name box, optionally change the directory location for your project files (the default locale is C:\Users\ \source\repos ), and then click Next.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In the Additional information window, verify that .NET Core 3.1 appears in the Target Framework drop-down menu, and then click Create.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual Studio creates the project. It’s a simple «Hello World» application that calls the Console.WriteLine() method to display the literal string «Hello World!» in the console (program output) window.

Shortly, you should see something like the following screen:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The C# code for your application shows in the editor window, which takes up most of the space. Notice that the text is automatically colorized to indicate different parts of the code, such as keywords and types. In addition, small, vertical dashed lines in the code indicate which braces match one another, and line numbers help you locate code later. You can choose the small, boxed minus signs to collapse or expand blocks of code. This code outlining feature lets you hide code you don’t need, helping to minimize onscreen clutter. The project files are listed on the right side in a window called Solution Explorer.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

There are other menus and tool windows available, but let’s move on for now.

Now, start the app. You can do this by choosing Start Without Debugging from the Debug menu on the menu bar. You can also press Ctrl+F5.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoftStart without Debugging menu item.» data-linktype=»relative-path»>

Visual Studio builds the app, and a console window opens with the message Hello World!. You now have a running app!

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To close the console window, press any key on your keyboard.

Let’s add some more code to the app. Add the following C# code before the line that says Console.WriteLine(«Hello World!»); :

This code displays What is your name? in the console window, and then waits until the user enters some text followed by the Enter key.

Change the line that says Console.WriteLine(«Hello World!»); to the following code:

Run the app again by selecting Debug > Start Without Debugging or by pressing Ctrl+F5.

Visual Studio rebuilds the app, and a console window opens and prompts you for your name.

Enter your name in the console window and press Enter.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Press any key to close the console window and stop the running program.

Start Visual Studio. The start window appears with options for cloning a repo, opening a recent project, or creating a new project.

Choose Create a new project.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The Create a new project window opens and shows several project templates. A template contains the basic files and settings required for a given project type.

To find a template, you can type or enter keywords in the search box. The list of available templates filters based on the keywords you enter. You can further filter the template results by choosing C# from the All languages dropdown list, Windows from the All platforms list, and Console from the All project types list.

Select the Console Application template, and then select Next.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In the Configure your new project window, enter HelloWorld in the Project name box. Optionally, change the project directory location from the default location of C:\Users\ \source\repos, and then select Next.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In the Additional information window, verify that .NET 6.0 appears in the Target Framework drop-down menu, and then select Create.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual Studio creates the project. The program is a simple «Hello World» application that calls the Console.WriteLine() method to display the string Hello, World! in a console window.

The project files appear on the right side of the Visual Studio IDE, in a window called the Solution Explorer. In the Solution Explorer window, select the Program.cs file. The C# code for your app opens in the central editor window, which takes up most of the space.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The code is automatically colorized to indicate different parts, such as keywords and types. Line numbers help you locate code.

Small, vertical dashed lines in the code indicate which braces match one another. You can also choose small, boxed minus or plus signs to collapse or expand blocks of code. This code outlining feature lets you hide code you don’t need to see, helping to minimize onscreen clutter.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Many other menus and tool windows are available.

Start the app by choosing Debug > Start Without Debugging from the Visual Studio top menu. You can also press Ctrl+F5.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoftStart without Debugging menu item.» data-linktype=»relative-path»>

Visual Studio builds the app, and a console window opens with the message Hello, World!. You now have a running app!

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To close the console window, press any key.

Let’s add some more code to the app. Add the following C# code before the line that says Console.WriteLine(«Hello World!»); :

This code displays What is your name? in the console window, and then waits until the user enters some text.

Change the line that says Console.WriteLine(«Hello World!»); to the following line:

Run the app again by selecting Debug > Start Without Debugging or pressing Ctrl+F5.

Visual Studio rebuilds the app, and a console window opens and prompts you for your name.

Type your name in the console window and press Enter.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Press any key to close the console window and stop the running program.

Use refactoring and IntelliSense

Let’s look at a couple of the ways that refactoring and IntelliSense can help you code more efficiently.

First, rename the name variable:

Double-click the name variable, and type the new name for the variable, username.

A box appears around the variable, and a light bulb appears in the margin.

Select the light bulb icon to show the available Quick Actions. Select Rename ‘name’ to ‘username’.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The variable is renamed across the project, which in our case is only two places.

A box displays the members of the DateTime class. The description of the currently selected member also displays in a separate box.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Below that line, enter the following lines of code:

Console.Write is different from Console.WriteLine in that it doesn’t add a line terminator after it prints. That means that the next piece of text that’s sent to the output will print on the same line. You can hover over each of these methods in your code to see their descriptions.

Select the screwdriver icon to see available suggestions from Visual Studio. This case shows the Inline temporary variable refactoring to remove a line of code without changing the overall code behavior.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Select Inline temporary variable to refactor the code.

Run the program again by pressing Ctrl+F5. The output looks something like this:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Debug code

When you write code, you should run it and test it for bugs. Visual Studio’s debugging system lets you step through code one statement at a time and inspect variables as you go. You can set breakpoints that stop execution of the code at a particular line, and observe how the variable value changes as the code runs.

Set a breakpoint to see the value of the username variable while the program is running.

Set a breakpoint on the line of code that says Console.WriteLine($»\nHello !»); by clicking in the far-left margin, or gutter, next to the line. You can also select the line of code and then press F9.

A red circle appears in the gutter, and the line is highlighted.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Start debugging by selecting Debug > Start Debugging or pressing F5.

When the console window appears and asks for your name, enter your name.

The focus returns to the Visual Studio code editor, and the line of code with the breakpoint is highlighted in yellow. The yellow highlight means that this line of code will execute next. The breakpoint makes the app pause execution at this line.

Hover your mouse over the username variable to see its value. You can also right-click on username and select Add Watch to add the variable to the Watch window, where you can also see its value.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Press F5 again to finish running the app.

For more information about debugging in Visual Studio, see the Debugger feature tour.

Customize Visual Studio

You can personalize the Visual Studio user interface, including changing the default color theme. To change the color theme:

On the menu bar, choose Tools > Options to open the Options dialog.

On the Environment > General options page, change the Color theme selection to Dark, and then choose OK.

The color theme for the entire IDE changes to Dark.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

On the menu bar, choose Tools > Options to open the Options dialog.

On the Environment > General options page, change the Color Theme selection to Blue or Light, and then select OK.

The color theme for the entire IDE changes accordingly. The following screenshot shows the Blue theme:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To learn about other ways you can personalize the IDE, see Personalize Visual Studio.

Next steps

Explore Visual Studio further by following along with one of these introductory articles:

Cover the basics in this Learn module: Introduction to Visual Studio.

Get acquainted with the code editor in Learn to use the code editor.

Learn how Visual Studio organizes code in Learn about projects and solutions.

If you’re ready to dive into more coding, one of the following language-specific quickstarts is a good next step:

Another good place to start with coding is a tutorial:

Debugging techniques and tools to help you write better code

Fixing bugs and errors in your code can be a time-consuming—and sometimes frustrating—task. It takes time to learn how to debug effectively, but a powerful IDE like Visual Studio can make your job a lot easier. An IDE can help you fix errors and debug your code more quickly, and not just that, but it can also help you write better code with fewer bugs. Our aim in this article is to give you a holistic view of the «bug-fixing» process, so you will know when to use the code analyzer, when to use the debugger, how to fix exceptions, and how to code for intent. If you already know you need to use the debugger, see First look at the debugger.

In this article, we talk about leveraging the IDE to make your coding sessions more productive. We touch on several tasks, such as:

Prepare your code for debugging by leveraging the IDE’s code analyzer

How to fix exceptions (run-time errors)

How to minimize bugs by coding for intent (using assert)

When to use the debugger

To demonstrate these tasks, we show a few of the most common types of errors and bugs that you’ll encounter when trying to debug your apps. Although the sample code is C#, the conceptual information is generally applicable to C++, Visual Basic, JavaScript, and other languages supported by Visual Studio (except where noted). The screenshots are in C#.

Create a sample app with some bugs and errors in it

The following code has some bugs that you can fix using the Visual Studio IDE. The app here is a simple app that simulates getting JSON data from some operation, deserializing the data to an object, and updating a simple list with the new data.

To create the app:

You must have Visual Studio installed and the .NET Core cross platform development workload installed.

If you haven’t already installed Visual Studio, go to theВ Visual Studio downloadsВ page to install it for free.

If you need to install the workload but already have Visual Studio, click Tools > Get Tools and Features. The Visual Studio Installer launches. Choose the .NET Core cross platform development workload, then choose Modify.

Open Visual Studio.

Visual Studio creates the console project, which appears in Solution Explorer in the right pane.

Replace the default code in the project’s Program.cs file with the sample code below.

Find the red and green squiggles!

Before you try to start the sample app and run the debugger, check the code in the code editor for red and green squiggles. These represent errors and warnings that are identified by the IDE’s code analyzer. The red squiggles are compile-time errors, which you must fix before you can run the code. The green squiggles are warnings. Although you can often run your app without fixing the warnings, they can be a source of bugs and you often save yourself time and trouble by investigating them. These warnings and errors also show up in the Error List window, if you prefer a list view.

In the sample app, you see several red squiggles that you need to fix, and one green one that you’ll look at. Here is the first error.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To fix this error, you’ll look at another feature of the IDE, represented by the light bulb icon.

Check the light bulb!

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

When you click this item, Visual Studio adds the using System.Text statement at the top of the Program.cs file, and the red squiggle disappears. (When you’re not sure what a suggested fix will do, choose the Preview changes link on the right before applying the fix.)

The preceding error is a common one that you usually fix by adding a new using statement to your code. There are several common, similar errors to this one such as The type or namespace `Name` cannot be found. These kinds of errors may indicate a missing assembly reference (right-click the project, choose Add > Reference), a misspelled name, or a missing library that you need to add (for C#, right-click the project and choose Manage NuGet Packages).

Fix the remaining errors and warnings

There are a few more squiggles to look at in this code. Here, you see a common type conversion error. When you hover over the squiggle, you see that the code is trying to convert a string to an int, which is not supported unless you add explicit code to make the conversion.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To fix this error, change the points member of the User class from this:

The red squiggly lines in the code editor go away.

Next, hover over the green squiggle in the declaration of the points data member. The code analyzer tells you the variable is never assigned a value.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Typically, this represents a problem that needs to be fixed. However, in the sample app you are in fact storing data in the points variable during the deserialization process, and then adding that value to the totalpoints data member. In this example, you know the intent of the code and can safely ignore the warning. However, if you want to eliminate the warning, you can replace the following code:

The green squiggle goes away.

Fix an exception

When you have fixed all the red squiggles and resolved—or at least investigated—all the green squiggles, you are ready to start the debugger and run the app.

Press F5 (Debug > Start Debugging) or the Start Debugging button Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoftin the Debug toolbar.

At this point, the sample app throws a SerializationException exception (a runtime error). That is, the app chokes on the data that it is trying to serialize. Because you started the app in debug mode (debugger attached), the debugger’s Exception Helper takes you right to the code that threw the exception and gives you a helpful error message.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

When you hit an exception, you need to ask (and answer) a couple of questions:

Is this exception just a bug that you can fix? Or,

Is this exception something that your users might encounter?

If it’s the former, fix the bug. (In the sample app, that means fix the bad data.) If it’s the latter, you might need to handle the exception in your code using a try/catch block (we look at other possible strategies in the next section). In the sample app, replace the following code:

A try/catch block has some performance cost, so you’ll only want to use them when you really need them, that is, where (a) they might occur in the release version of the app, and where (b) the documentation for the method indicates that you should check for the exception (assuming the documentation is complete!). In many cases, you can handle an exception appropriately and the user will never need to know about it.

Here are a couple of important tips for exception handling:

For unfamiliar functions that you include in your app, especially those interacting with external data (such as a web request), check the documentation to see what exceptions the function is likely to throw. This can be critical information for proper error handling and for debugging your app.

Clarify your code intent by using assert

Click the Restart Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoftbutton in the Debug Toolbar (Ctrl + Shift + F5). This restarts the app in fewer steps. You see the following output in the console window.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

You can see something in this output that is not quite right. name and lastname for the third record are blank!

By adding assert statements like this to your functions during the development process, you can help specify the intent of your code. In the preceding example, we specify the following:

By specifying intent in this way, you enforce your requirements. This is a simple and handy method that you can use to surface bugs during development. ( assert statements are also used as the main element in unit tests.)

Click the Restart Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoftbutton in the Debug Toolbar (Ctrl + Shift + F5).

The assert code is active only in a Debug build.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The assert error tells you that there’s a problem that you need to investigate. assert can cover many scenarios where you don’t necessarily see an exception. In this example, the user won’t see an exception, and a null value gets added as firstname in your list of records. This may cause problems later on (such as you see in the console output) and might be harder to debug.

During the debugging process, it’s good to keep a particular assert statement until you know you need to replace it with an actual code fix. Let’s say you decide that the user might encounter the exception in a release build of the app. In that case, you must refactor code to make sure that your app doesn’t throw a fatal exception or result in some other error. So, to fix this code, replace the following code:

By using this code, you fulfill your code requirements and make sure that a record with a firstname or lastname value of null is not added to the data.

For the preceding statements, your intent is that you load existing data ( db ) and retrieve new data ( users ) before updating anything.

The preceding code is useful if you want to specify the following intent: a new point value greater than zero (0) is required to update the user’s record.

Inspect your code in the debugger

OK, now that you’ve fixed everything critical that’s wrong with the sample app, you can move onto other important stuff!

We showed you the debugger’s Exception Helper, but the debugger is a much more powerful tool that also lets you do other things like step through your code and inspect its variables. These more powerful capabilities are useful in many scenarios, especially the following:

You are trying to isolate a runtime bug in your code, but are unable to do it using methods and tools previously discussed.

You want to validate your code, that is, watch it while it runs to make sure it is behaving in the way you expect and doing what you want it to.

It is instructive to watch your code while it runs. You can learn more about your code this way and can often identify bugs before they manifest any obvious symptoms.

To learn how to use the essential features of the debugger, see Debugging for absolute beginners.

Fix performance issues

Bugs of another kind include inefficient code that causes your app to run slowly or to use too much memory. Generally, optimizing performance is something you do later in your app development. However, you can run into performance issues early (for example, you see that some part of your app is running slow), and you may need to test your app with the profiling tools early on. For more information about profiling tools such as the CPU Usage tool and the Memory Analyzer, see First look at the profiling tools.

Next steps

In this article, you’ve learned how to avoid and fix many common bugs in your code and when to use the debugger. Next, learn more about using the Visual Studio debugger to fix bugs.

Develop code in Visual Studio without projects or solutions

You can open code from nearly any type of directory-based project into Visual Studio without the need for a solution or project file. This means you can, for example, clone a repo on GitHub, open it directly into Visual Studio, and begin developing, without having to create a solution or project. If needed, you can specify custom build tasks and launch parameters through simple JSON files.

After you open your code files in Visual Studio, Solution Explorer displays all the files in the folder. You can click on any file to begin editing it. In the background, Visual Studio starts indexing the files to enable IntelliSense, navigation, and refactoring features. As you edit, create, move, or delete files, Visual Studio tracks the changes automatically and continuously updates its IntelliSense index. Code will appear with syntax colorization and, in many cases, include basic IntelliSense statement completion.

If you’re looking for information that’s specific to VS Code, visit the Getting started with Visual Studio Code page.

Open any code

You can open code into Visual Studio in the following ways:

On the Visual Studio menu bar, choose File > Open > Folder, and then browse to the code location.

On the context (right-click) menu of a folder containing code, choose the Open in Visual Studio command.

Choose the Open Folder link on the start window.

If you are a keyboard user, press Ctrl+Shift+Alt+O in Visual Studio.

Open code from a cloned GitHub repo.

To open code from a cloned GitHub repo

The following example shows how to clone a GitHub repo and then open its code in Visual Studio. To follow this procedure, you must have a GitHub account and Git for Windows installed on your system. See Create a GitHub account to use with Visual Studio and Git for Windows for more information.

Go to the repo you want to clone on GitHub.

Choose the Clone or Download button and then choose the Copy to Clipboard button in the dropdown menu to copy the secure URL for the GitHub repo.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Use Git in Visual Studio

As of Visual Studio 2019 version 16.8, we introduced a new, streamlined Git interface that you can use to interact with your files on GitHub. To learn more, visit the Visual Studio version control docs.

Use Team Explorer in Visual Studio

You can still use Team Explorer in Visual Studio 2022 and in Visual Studio 2019 version 16.8 and later. However, you might find it easier to use the new Git experience. For more information, see How Visual Studio makes version control easy with Git.

In Visual Studio, choose the Team Explorer tab to open Team Explorer. If you don’t see the tab, open it from View > Team Explorer.

In Team Explorer, under the Local Git Repositories section, choose the Clone command and then paste the URL of the GitHub page into the text box.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Choose the Clone button to clone the project’s files to a local Git repository. Depending on the size of the repo, this process could take several minutes.

After the repo has been cloned to your system, in Team Explorer, choose the Open command on the context (right-click) menu of the newly cloned repo.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Choose the Show Folder View command to view the files in Solution Explorer.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

You can now browse folders and files in the cloned repo, and view and search the code in the Visual Studio code editor, complete with syntax colorization and other features.

Run and debug your code

You can debug your code in Visual Studio without a project or solution! To debug some languages, you may need to specify a valid startup file in the codebase, such as a script, executable, or project. The drop-down list box next to the Start button on the toolbar lists all of the startup items that Visual Studio detects, as well as items you specifically designate. Visual Studio runs this code first when you debug your code.

Configuring your code to run in Visual Studio differs depending on what kind of code it is, and what the build tools are.

Codebases that use MSBuild

MSBuild-based codebases can have multiple build configurations that appear in the Start button’s drop-down list. Select the file that you want to use as the startup item, and then choose the Start button to begin debugging.

For C# and Visual Basic codebases, you must have the .NET desktop development workload installed. For C++ codebases, you must have the Desktop development with C++ workload installed.

Codebases that use custom build tools

If your codebase uses custom build tools, then you must tell Visual Studio how to build your code using build tasks that are defined in a .json file. For more information, see Customize build and debug tasks.

Codebases that contain Python or JavaScript code

If your codebase contains Python or JavaScript code, you don’t have to configure any .json files, but you do have to install the corresponding workload. You must also configure the startup script:

Install the Node.js development or Python development workload by choosing Tools > Get Tools and Features, or by closing Visual Studio and running the Visual Studio Installer.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In Solution Explorer, on the right-click or context menu of a JavaScript or Python file, choose the Set as Startup Item command.

Choose the Start button to begin debugging.

Codebases that contain C++ code

For information about opening C++ code without solutions or projects in Visual Studio, see Open Folder projects for C++.

Codebases that contain a Visual Studio project

If your code folder contains a Visual Studio project, you can designate the project as the startup item.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The Start button’s text changes to reflect that the project is the startup item.

Welcome to the Visual Studio IDE

An integrated development environment (IDE) is a feature-rich program that supports many aspects of software development. The Visual Studio IDE is a creative launching pad that you can use to edit, debug, and build code, and then publish an app. Over and above the standard editor and debugger that most IDEs provide, Visual Studio includes compilers, code completion tools, graphical designers, and many more features to enhance the software development process.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The preceding image shows Visual Studio with an open project that shows key windows and their functionality:

In Solution Explorer, at upper right, you can view, navigate, and manage your code files. Solution Explorer can help organize your code by grouping the files into solutions and projects.

The central editor window, where you’ll probably spend most of your time, displays file contents. In the editor window, you can edit code or design a user interface such as a window with buttons and text boxes.

In Git Changes at lower right, you can track work items and share code with others by using version control technologies like Git and GitHub.

Editions

Visual Studio is available for Windows and Mac. Visual Studio for Mac has many of the same features as Visual Studio for Windows, and is optimized for developing cross-platform and mobile apps. This article focuses on the Windows version of Visual Studio.

There are three editions of Visual Studio: Community, Professional, and Enterprise. See Compare Visual Studio editions to learn about which features are supported in each edition.

Popular productivity features

Some popular features in Visual Studio that improve your productivity when developing software include:

Squiggles are wavy underlines that alert you to errors or potential problems in your code as you type. These visual clues help you fix problems immediately, without waiting to discover errors during build or runtime. If you hover over a squiggle, you see more information about the error. A lightbulb might also appear in the left margin showing Quick Actions you can take to fix the error.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Refactoring includes operations such as intelligent renaming of variables, extracting one or more lines of code into a new method, and changing the order of method parameters.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

IntelliSense is a set of features that display information about your code directly in the editor and, in some cases, write small bits of code for you. It’s like having basic documentation inline in the editor, so you don’t have to look up type information elsewhere.

The following illustration shows how IntelliSense displays a member list for a type:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual Studio menus, options, and properties can seem overwhelming at times. Visual Studio search, or Ctrl+Q, is a great way to rapidly find IDE features and code in one place.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

For information and productivity tips, see How to use Visual Studio search.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

For information and productivity tips, see How to use Visual Studio search.

Collaboratively edit and debug with others in real time, regardless of your app type or programming language. You can instantly and securely share your project. You can also share debugging sessions, terminal instances, localhost web apps, voice calls, and more.

The Call Hierarchy window shows the methods that call a selected method. This information can be useful when you’re thinking about changing or removing the method, or when you’re trying to track down a bug.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

CodeLens helps you find code references, code changes, linked bugs, work items, code reviews, and unit tests, without leaving the editor.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The Go To Definition feature takes you directly to the location of a function or type definition.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The Peek Definition window shows a method or type definition without opening a separate file.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Install Visual Studio

In this section, you create a simple project to try out some of the things you can do with Visual Studio. You use IntelliSense as a coding aid, debug an app to see a variable value during app execution, and change the color theme.

To get started, download Visual Studio and install it on your system. The modular installer enables you to choose and install workloads, which are groups of features needed for the programming languages or platforms you want. To follow the steps to create a program, be sure to select the .NET Core cross-platform development workload during installation.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To get started, download Visual Studio and install it on your system. In the modular installer, you choose and install workloads, which are groups of features you need for the programming languages or platforms you want. To use the following steps to create a program, be sure to select the .NET desktop development workload during installation.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

When you open Visual Studio for the first time, you can sign in by using your Microsoft account or your work or school account.

Create a program

Dive in and create a simple program.

Open Visual Studio.

The start window appears with options for cloning a repo, opening a recent project, or creating a new project.

Choose Create a new project.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The Create a new project window opens and shows several project templates. A template contains the basic files and settings required for a given project type.

To find the template we want, type or enter .net core console in the search box. The list of available templates is automatically filtered based on the keywords you entered. You can further filter the template results by choosing C# from the All language drop-down list, Windows from the All platforms list, and Console from the All project types list.

Select the Console Application template, and then click Next.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In the Configure your new project window, enter HelloWorld in the Project name box, optionally change the directory location for your project files (the default locale is C:\Users\ \source\repos ), and then click Next.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In the Additional information window, verify that .NET Core 3.1 appears in the Target Framework drop-down menu, and then click Create.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual Studio creates the project. It’s a simple «Hello World» application that calls the Console.WriteLine() method to display the literal string «Hello World!» in the console (program output) window.

Shortly, you should see something like the following screen:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The C# code for your application shows in the editor window, which takes up most of the space. Notice that the text is automatically colorized to indicate different parts of the code, such as keywords and types. In addition, small, vertical dashed lines in the code indicate which braces match one another, and line numbers help you locate code later. You can choose the small, boxed minus signs to collapse or expand blocks of code. This code outlining feature lets you hide code you don’t need, helping to minimize onscreen clutter. The project files are listed on the right side in a window called Solution Explorer.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

There are other menus and tool windows available, but let’s move on for now.

Now, start the app. You can do this by choosing Start Without Debugging from the Debug menu on the menu bar. You can also press Ctrl+F5.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoftStart without Debugging menu item.» data-linktype=»relative-path»>

Visual Studio builds the app, and a console window opens with the message Hello World!. You now have a running app!

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To close the console window, press any key on your keyboard.

Let’s add some more code to the app. Add the following C# code before the line that says Console.WriteLine(«Hello World!»); :

This code displays What is your name? in the console window, and then waits until the user enters some text followed by the Enter key.

Change the line that says Console.WriteLine(«Hello World!»); to the following code:

Run the app again by selecting Debug > Start Without Debugging or by pressing Ctrl+F5.

Visual Studio rebuilds the app, and a console window opens and prompts you for your name.

Enter your name in the console window and press Enter.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Press any key to close the console window and stop the running program.

Start Visual Studio. The start window appears with options for cloning a repo, opening a recent project, or creating a new project.

Choose Create a new project.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The Create a new project window opens and shows several project templates. A template contains the basic files and settings required for a given project type.

To find a template, you can type or enter keywords in the search box. The list of available templates filters based on the keywords you enter. You can further filter the template results by choosing C# from the All languages dropdown list, Windows from the All platforms list, and Console from the All project types list.

Select the Console Application template, and then select Next.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In the Configure your new project window, enter HelloWorld in the Project name box. Optionally, change the project directory location from the default location of C:\Users\ \source\repos, and then select Next.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In the Additional information window, verify that .NET 6.0 appears in the Target Framework drop-down menu, and then select Create.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual Studio creates the project. The program is a simple «Hello World» application that calls the Console.WriteLine() method to display the string Hello, World! in a console window.

The project files appear on the right side of the Visual Studio IDE, in a window called the Solution Explorer. In the Solution Explorer window, select the Program.cs file. The C# code for your app opens in the central editor window, which takes up most of the space.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The code is automatically colorized to indicate different parts, such as keywords and types. Line numbers help you locate code.

Small, vertical dashed lines in the code indicate which braces match one another. You can also choose small, boxed minus or plus signs to collapse or expand blocks of code. This code outlining feature lets you hide code you don’t need to see, helping to minimize onscreen clutter.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Many other menus and tool windows are available.

Start the app by choosing Debug > Start Without Debugging from the Visual Studio top menu. You can also press Ctrl+F5.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoftStart without Debugging menu item.» data-linktype=»relative-path»>

Visual Studio builds the app, and a console window opens with the message Hello, World!. You now have a running app!

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To close the console window, press any key.

Let’s add some more code to the app. Add the following C# code before the line that says Console.WriteLine(«Hello World!»); :

This code displays What is your name? in the console window, and then waits until the user enters some text.

Change the line that says Console.WriteLine(«Hello World!»); to the following line:

Run the app again by selecting Debug > Start Without Debugging or pressing Ctrl+F5.

Visual Studio rebuilds the app, and a console window opens and prompts you for your name.

Type your name in the console window and press Enter.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Press any key to close the console window and stop the running program.

Use refactoring and IntelliSense

Let’s look at a couple of the ways that refactoring and IntelliSense can help you code more efficiently.

First, rename the name variable:

Double-click the name variable, and type the new name for the variable, username.

A box appears around the variable, and a light bulb appears in the margin.

Select the light bulb icon to show the available Quick Actions. Select Rename ‘name’ to ‘username’.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The variable is renamed across the project, which in our case is only two places.

A box displays the members of the DateTime class. The description of the currently selected member also displays in a separate box.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Below that line, enter the following lines of code:

Console.Write is different from Console.WriteLine in that it doesn’t add a line terminator after it prints. That means that the next piece of text that’s sent to the output will print on the same line. You can hover over each of these methods in your code to see their descriptions.

Select the screwdriver icon to see available suggestions from Visual Studio. This case shows the Inline temporary variable refactoring to remove a line of code without changing the overall code behavior.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Select Inline temporary variable to refactor the code.

Run the program again by pressing Ctrl+F5. The output looks something like this:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Debug code

When you write code, you should run it and test it for bugs. Visual Studio’s debugging system lets you step through code one statement at a time and inspect variables as you go. You can set breakpoints that stop execution of the code at a particular line, and observe how the variable value changes as the code runs.

Set a breakpoint to see the value of the username variable while the program is running.

Set a breakpoint on the line of code that says Console.WriteLine($»\nHello !»); by clicking in the far-left margin, or gutter, next to the line. You can also select the line of code and then press F9.

A red circle appears in the gutter, and the line is highlighted.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Start debugging by selecting Debug > Start Debugging or pressing F5.

When the console window appears and asks for your name, enter your name.

The focus returns to the Visual Studio code editor, and the line of code with the breakpoint is highlighted in yellow. The yellow highlight means that this line of code will execute next. The breakpoint makes the app pause execution at this line.

Hover your mouse over the username variable to see its value. You can also right-click on username and select Add Watch to add the variable to the Watch window, where you can also see its value.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Press F5 again to finish running the app.

For more information about debugging in Visual Studio, see the Debugger feature tour.

Customize Visual Studio

You can personalize the Visual Studio user interface, including changing the default color theme. To change the color theme:

On the menu bar, choose Tools > Options to open the Options dialog.

On the Environment > General options page, change the Color theme selection to Dark, and then choose OK.

The color theme for the entire IDE changes to Dark.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

On the menu bar, choose Tools > Options to open the Options dialog.

On the Environment > General options page, change the Color Theme selection to Blue or Light, and then select OK.

The color theme for the entire IDE changes accordingly. The following screenshot shows the Blue theme:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To learn about other ways you can personalize the IDE, see Personalize Visual Studio.

Next steps

Explore Visual Studio further by following along with one of these introductory articles:

Cover the basics in this Learn module: Introduction to Visual Studio.

Get acquainted with the code editor in Learn to use the code editor.

Learn how Visual Studio organizes code in Learn about projects and solutions.

If you’re ready to dive into more coding, one of the following language-specific quickstarts is a good next step:

Another good place to start with coding is a tutorial:

Visual Studio productivity guide for C# developers

Use keyboard shortcuts from a different editor

If you’re coming from another IDE or coding environment, you can change your keyboard scheme to Visual Studio Code or ReSharper (Visual Studio):

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Some extensions also offer keyboard schemes:

The following are popular Visual Studio shortcuts:

Shortcut (All Profiles)CommandDescription
Ctrl+TGo To AllNavigate to any file, type, member, or symbol declaration
F12 (also Ctrl+Click)Go To DefinitionNavigate to where a symbol is defined
Ctrl+F12Go To ImplementationNavigate from a base type or member to its various implementations
Shift+F12Find All ReferencesSee all symbol or literal references
Alt+HomeGo To BaseNavigate up the inheritance chain
Ctrl+. (also Alt+Enter in C# Profile)Quick Actions and RefactoringsSee what code fixes, code generation actions, refactorings, or other quick actions are available at your cursor position or code selection
Ctrl+DDuplicate lineDuplicates the line of code that the cursor is in
Shift+Alt++/Expand/Contract selectionExpands or contracts the current selection in the editor
Shift + Alt + .Insert Next Matching CaretAdds a selection and caret at the next location that matches the current selection
Ctrl+QSearchSearch all Visual Studio settings
F5Start DebuggingStart debugging your application
Ctrl+F5Run without DebugRun your application locally without debugging
Ctrl+K,D (Default Profile) or Ctrl+E,D (C# Profile)Format DocumentCleans up formatting violations in your file based on your newline, spacing, and indentation settings
Ctrl+\,Ctrl+E (Default Profile) or Ctrl+W,E (C# Profile)View Error ListSee all errors in your document, project, or solution
Alt + PgUp/PgDnGo to Next/Previous IssueJump to the previous/next error, warning, suggestion in your document
Ctrl+K,/Toggle single line comment/uncommentThis command adds or removes a single line comment depending on whether your selection is already commented
Ctrl+Shift+/Toggle block comment/uncommentThis command adds or removes block comments depending on what you have selected

Some extensions unbind the default Visual Studio keybindings. You can restore your keybindings to their defaults by going to Tools > Import and Export Settings > Reset all settings or Tools > Options > Keyboard > Reset.

For more information about keyboard shortcuts and commands, see Productivity shortcuts. Or, see Keyboard shortcuts in Visual Studio for a comprehensive list along with a downloadable cheat sheet.

Navigate quickly to files or types

Visual Studio has a feature called Go To All that you can use to quickly jump to any file, type, member, or symbol declaration. To open it from the menu bar, select Edit > Go To > Go To All. Or, you can open it by using the Ctrl+T keyboard shortcut.

A small window is displayed at the top right of your code editor.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

You can use this feature to perform the following actions:

For more information about Go To All, see Find code by using Go To commands.

Enforce code style rules

You can use an EditorConfig file to codify coding conventions and have them travel with your source.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The code inference feature of IntelliCode for Visual Studio infers your code styles from existing code. It then creates a non-empty EditorConfig file with your code-style preferences already defined.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Code Cleanup

Visual Studio provides on-demand formatting of your code file, including code style preferences, through the Code Cleanup feature. To run Code Cleanup, click the broom icon at the bottom of the editor or press Ctrl+K, Ctrl+E.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

You can also run code cleanup across your entire project or solution. Right-click on the project or solution name in Solution Explorer, select Analyze and Code Cleanup, and then select Run Code Cleanup.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In addition to formatting your file for spaces, indents, et cetera, Code Cleanup also applies selected code styles. Your preferences for each code style are read from the EditorConfig file, if you have one for the project, or from the code style settings in the Options dialog box.

Refactorings and code fixes

Visual Studio comes with numerous refactorings, code generation actions, and code fixes. Red squiggles represent errors, green squiggles represent warnings, and three gray dots represent code suggestions. You can access code fixes by clicking the light bulb or screwdriver icon, or by pressing Ctrl+. or Alt+Enter. Each fix comes with a preview window that shows a live code diff of how the fix works.

Popular quick fixes and refactorings include:

Several community members have written free extensions that add additional code inspections:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Find Usages, Go To Implementation, and Navigate To Decompiled Assemblies

Visual Studio has many features to help you search and navigate your code.

FeatureShortcutDetails/Improvements
Find All ReferencesShift+F12Results are colorized and can be grouped by project, definition, and reference type, such as read or write. You can also «lock» results.
Go To ImplementationCtrl+F12You can use Go To Definition on the override keyword to navigate to the overridden member
Go To DefinitionF12 or Ctrl+ClickPress Ctrl while clicking to navigate to definition
Peek DefinitionAlt+F12Inline view of a definition
Structure VisualizerGray, dotted-lines between bracesHover to see your code structure
Navigation to decompiled assembliesF12 or Ctrl+ClickNavigate to external source (decompiled with ILSpy) by enabling the feature: Tools > Options > Text Editor > C# > Advanced > Enable navigation to decompiled sources.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Improved IntelliSense

Use IntelliCode for Visual Studio to get context-aware code completions instead of just an alphabetical list. You can also train a custom IntelliSense model based on your own domain-specific libraries.

Unit testing

We’ve made numerous improvements to the testing experience. You can test with the MSTest (MSTest v1 or MSTest v2), NUnit, and XUnit test frameworks.

Test Explorer test discovery is fast.

Organize your tests in Test Explorer with hierarchical sorting.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

For more information, see Unit test basics.

Debugging

Some of Visual Studio’s debugging capabilities include the following:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Version control

In Visual Studio 2022, you can use Git directly from the IDE to create, review, check out, and run pull requests. To learn more, see How Visual Studio makes version control easy with Git.

You can use Git or TFVC to store and update your code in Visual Studio.

In Visual Studio 2019 version 16.8 and later, you can use Git from directly within the IDE to create, review, check out, and run pull requests.

In Visual Studio 2019 version 16.7 and earlier, install the Pull requests for Visual Studio extension to create, review, check out, and run pull requests without leaving Visual Studio.

Organize your local changes in Team Explorer and use the status bar to track pending commits and changes.

Set up continuous integration and delivery for your ASP.NET projects inside of Visual Studio with the Continuous delivery tools for Visual Studio extension.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

What other features should I know about?

Here’s a list of editor and productivity features to make writing code more efficient. Some features might need to be enabled because they’re off by default.

Develop code in Visual Studio without projects or solutions

You can open code from nearly any type of directory-based project into Visual Studio without the need for a solution or project file. This means you can, for example, clone a repo on GitHub, open it directly into Visual Studio, and begin developing, without having to create a solution or project. If needed, you can specify custom build tasks and launch parameters through simple JSON files.

After you open your code files in Visual Studio, Solution Explorer displays all the files in the folder. You can click on any file to begin editing it. In the background, Visual Studio starts indexing the files to enable IntelliSense, navigation, and refactoring features. As you edit, create, move, or delete files, Visual Studio tracks the changes automatically and continuously updates its IntelliSense index. Code will appear with syntax colorization and, in many cases, include basic IntelliSense statement completion.

If you’re looking for information that’s specific to VS Code, visit the Getting started with Visual Studio Code page.

Open any code

You can open code into Visual Studio in the following ways:

On the Visual Studio menu bar, choose File > Open > Folder, and then browse to the code location.

On the context (right-click) menu of a folder containing code, choose the Open in Visual Studio command.

Choose the Open Folder link on the start window.

If you are a keyboard user, press Ctrl+Shift+Alt+O in Visual Studio.

Open code from a cloned GitHub repo.

To open code from a cloned GitHub repo

The following example shows how to clone a GitHub repo and then open its code in Visual Studio. To follow this procedure, you must have a GitHub account and Git for Windows installed on your system. See Create a GitHub account to use with Visual Studio and Git for Windows for more information.

Go to the repo you want to clone on GitHub.

Choose the Clone or Download button and then choose the Copy to Clipboard button in the dropdown menu to copy the secure URL for the GitHub repo.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Use Git in Visual Studio

As of Visual Studio 2019 version 16.8, we introduced a new, streamlined Git interface that you can use to interact with your files on GitHub. To learn more, visit the Visual Studio version control docs.

Use Team Explorer in Visual Studio

You can still use Team Explorer in Visual Studio 2022 and in Visual Studio 2019 version 16.8 and later. However, you might find it easier to use the new Git experience. For more information, see How Visual Studio makes version control easy with Git.

In Visual Studio, choose the Team Explorer tab to open Team Explorer. If you don’t see the tab, open it from View > Team Explorer.

In Team Explorer, under the Local Git Repositories section, choose the Clone command and then paste the URL of the GitHub page into the text box.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Choose the Clone button to clone the project’s files to a local Git repository. Depending on the size of the repo, this process could take several minutes.

After the repo has been cloned to your system, in Team Explorer, choose the Open command on the context (right-click) menu of the newly cloned repo.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Choose the Show Folder View command to view the files in Solution Explorer.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

You can now browse folders and files in the cloned repo, and view and search the code in the Visual Studio code editor, complete with syntax colorization and other features.

Run and debug your code

You can debug your code in Visual Studio without a project or solution! To debug some languages, you may need to specify a valid startup file in the codebase, such as a script, executable, or project. The drop-down list box next to the Start button on the toolbar lists all of the startup items that Visual Studio detects, as well as items you specifically designate. Visual Studio runs this code first when you debug your code.

Configuring your code to run in Visual Studio differs depending on what kind of code it is, and what the build tools are.

Codebases that use MSBuild

MSBuild-based codebases can have multiple build configurations that appear in the Start button’s drop-down list. Select the file that you want to use as the startup item, and then choose the Start button to begin debugging.

For C# and Visual Basic codebases, you must have the .NET desktop development workload installed. For C++ codebases, you must have the Desktop development with C++ workload installed.

Codebases that use custom build tools

If your codebase uses custom build tools, then you must tell Visual Studio how to build your code using build tasks that are defined in a .json file. For more information, see Customize build and debug tasks.

Codebases that contain Python or JavaScript code

If your codebase contains Python or JavaScript code, you don’t have to configure any .json files, but you do have to install the corresponding workload. You must also configure the startup script:

Install the Node.js development or Python development workload by choosing Tools > Get Tools and Features, or by closing Visual Studio and running the Visual Studio Installer.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In Solution Explorer, on the right-click or context menu of a JavaScript or Python file, choose the Set as Startup Item command.

Choose the Start button to begin debugging.

Codebases that contain C++ code

For information about opening C++ code without solutions or projects in Visual Studio, see Open Folder projects for C++.

Codebases that contain a Visual Studio project

If your code folder contains a Visual Studio project, you can designate the project as the startup item.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The Start button’s text changes to reflect that the project is the startup item.

Welcome to the Visual Studio IDE | C#

An integrated development environment (IDE) is a feature-rich program that supports many aspects of software development. The Visual Studio IDE is a creative launching pad that you can use to edit, debug, and build code, and then publish an app. Over and above the standard editor and debugger that most IDEs provide, Visual Studio includes compilers, code completion tools, graphical designers, and many more features to enhance the software development process.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The preceding image shows Visual Studio with an open project that shows key windows and their functionality:

In Solution Explorer, at upper right, you can view, navigate, and manage your code files. Solution Explorer can help organize your code by grouping the files into solutions and projects.

The central editor window, where you’ll probably spend most of your time, displays file contents. In the editor window, you can edit code or design a user interface such as a window with buttons and text boxes.

In Git Changes at lower right, you can track work items and share code with others by using version control technologies like Git and GitHub.

Editions

Visual Studio is available for Windows and Mac. Visual Studio for Mac has many of the same features as Visual Studio for Windows, and is optimized for developing cross-platform and mobile apps. This article focuses on the Windows version of Visual Studio.

There are three editions of Visual Studio: Community, Professional, and Enterprise. See Compare Visual Studio editions to learn about which features are supported in each edition.

Popular productivity features

Some popular features in Visual Studio that improve your productivity when developing software include:

Squiggles are wavy underlines that alert you to errors or potential problems in your code as you type. These visual clues help you fix problems immediately, without waiting to discover errors during build or runtime. If you hover over a squiggle, you see more information about the error. A lightbulb might also appear in the left margin showing Quick Actions you can take to fix the error.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Refactoring includes operations such as intelligent renaming of variables, extracting one or more lines of code into a new method, and changing the order of method parameters.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

IntelliSense is a set of features that display information about your code directly in the editor and, in some cases, write small bits of code for you. It’s like having basic documentation inline in the editor, so you don’t have to look up type information elsewhere.

The following illustration shows how IntelliSense displays a member list for a type:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual Studio menus, options, and properties can seem overwhelming at times. Visual Studio search, or Ctrl+Q, is a great way to rapidly find IDE features and code in one place.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

For information and productivity tips, see How to use Visual Studio search.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

For information and productivity tips, see How to use Visual Studio search.

Collaboratively edit and debug with others in real time, regardless of your app type or programming language. You can instantly and securely share your project. You can also share debugging sessions, terminal instances, localhost web apps, voice calls, and more.

The Call Hierarchy window shows the methods that call a selected method. This information can be useful when you’re thinking about changing or removing the method, or when you’re trying to track down a bug.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

CodeLens helps you find code references, code changes, linked bugs, work items, code reviews, and unit tests, without leaving the editor.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The Go To Definition feature takes you directly to the location of a function or type definition.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The Peek Definition window shows a method or type definition without opening a separate file.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Install Visual Studio

In this section, you create a simple project to try out some of the things you can do with Visual Studio. You use IntelliSense as a coding aid, debug an app to see a variable value during app execution, and change the color theme.

To get started, download Visual Studio and install it on your system. The modular installer enables you to choose and install workloads, which are groups of features needed for the programming languages or platforms you want. To follow the steps to create a program, be sure to select the .NET Core cross-platform development workload during installation.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To get started, download Visual Studio and install it on your system. In the modular installer, you choose and install workloads, which are groups of features you need for the programming languages or platforms you want. To use the following steps to create a program, be sure to select the .NET desktop development workload during installation.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

When you open Visual Studio for the first time, you can sign in by using your Microsoft account or your work or school account.

Create a program

Dive in and create a simple program.

Open Visual Studio.

The start window appears with options for cloning a repo, opening a recent project, or creating a new project.

Choose Create a new project.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The Create a new project window opens and shows several project templates. A template contains the basic files and settings required for a given project type.

To find the template we want, type or enter .net core console in the search box. The list of available templates is automatically filtered based on the keywords you entered. You can further filter the template results by choosing C# from the All language drop-down list, Windows from the All platforms list, and Console from the All project types list.

Select the Console Application template, and then click Next.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In the Configure your new project window, enter HelloWorld in the Project name box, optionally change the directory location for your project files (the default locale is C:\Users\ \source\repos ), and then click Next.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In the Additional information window, verify that .NET Core 3.1 appears in the Target Framework drop-down menu, and then click Create.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual Studio creates the project. It’s a simple «Hello World» application that calls the Console.WriteLine() method to display the literal string «Hello World!» in the console (program output) window.

Shortly, you should see something like the following screen:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The C# code for your application shows in the editor window, which takes up most of the space. Notice that the text is automatically colorized to indicate different parts of the code, such as keywords and types. In addition, small, vertical dashed lines in the code indicate which braces match one another, and line numbers help you locate code later. You can choose the small, boxed minus signs to collapse or expand blocks of code. This code outlining feature lets you hide code you don’t need, helping to minimize onscreen clutter. The project files are listed on the right side in a window called Solution Explorer.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

There are other menus and tool windows available, but let’s move on for now.

Now, start the app. You can do this by choosing Start Without Debugging from the Debug menu on the menu bar. You can also press Ctrl+F5.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoftStart without Debugging menu item.» data-linktype=»relative-path»>

Visual Studio builds the app, and a console window opens with the message Hello World!. You now have a running app!

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To close the console window, press any key on your keyboard.

Let’s add some more code to the app. Add the following C# code before the line that says Console.WriteLine(«Hello World!»); :

This code displays What is your name? in the console window, and then waits until the user enters some text followed by the Enter key.

Change the line that says Console.WriteLine(«Hello World!»); to the following code:

Run the app again by selecting Debug > Start Without Debugging or by pressing Ctrl+F5.

Visual Studio rebuilds the app, and a console window opens and prompts you for your name.

Enter your name in the console window and press Enter.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Press any key to close the console window and stop the running program.

Start Visual Studio. The start window appears with options for cloning a repo, opening a recent project, or creating a new project.

Choose Create a new project.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The Create a new project window opens and shows several project templates. A template contains the basic files and settings required for a given project type.

To find a template, you can type or enter keywords in the search box. The list of available templates filters based on the keywords you enter. You can further filter the template results by choosing C# from the All languages dropdown list, Windows from the All platforms list, and Console from the All project types list.

Select the Console Application template, and then select Next.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In the Configure your new project window, enter HelloWorld in the Project name box. Optionally, change the project directory location from the default location of C:\Users\ \source\repos, and then select Next.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In the Additional information window, verify that .NET 6.0 appears in the Target Framework drop-down menu, and then select Create.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual Studio creates the project. The program is a simple «Hello World» application that calls the Console.WriteLine() method to display the string Hello, World! in a console window.

The project files appear on the right side of the Visual Studio IDE, in a window called the Solution Explorer. In the Solution Explorer window, select the Program.cs file. The C# code for your app opens in the central editor window, which takes up most of the space.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The code is automatically colorized to indicate different parts, such as keywords and types. Line numbers help you locate code.

Small, vertical dashed lines in the code indicate which braces match one another. You can also choose small, boxed minus or plus signs to collapse or expand blocks of code. This code outlining feature lets you hide code you don’t need to see, helping to minimize onscreen clutter.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Many other menus and tool windows are available.

Start the app by choosing Debug > Start Without Debugging from the Visual Studio top menu. You can also press Ctrl+F5.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoftStart without Debugging menu item.» data-linktype=»relative-path»>

Visual Studio builds the app, and a console window opens with the message Hello, World!. You now have a running app!

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To close the console window, press any key.

Let’s add some more code to the app. Add the following C# code before the line that says Console.WriteLine(«Hello World!»); :

This code displays What is your name? in the console window, and then waits until the user enters some text.

Change the line that says Console.WriteLine(«Hello World!»); to the following line:

Run the app again by selecting Debug > Start Without Debugging or pressing Ctrl+F5.

Visual Studio rebuilds the app, and a console window opens and prompts you for your name.

Type your name in the console window and press Enter.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Press any key to close the console window and stop the running program.

Use refactoring and IntelliSense

Let’s look at a couple of the ways that refactoring and IntelliSense can help you code more efficiently.

First, rename the name variable:

Double-click the name variable, and type the new name for the variable, username.

A box appears around the variable, and a light bulb appears in the margin.

Select the light bulb icon to show the available Quick Actions. Select Rename ‘name’ to ‘username’.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The variable is renamed across the project, which in our case is only two places.

A box displays the members of the DateTime class. The description of the currently selected member also displays in a separate box.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Below that line, enter the following lines of code:

Console.Write is different from Console.WriteLine in that it doesn’t add a line terminator after it prints. That means that the next piece of text that’s sent to the output will print on the same line. You can hover over each of these methods in your code to see their descriptions.

Select the screwdriver icon to see available suggestions from Visual Studio. This case shows the Inline temporary variable refactoring to remove a line of code without changing the overall code behavior.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Select Inline temporary variable to refactor the code.

Run the program again by pressing Ctrl+F5. The output looks something like this:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Debug code

When you write code, you should run it and test it for bugs. Visual Studio’s debugging system lets you step through code one statement at a time and inspect variables as you go. You can set breakpoints that stop execution of the code at a particular line, and observe how the variable value changes as the code runs.

Set a breakpoint to see the value of the username variable while the program is running.

Set a breakpoint on the line of code that says Console.WriteLine($»\nHello !»); by clicking in the far-left margin, or gutter, next to the line. You can also select the line of code and then press F9.

A red circle appears in the gutter, and the line is highlighted.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Start debugging by selecting Debug > Start Debugging or pressing F5.

When the console window appears and asks for your name, enter your name.

The focus returns to the Visual Studio code editor, and the line of code with the breakpoint is highlighted in yellow. The yellow highlight means that this line of code will execute next. The breakpoint makes the app pause execution at this line.

Hover your mouse over the username variable to see its value. You can also right-click on username and select Add Watch to add the variable to the Watch window, where you can also see its value.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Press F5 again to finish running the app.

For more information about debugging in Visual Studio, see the Debugger feature tour.

Customize Visual Studio

You can personalize the Visual Studio user interface, including changing the default color theme. To change the color theme:

On the menu bar, choose Tools > Options to open the Options dialog.

On the Environment > General options page, change the Color theme selection to Dark, and then choose OK.

The color theme for the entire IDE changes to Dark.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

On the menu bar, choose Tools > Options to open the Options dialog.

On the Environment > General options page, change the Color Theme selection to Blue or Light, and then select OK.

The color theme for the entire IDE changes accordingly. The following screenshot shows the Blue theme:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To learn about other ways you can personalize the IDE, see Personalize Visual Studio.

Select environment settings

You can configure Visual Studio to use environment settings tailored to C# developers:

On the menu bar, choose Tools > Import and Export Settings.

In the Import and Export Settings Wizard, select Reset all settings, and then select Next.

On the Save Current Settings page, choose whether to save your current settings before resetting. If you haven’t customized any settings, select No, just reset settings, overwriting my current settings. Then select Next.

On the Choose a Default Collection of Settings page, choose Visual C#, and then select Finish.

On the Reset Complete page, select Close.

To learn about other ways you can personalize the IDE, see Personalize Visual Studio.

Next steps

Explore Visual Studio further by following along with one of these introductory articles:

Welcome to the Visual Studio IDE

An integrated development environment (IDE) is a feature-rich program that supports many aspects of software development. The Visual Studio IDE is a creative launching pad that you can use to edit, debug, and build code, and then publish an app. Over and above the standard editor and debugger that most IDEs provide, Visual Studio includes compilers, code completion tools, graphical designers, and many more features to enhance the software development process.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The preceding image shows Visual Studio with an open project that shows key windows and their functionality:

In Solution Explorer, at upper right, you can view, navigate, and manage your code files. Solution Explorer can help organize your code by grouping the files into solutions and projects.

The central editor window, where you’ll probably spend most of your time, displays file contents. In the editor window, you can edit code or design a user interface such as a window with buttons and text boxes.

In Git Changes at lower right, you can track work items and share code with others by using version control technologies like Git and GitHub.

Editions

Visual Studio is available for Windows and Mac. Visual Studio for Mac has many of the same features as Visual Studio for Windows, and is optimized for developing cross-platform and mobile apps. This article focuses on the Windows version of Visual Studio.

There are three editions of Visual Studio: Community, Professional, and Enterprise. See Compare Visual Studio editions to learn about which features are supported in each edition.

Popular productivity features

Some popular features in Visual Studio that improve your productivity when developing software include:

Squiggles are wavy underlines that alert you to errors or potential problems in your code as you type. These visual clues help you fix problems immediately, without waiting to discover errors during build or runtime. If you hover over a squiggle, you see more information about the error. A lightbulb might also appear in the left margin showing Quick Actions you can take to fix the error.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Refactoring includes operations such as intelligent renaming of variables, extracting one or more lines of code into a new method, and changing the order of method parameters.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

IntelliSense is a set of features that display information about your code directly in the editor and, in some cases, write small bits of code for you. It’s like having basic documentation inline in the editor, so you don’t have to look up type information elsewhere.

The following illustration shows how IntelliSense displays a member list for a type:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual Studio menus, options, and properties can seem overwhelming at times. Visual Studio search, or Ctrl+Q, is a great way to rapidly find IDE features and code in one place.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

For information and productivity tips, see How to use Visual Studio search.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

For information and productivity tips, see How to use Visual Studio search.

Collaboratively edit and debug with others in real time, regardless of your app type or programming language. You can instantly and securely share your project. You can also share debugging sessions, terminal instances, localhost web apps, voice calls, and more.

The Call Hierarchy window shows the methods that call a selected method. This information can be useful when you’re thinking about changing or removing the method, or when you’re trying to track down a bug.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

CodeLens helps you find code references, code changes, linked bugs, work items, code reviews, and unit tests, without leaving the editor.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The Go To Definition feature takes you directly to the location of a function or type definition.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The Peek Definition window shows a method or type definition without opening a separate file.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Install Visual Studio

In this section, you create a simple project to try out some of the things you can do with Visual Studio. You use IntelliSense as a coding aid, debug an app to see a variable value during app execution, and change the color theme.

To get started, download Visual Studio and install it on your system. The modular installer enables you to choose and install workloads, which are groups of features needed for the programming languages or platforms you want. To follow the steps to create a program, be sure to select the .NET Core cross-platform development workload during installation.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To get started, download Visual Studio and install it on your system. In the modular installer, you choose and install workloads, which are groups of features you need for the programming languages or platforms you want. To use the following steps to create a program, be sure to select the .NET desktop development workload during installation.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

When you open Visual Studio for the first time, you can sign in by using your Microsoft account or your work or school account.

Create a program

Dive in and create a simple program.

Open Visual Studio.

The start window appears with options for cloning a repo, opening a recent project, or creating a new project.

Choose Create a new project.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The Create a new project window opens and shows several project templates. A template contains the basic files and settings required for a given project type.

To find the template we want, type or enter .net core console in the search box. The list of available templates is automatically filtered based on the keywords you entered. You can further filter the template results by choosing C# from the All language drop-down list, Windows from the All platforms list, and Console from the All project types list.

Select the Console Application template, and then click Next.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In the Configure your new project window, enter HelloWorld in the Project name box, optionally change the directory location for your project files (the default locale is C:\Users\ \source\repos ), and then click Next.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In the Additional information window, verify that .NET Core 3.1 appears in the Target Framework drop-down menu, and then click Create.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual Studio creates the project. It’s a simple «Hello World» application that calls the Console.WriteLine() method to display the literal string «Hello World!» in the console (program output) window.

Shortly, you should see something like the following screen:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The C# code for your application shows in the editor window, which takes up most of the space. Notice that the text is automatically colorized to indicate different parts of the code, such as keywords and types. In addition, small, vertical dashed lines in the code indicate which braces match one another, and line numbers help you locate code later. You can choose the small, boxed minus signs to collapse or expand blocks of code. This code outlining feature lets you hide code you don’t need, helping to minimize onscreen clutter. The project files are listed on the right side in a window called Solution Explorer.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

There are other menus and tool windows available, but let’s move on for now.

Now, start the app. You can do this by choosing Start Without Debugging from the Debug menu on the menu bar. You can also press Ctrl+F5.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoftStart without Debugging menu item.» data-linktype=»relative-path»>

Visual Studio builds the app, and a console window opens with the message Hello World!. You now have a running app!

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To close the console window, press any key on your keyboard.

Let’s add some more code to the app. Add the following C# code before the line that says Console.WriteLine(«Hello World!»); :

This code displays What is your name? in the console window, and then waits until the user enters some text followed by the Enter key.

Change the line that says Console.WriteLine(«Hello World!»); to the following code:

Run the app again by selecting Debug > Start Without Debugging or by pressing Ctrl+F5.

Visual Studio rebuilds the app, and a console window opens and prompts you for your name.

Enter your name in the console window and press Enter.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Press any key to close the console window and stop the running program.

Start Visual Studio. The start window appears with options for cloning a repo, opening a recent project, or creating a new project.

Choose Create a new project.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The Create a new project window opens and shows several project templates. A template contains the basic files and settings required for a given project type.

To find a template, you can type or enter keywords in the search box. The list of available templates filters based on the keywords you enter. You can further filter the template results by choosing C# from the All languages dropdown list, Windows from the All platforms list, and Console from the All project types list.

Select the Console Application template, and then select Next.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In the Configure your new project window, enter HelloWorld in the Project name box. Optionally, change the project directory location from the default location of C:\Users\ \source\repos, and then select Next.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In the Additional information window, verify that .NET 6.0 appears in the Target Framework drop-down menu, and then select Create.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual Studio creates the project. The program is a simple «Hello World» application that calls the Console.WriteLine() method to display the string Hello, World! in a console window.

The project files appear on the right side of the Visual Studio IDE, in a window called the Solution Explorer. In the Solution Explorer window, select the Program.cs file. The C# code for your app opens in the central editor window, which takes up most of the space.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The code is automatically colorized to indicate different parts, such as keywords and types. Line numbers help you locate code.

Small, vertical dashed lines in the code indicate which braces match one another. You can also choose small, boxed minus or plus signs to collapse or expand blocks of code. This code outlining feature lets you hide code you don’t need to see, helping to minimize onscreen clutter.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Many other menus and tool windows are available.

Start the app by choosing Debug > Start Without Debugging from the Visual Studio top menu. You can also press Ctrl+F5.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoftStart without Debugging menu item.» data-linktype=»relative-path»>

Visual Studio builds the app, and a console window opens with the message Hello, World!. You now have a running app!

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To close the console window, press any key.

Let’s add some more code to the app. Add the following C# code before the line that says Console.WriteLine(«Hello World!»); :

This code displays What is your name? in the console window, and then waits until the user enters some text.

Change the line that says Console.WriteLine(«Hello World!»); to the following line:

Run the app again by selecting Debug > Start Without Debugging or pressing Ctrl+F5.

Visual Studio rebuilds the app, and a console window opens and prompts you for your name.

Type your name in the console window and press Enter.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Press any key to close the console window and stop the running program.

Use refactoring and IntelliSense

Let’s look at a couple of the ways that refactoring and IntelliSense can help you code more efficiently.

First, rename the name variable:

Double-click the name variable, and type the new name for the variable, username.

A box appears around the variable, and a light bulb appears in the margin.

Select the light bulb icon to show the available Quick Actions. Select Rename ‘name’ to ‘username’.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The variable is renamed across the project, which in our case is only two places.

A box displays the members of the DateTime class. The description of the currently selected member also displays in a separate box.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Below that line, enter the following lines of code:

Console.Write is different from Console.WriteLine in that it doesn’t add a line terminator after it prints. That means that the next piece of text that’s sent to the output will print on the same line. You can hover over each of these methods in your code to see their descriptions.

Select the screwdriver icon to see available suggestions from Visual Studio. This case shows the Inline temporary variable refactoring to remove a line of code without changing the overall code behavior.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Select Inline temporary variable to refactor the code.

Run the program again by pressing Ctrl+F5. The output looks something like this:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Debug code

When you write code, you should run it and test it for bugs. Visual Studio’s debugging system lets you step through code one statement at a time and inspect variables as you go. You can set breakpoints that stop execution of the code at a particular line, and observe how the variable value changes as the code runs.

Set a breakpoint to see the value of the username variable while the program is running.

Set a breakpoint on the line of code that says Console.WriteLine($»\nHello !»); by clicking in the far-left margin, or gutter, next to the line. You can also select the line of code and then press F9.

A red circle appears in the gutter, and the line is highlighted.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Start debugging by selecting Debug > Start Debugging or pressing F5.

When the console window appears and asks for your name, enter your name.

The focus returns to the Visual Studio code editor, and the line of code with the breakpoint is highlighted in yellow. The yellow highlight means that this line of code will execute next. The breakpoint makes the app pause execution at this line.

Hover your mouse over the username variable to see its value. You can also right-click on username and select Add Watch to add the variable to the Watch window, where you can also see its value.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Press F5 again to finish running the app.

For more information about debugging in Visual Studio, see the Debugger feature tour.

Customize Visual Studio

You can personalize the Visual Studio user interface, including changing the default color theme. To change the color theme:

On the menu bar, choose Tools > Options to open the Options dialog.

On the Environment > General options page, change the Color theme selection to Dark, and then choose OK.

The color theme for the entire IDE changes to Dark.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

On the menu bar, choose Tools > Options to open the Options dialog.

On the Environment > General options page, change the Color Theme selection to Blue or Light, and then select OK.

The color theme for the entire IDE changes accordingly. The following screenshot shows the Blue theme:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To learn about other ways you can personalize the IDE, see Personalize Visual Studio.

Next steps

Explore Visual Studio further by following along with one of these introductory articles:

Cover the basics in this Learn module: Introduction to Visual Studio.

Get acquainted with the code editor in Learn to use the code editor.

Learn how Visual Studio organizes code in Learn about projects and solutions.

If you’re ready to dive into more coding, one of the following language-specific quickstarts is a good next step:

Another good place to start with coding is a tutorial:

Code editing. Redefined.

Free. Built on open source. Runs everywhere.

By using VS Code, you agree to its license and privacy statement.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Meet IntelliSense.

Go beyond syntax highlighting and autocomplete with IntelliSense, which provides smart completions based on variable types, function definitions, and imported modules.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Print statement debugging is a thing of the past.

Debug code right from the editor. Launch or attach to your running apps and debug with break points, call stacks, and an interactive console.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Git commands built-in.

Working with Git and other SCM providers has never been easier. Review diffs, stage files, and make commits right from the editor. Push and pull from any hosted SCM service.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Extensible and customizable.

Want even more features? Install extensions to add new languages, themes, debuggers, and to connect to additional services. Extensions run in separate processes, ensuring they won’t slow down your editor. Learn more about extensions.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Deploy with confidence and ease

With Microsoft Azure you can deploy and host your React, Angular, Vue, Node, Python (and more!) sites, store and query relational and document based data, and scale with serverless computing, all with ease, all from within VS Code.

VS Code for

Want new features sooner?

Use vscode.dev for quick edits online!

GitHub, Azure Repos, and local files.

License and Privacy Terms

By downloading and using Visual Studio Code, you agree to the license terms and privacy statement. VS Code automatically sends telemetry data and crash dumps to help us improve the product. If you would prefer not to have this data sent please go see How to Disable Crash Reporting to learn how to disable it.

Code editing. Redefined.

Free. Built on open source. Runs everywhere.

By using VS Code, you agree to its license and privacy statement.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Meet IntelliSense.

Go beyond syntax highlighting and autocomplete with IntelliSense, which provides smart completions based on variable types, function definitions, and imported modules.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Print statement debugging is a thing of the past.

Debug code right from the editor. Launch or attach to your running apps and debug with break points, call stacks, and an interactive console.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Git commands built-in.

Working with Git and other SCM providers has never been easier. Review diffs, stage files, and make commits right from the editor. Push and pull from any hosted SCM service.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Extensible and customizable.

Want even more features? Install extensions to add new languages, themes, debuggers, and to connect to additional services. Extensions run in separate processes, ensuring they won’t slow down your editor. Learn more about extensions.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Deploy with confidence and ease

With Microsoft Azure you can deploy and host your React, Angular, Vue, Node, Python (and more!) sites, store and query relational and document based data, and scale with serverless computing, all with ease, all from within VS Code.

VS Code for

Want new features sooner?

Use vscode.dev for quick edits online!

GitHub, Azure Repos, and local files.

License and Privacy Terms

By downloading and using Visual Studio Code, you agree to the license terms and privacy statement. VS Code automatically sends telemetry data and crash dumps to help us improve the product. If you would prefer not to have this data sent please go see How to Disable Crash Reporting to learn how to disable it.

Tutorial: Debug C# and C++ in the same debugging session

Visual Studio lets you enable more than one debugger type in a debugging session, which is called mixed-mode debugging. In this tutorial, you learn to debug both managed and native code in a single debugging session.

This tutorial shows how to debug native code from a managed app, but you can also debug managed code from a native app. The debugger also supports other types of mixed-mode debugging, such as debugging Python and native code, and using the script debugger in app types such as ASP.NET.

In this tutorial, you will:

Prerequisites

You must have Visual Studio installed, with the following workloads:

You must have Visual Studio installed, with the following workloads:

If you don’t have Visual Studio, go to theВ Visual Studio downloadsВ page to install it for free.

If you have Visual Studio installed, but don’t have the workloads you need, select Open Visual Studio Installer in the left pane of the Visual Studio New Project dialog box. In the Visual Studio Installer, select the workloads you need, and then select Modify.

Create a simple native DLL

To create the files for the DLL project:

Open Visual Studio and create a project.

Press Esc to close the start window. Type Ctrl + Q to open the search box, type Empty Project, choose Templates, then choose Empty Project for C++. In the dialog box that appears, choose Create. Then, type a name like Mixed_Mode_Debugging and click Create.

Visual Studio creates the project.

In Solution Explorer, select Source Files, and then select Project > Add New Item. Or, right-click Source Files and select Add > New Item.

In the New Item dialog, select C++ file (.cpp). Type Mixed_Mode.cpp in the Name field, and then select Add.

Visual Studio adds the new C++ file to Solution Explorer.

Copy the following code into Mixed_Mode.cpp:

In Solution Explorer, select Header Files, and then select Project > Add New Item. Or, right-click Header Files and select Add > New Item.

In the New Item dialog, select Header file (.h). Type Mixed_Mode.h in the Name field, and then select Add.

Visual Studio adds the new header file to Solution Explorer.

Copy the following code into Mixed_Mode.h:

Select File > Save All or press Ctrl+Shift+S to save the files.

To configure and build the DLL project:

In Solution Explorer, select the Mixed_Mode_Debugging project node and select the Properties icon, or right-click the project node and select Properties.

At the top of the Properties pane, make sure the Configuration is set to Active(Debug) and the Platform is the same as what you set in the toolbar: x64, or Win32 for x86 platform.

If you switch platform from x86 to x64 or vice versa, you must reconfigure the properties for the new platform.

Under Configuration Properties in the left pane, select Linker > Advanced, and in the dropdown next to No Entry Point, select No. If you had to change it to No, select Apply.

Under Configuration Properties, select General, and in the dropdown next to Configuration Type, select Dynamic Library (.dll). Select Apply, and then select OK.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Select the project in Solution Explorer and then select Build > Build Solution, press F7, or right-click the project and select Build.

The project should build with no errors.

Create a simple managed app to call the DLL

Open Visual Studio and create a new project.

Then, type a name like Mixed_Mode_Calling_App and click Next or Create, whichever option is available.

You could also add the new managed project to your existing C++ solution. We are creating the project in a new solution to make the mixed-mode debugging task more difficult.

Visual Studio creates the empty project and displays it in Solution Explorer.

Replace all the code in Program.cs with the following code:

In the new code, replace the file path in [DllImport] with your file path to the Mixed_Mode_Debugging.dll you just created. See the code comment for hints. Make sure to replace the username placeholder.

Select File > Save Program.cs or press Ctrl+S to save the file.

Configure mixed-mode debugging

In Solution Explorer, select the Mixed_Mode_Calling_App project node and select the Properties icon, or right-click the project node and select Properties.

Enable native code debugging in the properties.

Select Debug in the left pane, select Open debug launch profiles UI, then select the Enable native code debugging check box, and then close the properties page to save the changes. Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Select Debug in the left pane, select the Enable native code debugging check box, and then close the properties page to save the changes.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Set a breakpoint and start debugging

In the C# project, open Program.cs. Set a breakpoint on the following line of code by clicking in the far left margin, selecting the line and pressing F9, or right-clicking the line and selecting Breakpoint > Insert Breakpoint.

A red circle appears in the left margin where you set the breakpoint.

Press F5, select the green arrow in the Visual Studio toolbar, or select Debug > Start Debugging to start debugging.

The debugger pauses on the breakpoint that you set. A yellow arrow indicates where the debugger is currently paused.

Step in and out of native code

While debugging is paused in the managed app, press F11, or select Debug > Step Into.

The Mixed_Mode.h native header file opens, and you see the yellow arrow where the debugger is paused.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Now, you can set and hit breakpoints and inspect variables in the native or managed code.

Hover over variables in the source code to see their values.

Look at variable and their values in the Autos and Locals windows.

While paused in the debugger, you can also use the Watch windows and the Call Stack window.

Press F11 again to advance the debugger one line.

Press Shift+F11 or select Debug > Step Out to continue execution and pause again in the managed app.

Press F5 or select the green arrow to continue debugging the app.

Congratulations! You have completed the tutorial on mixed-mode debugging.

Next step

In this tutorial, you learned how to debug native code from a managed app by enabling mixed-mode debugging. For an overview of other debugger features, see:

Code editing. Redefined.

Free. Built on open source. Runs everywhere.

By using VS Code, you agree to its license and privacy statement.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Meet IntelliSense.

Go beyond syntax highlighting and autocomplete with IntelliSense, which provides smart completions based on variable types, function definitions, and imported modules.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Print statement debugging is a thing of the past.

Debug code right from the editor. Launch or attach to your running apps and debug with break points, call stacks, and an interactive console.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Git commands built-in.

Working with Git and other SCM providers has never been easier. Review diffs, stage files, and make commits right from the editor. Push and pull from any hosted SCM service.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Extensible and customizable.

Want even more features? Install extensions to add new languages, themes, debuggers, and to connect to additional services. Extensions run in separate processes, ensuring they won’t slow down your editor. Learn more about extensions.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Deploy with confidence and ease

With Microsoft Azure you can deploy and host your React, Angular, Vue, Node, Python (and more!) sites, store and query relational and document based data, and scale with serverless computing, all with ease, all from within VS Code.

VS Code for

Want new features sooner?

Use vscode.dev for quick edits online!

GitHub, Azure Repos, and local files.

License and Privacy Terms

By downloading and using Visual Studio Code, you agree to the license terms and privacy statement. VS Code automatically sends telemetry data and crash dumps to help us improve the product. If you would prefer not to have this data sent please go see How to Disable Crash Reporting to learn how to disable it.

Методы и средства отладки, помогающие писать более качественный код

Устранение ошибок в коде может быть трудоемкой и иногда неприятной задачей. Чтобы научиться эффективно выполнять отладку, требуется время, но эффективная интегрированная среда разработки, такая как Visual Studio, может сделать вашу работу гораздо проще. Интегрированная среда разработки позволяет быстрее исправлять ошибки и выполнять отладку кода, а также может помочь в написании боле качественного кода с меньшим количеством ошибок. Целью этой статьи является формирование комплексного представления о процессе исправления ошибок, благодаря чему вы узнаете, когда следует использовать анализатор кода, когда — отладчик, как исправить исключения и как писать код, руководствуясь его предназначением. Если вы уже знакомы с использованием отладчика, см. статью Первое знакомство с отладчиком.

В этой статье мы поговорим об использовании интегрированной среды разработки для повышения продуктивности сеансов программирования. Мы затронем несколько задач, таких как:

Подготовка кода к отладке с помощью анализатора кода интегрированной среды разработки

Исправление исключений (ошибки времени выполнения)

Минимизация ошибок путем написания кода с учетом его предназначения (с помощью оператора assert)

Аспекты использования отладчика

В качестве демонстрации к этим задачам мы рассмотрим несколько наиболее распространенных типов ошибок, которые возникают при попытке отладки приложений. Хотя пример кода написан на C#, указанные концепции в общем случае применимы к C++, Visual Basic, JavaScript и другим языкам, поддерживаемым Visual Studio (если не указано иное). На снимках экрана представлены примеры на C#.

Создание примера приложения с некоторыми ошибками

В следующем коде есть ошибки, которые можно исправить с помощью интегрированной среды разработки Visual Studio. Здесь представлено простое приложение, которое имитирует получение данных JSON из некоторой операции, десериализацию данных в объект и обновление простого списка с помощью новых данных.

Установите Visual Studio бесплатно со страницы скачиваемых материалов Visual Studio, если еще не сделали этого.

Запустите Visual Studio.

Visual Studio создаст консольный проект и откроет его в обозревателе решений (правая область).

Замените код по умолчанию в файле Program.cs проекта на пример кода ниже.

Ищите красные и зеленые волнистые линии!

Прежде чем пытаться запустить пример приложения и отладчик, проверьте код в редакторе кода на наличие красных и зеленых волнистых линий. Они представляют ошибки и предупреждения, определяемые анализатором кода интегрированной среды разработки. Красные волнистые линии обозначают ошибки времени компиляции, которые необходимо исправить, прежде чем можно будет запустить код. Зеленые волнистые линии обозначают предупреждения. Хотя часто приложение можно запустить без исправления предупреждений, они могут быть источником ошибок, а их устранение во многих случаях помогает сэкономить время и силы. Эти предупреждения и ошибки также можно просмотреть в окне Список ошибок, если вы предпочитаете представление списка.

В примере приложения вы увидите несколько красных волнистых линий, которые необходимо исправить, и одну зеленую, которую необходимо изучить. Ниже приведена первая ошибка.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Чтобы устранить эту ошибку, обратитесь к другой функции интегрированной среды разработки, представленной значком в виде лампочки.

Проверяйте лампочку!

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Если щелкнуть этот элемент, Visual Studio добавит оператор using System.Text в начало файла Program.cs, а красная волнистая линия исчезнет. (Если вы не уверены, что именно делает предложенное исправление, выберите ссылку Просмотреть изменения справа перед его применением.)

Исправление оставшихся ошибок и предупреждений

В этом коде есть еще несколько волнистых линий. Здесь присутствует типичная ошибка преобразования типа. При наведении указателя мыши на волнистую линию видно, что код пытается преобразовать тип string в int, что не поддерживается, если не добавлен явный код для такого преобразования.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Чтобы устранить эту ошибку, измените член points класса User с такого:

Красные волнистые линии в редакторе кода исчезают.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Зеленая волнистая линия исчезает.

Исправление исключения

Когда вы устранили все ошибки, обозначенные красными волнистыми линиями, и разрешили или по меньшей мере изучили все предупреждения, обозначенные зелеными волнистыми линиями, все готово к запуску отладчика и приложения.

Нажмите клавишу F5 (Отладка > Начать отладку) или кнопку Начать отладку Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoftна панели инструментов отладки.

На этом этапе пример приложения выдает исключение SerializationException (ошибка времени выполнения). Это значит, что приложение не справляется с данными, которые пытается сериализовать. Так как приложение запущено в режиме отладки (подключен отладчик), помощник по исправлению ошибок отладчика переносит вас прямо к коду, выдавшему исключение, и выдает полезное сообщение об ошибке.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

При возникновении исключения необходимо задать себе пару вопросов:

Является ли это исключение простой ошибкой, которую можно исправить? Или

Может ли это исключение возникнуть у пользователей?

В первом случае исправьте ошибку. (В примере приложения для этого нужно исправить неверные данные.) Во втором случае может потребоваться обработать исключение в коде, используя блок try/catch (мы рассмотрим другие возможные стратегии в следующем разделе). В примере приложения замените приведенный ниже код:

Блок try/catch подразумевает некоторое снижение производительности, поэтому их следует использовать только тогда, когда это действительно необходимо, то есть, когда (а) они могут возникнуть в окончательной версии приложения и (б) документация по методу указывает, что необходимо проверить наличие исключения (с предположением, что документация завершена). Во многих случаях можно соответствующим образом обработать исключение, чтобы пользователь никогда с ним не столкнулся.

Ниже приведено несколько важных советов по обработке исключений:

Для незнакомых функций, включаемых в приложение, особенно тех, которые взаимодействуют с внешними данными (например, с веб-запросом), изучите документацию, чтобы узнать, какие исключения может вызывать функция. Это может оказаться крайне важной информацией для правильной обработки ошибок и отладки приложения.

Уточнение предназначения кода с помощью оператора assert

Нажмите кнопку Перезапустить Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoftна панели инструментов отладки (CTRL + SHIFT + F5). Это приведет к перезапуску приложения за меньшее количество шагов. В окне консоли вы увидите приведенные ниже выходные данные.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Можно заметить, что с выходными данными что-то не так. Значения name и lastname для третьей записи пусты.

Добавив такие операторы assert в функции в процессе разработки, можно указать предназначение кода. В предыдущем примере мы указываем следующее:

Указав таким образом намерение, вы применяете необходимые требования. Это простой и удобный способ, который можно использовать для изучения ошибок во время разработки. (Операторы assert также используются в качестве главного элемента в модульных тестах.)

Нажмите кнопку Перезапустить Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoftна панели инструментов отладки (CTRL + SHIFT + F5).

Код assert активен только в отладочной сборке.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Для предыдущих операторов ваше намерение заключается в том, чтобы загрузить существующие данные ( db ) и извлечь новые данные ( users ) перед обновлением.

Приведенный выше код полезен, если необходимо указать следующее намерение: для обновления записи пользователя требуется новое значение точки больше нуля (0).

Проверка кода в отладчике

Итак, теперь, когда вы устранили все критические проблемы с примером приложения, можно двигаться дальше.

Мы рассмотрели помощник по исправлению ошибок отладчика, но отладчик является гораздо более функциональным инструментом, который позволяет совершать и другие действия, такие как пошаговое выполнение кода и изучение его переменных. Эти эффективные возможности полезны во многих сценариях, особенно в следующих случаях:

Вы пытаетесь изолировать ошибку времени выполнения в коде, но не можете сделать это с помощью описанных выше методов и средств.

Вы хотите проверить код, то есть следить за его выполнением, чтобы убедиться, что он работает надлежащим образом и совершает необходимые действия.

Следить за выполнением кода очень полезно. Так вы можете получить дополнительные сведения о коде и выявить ошибки до того, как проявляются их очевидные симптомы.

Дополнительные сведения об использовании функций отладчика см. в статье Отладка для начинающих.

Исправление проблем производительности

Ошибки другого типа включают неэффективный код, из-за которого приложение выполняется медленнее или использует слишком много памяти. Как правило, оптимизация производительности осуществляется на более позднем этапе разработки приложения. Однако столкнуться с проблемами производительности можно уже на ранних этапах (например, часть приложения может работать медленно), в результате чего вам может потребоваться протестировать приложение с помощью средств профилирования. Дополнительные сведения о средствах профилирования, таких как средство загрузки ЦП и анализатор памяти, см. в разделе Знакомство со средствами профилирования.

Следующие шаги

В этой статье вы узнали, как предотвращать и устранять многие распространенные ошибки в коде и когда использовать отладчик. Далее вы можете подробнее узнать об использовании отладчика Visual Studio для исправления ошибок.

It’s how you make software

Visual Studio can do that.

Meet the Visual Studio family

Visual Studio

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual Studio for Mac

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual Studio Code

A standalone source code editor that runs on Windows, macOS, and Linux. The top pick for JavaScript and web developers, with extensions to support just about any programming language.

By using Visual Studio Code you agree to its license & privacy statement

Still not sure which tool is best for you? We can help

Visual Studio Code for Windows

Lightweight yet powerful source code editor with tons of extensions for many languages and runtimes.

Hundreds of programming languages supported

Visual Studio Code for Mac

Hundreds of programming languages supported

Visual Studio for Mac

A complete array of development tools and features in native macOS experience for every stage of your software development.

Visual Studio Code for Linux

Hundreds of programming languages supported

Visual Studio for Windows

A complete array of development tools and features in one place to elevate and enhance every stage of your software development.
How to install offlineCompare editions

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Announcing Microsoft Dev Box

Microsoft Dev Box provides developers with self-service access to high-performance, cloud based workstations preconfigured for your projects.

Microsoft Dev Box provides developers with self-service access to high-performance, cloud based workstations preconfigured for your projects.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual Studio 25th Anniversary

Join us in celebrating Visual Studio’s 25th anniversary. Watch the video, grab some swag!

Join us in celebrating Visual Studio’s 25th anniversary. Watch the video, grab some swag!

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual Studio 2022

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual Studio 2022 for Mac

Visual Studio Subscriptions

Get more from Visual Studio with a subscription! Get access to platforms like Azure, training, and more for your team.

Code editing. Redefined.

Free. Built on open source. Runs everywhere.

By using VS Code, you agree to its license and privacy statement.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Meet IntelliSense.

Go beyond syntax highlighting and autocomplete with IntelliSense, which provides smart completions based on variable types, function definitions, and imported modules.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Print statement debugging is a thing of the past.

Debug code right from the editor. Launch or attach to your running apps and debug with break points, call stacks, and an interactive console.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Git commands built-in.

Working with Git and other SCM providers has never been easier. Review diffs, stage files, and make commits right from the editor. Push and pull from any hosted SCM service.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Extensible and customizable.

Want even more features? Install extensions to add new languages, themes, debuggers, and to connect to additional services. Extensions run in separate processes, ensuring they won’t slow down your editor. Learn more about extensions.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Deploy with confidence and ease

With Microsoft Azure you can deploy and host your React, Angular, Vue, Node, Python (and more!) sites, store and query relational and document based data, and scale with serverless computing, all with ease, all from within VS Code.

VS Code for

Want new features sooner?

Use vscode.dev for quick edits online!

GitHub, Azure Repos, and local files.

License and Privacy Terms

By downloading and using Visual Studio Code, you agree to the license terms and privacy statement. VS Code automatically sends telemetry data and crash dumps to help us improve the product. If you would prefer not to have this data sent please go see How to Disable Crash Reporting to learn how to disable it.

March 2021 (version 1.55)

Update 1.55.1: The update addresses these issues.

Update 1.55.2: The update addresses these security issues.

Welcome to the March 2021 release of Visual Studio Code. There are a number of updates in this version that we hope you will like, some of the key highlights include:

If you’d like to read these release notes online, go to Updates on code.visualstudio.com.

Join us live at the VS Code team’s livestream on Thursday, April 8 at 8am Pacific (4pm London) to see a demo of what’s new in this release, and ask us questions live.

Insiders: Want to try new features as soon as possible? You can download the nightly Insiders build and try the latest updates as soon as they are available.

Accessibility

Multi-cursor support

We have added initial screen reader support for multiple cursors. Whenever a new cursor is added, VS Code now announces it along with the cursor line and column position. VS Code also announces when secondary cursors have been removed. We plan to further improve multi-cursor accessibility as we receive more feedback.

Increased limit to 1000 lines for screen reader

Thanks to upstream issues being fixed, we have increased the number of lines that a «Say All» command can read. Previously, we had a hard limit of 100 lines that could be announced by a screen reader at one time, and we have now increased this limit to 1000. Further upstream fixes are needed in order for us to not have any limit at all.

Due to this change, the setting editor.accessibilityPageSize is now deprecated. We will still support this setting in the next couple of releases, however we plan to fully drop it in the future.

Workbench

Encryption update on Windows

We’ve changed the way we encrypt secrets on Windows, which impacts Settings Sync and extensions using the secrets API. Users on Windows will be automatically signed out on update and will need to authenticate again.

Updated brand icons for macOS Big Sur

We’ve been working on updating the VS Code brand icons on macOS to match the new visual style of Big Sur. We’ve appreciated all of the feedback from the community, and we are happy to release the new logos for Stable and Insiders. We are also using the same logos on all platforms.

StableInsidersExploration

Improved sash customization

A new workbench.sash.hoverDelay setting lets you define the delay for the hover feedback of sashes. The existing workbench.sash.size setting has been improved in order to still provide a large surface grabbing area for touch devices, while keeping the UI clean.

Improved List/Tree navigation

Lists and Trees now support a custom keyboard navigation mode that behaves more naturally in specific areas such as Notebooks.

Additionally, Shift+Click range selections behave more deterministically.

Tab decorations on by default

Tab decorations for editors are now on by default, to configure them use workbench.editor.decorations.colors and workbench.editor.decorations.badges

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoftTheme: GitHub Light Theme

Resizing columns in Keyboard Shortcuts editor

The Keyboard Shortcuts editor is now refactored to use the new table widget, allowing users to resize the columns in the editor.

Extension management improvements

VS Code now detects extensions installed/uninstalled through the VS Code CLI. Extensions can be activated/de-activated in the active window (instance) and will be correctly displayed in the Extensions view.

VS Code now shows the set of extensions included in an extension that sets the extensionPack property in a separate Extension Pack tab even when the extension is not categorized as Extension Packs.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Negative text filtering in Problems view

Reporting Marketplace issues

Last month we highlighted that there’s a new public repository for issues related to the Extension Marketplace. Now, VS Code’s issue reporter supports creating issues in this repository.

Configure tree hover delay

Emmet

The emmet.extensionsPath setting now takes in only string arrays, and can be directly edited in the Settings editor.

Search in Open Editors

You can now toggle the Search Only in Open Editors checkbox in a workspace search to change from searching the entire workspace to only searching in files that have been opened in editor tabs. This previously was enabled via an opt-in, this iteration we’ve enhanced the behavior with files that have not yet been loaded in the VS Code session and enabled it by default.

Control the font size of the Source Control input

You can now change the font size of the Source Control input via the new scm.inputFontSize setting.

Integrated Terminal

Terminal profiles

The terminal now supports defined profiles, which appear in the terminal’s dropdown, to conveniently launch non-default shells:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

VS Code will automatically detect and surface some of the more commonly used shells through this menu, but they can also be configured using the terminal.integrated.profiles.

setting. With this setting, it’s possible to add new profiles, change existing profiles and remove default profiles. For example:

The recommended way to initially add a profile is via the Select Default Profile command, which allows creating profiles based on either an existing profile or other detected shells.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Auto detected WSL profiles and improved defaults on Windows

Along with the new profiles feature, we now auto detect WSL profiles and show them in the list by default. This can be turned off with the terminal.integrated.useWslProfiles setting.

Cygwin is also now auto detected and exposed in the Select Default Profile command and Git Bash will run as a login shell (running

WebGL renderer is the new default

The terminal first got the experimental WebGL renderer back in the November 2019 release, which based our calculations at the time could increase performance by up to 900% and by even more if your environment had issues with rendering using a standard 2D canvas context.

Since then, the WebGL renderer has gradually improved in stability and had its feature gap closed. We decided now is as good a time as any to make the transition, but will be watching for any issue reports.

Seamless terminal relaunching

Last release, we introduced automatic relaunching of terminals when an extension wants to change the environment. This release will now prevent the flickering that was caused before when the relaunch occurs. If the output of the new terminal is identical to the last, there is no feedback or distractions caused by the relaunch.

Editor

New auto closing pair deletion

Debugging

Improvements to breakpoints

Inline menu to edit conditions and hit count

We now show an inline menu for editing conditions and hit counts for function breakpoints. Previously the inline edit button would choose automatically what condition to edit. Now, the menu should make the flow easier and give more control to the user.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Support for all access types of data breakpoints

Now VS Code’s generic debugger UI supports all data breakpoint access types defined in the Debug Adapter Protocol as context menu actions in the VARIABLES view:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Clearing a terminal before launching a debuggee

Some debug extensions allow you to launch debuggees in VS Code’s Integrated Terminal. In order to keep the number of Integrated Terminals small, VS Code tries to reuse a terminal if it is not blocked by a still running command. A consequence of this approach is that previous commands and program output will remain visible in the terminal, which is sometimes confusing.

JavaScript debugging

As usual, the complete list of changes can be found in the vscode-js-debug changelog.

Start Debugging and Stop on Entry

Improved handling of symbolic links

Debugging Node.js programs with symbolic links can require special flags to be passed to the program. Without these flags, breakpoints remained unbound, and it was hard to figure out what was going wrong. Now, the debugger will automatically detect these cases and provide a helpful notification.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Notebooks

Multiple cell selection

We now support selecting multiple cells in a Notebook using the mouse ( Shift+Click ) or keyboard shortcuts ( Shift+Arrow ). Once multiple cells are selected, you can then copy/cut/paste/move/duplicate selected cells.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

You can also drag and drop multiple cells together.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Limitations: When there are multiple distinct ranges of cells selected, most commands will only be executed against the first range or the focused range. We will continue improving this experience in upcoming releases.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Show/hide output and metadata differences in the diff editor

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Preview features

Continued improvements to extensible Markdown renderers in Notebooks

We continued improving our support extending the Markdown renderer in Notebooks. Our focus this iteration was improving performance of the new renderers. We also fixed many regressions that the new renders introduced.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Getting Started

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoftTheme: GitHub Light

Contributions to extensions

Remote Development

Work continues on the Remote Development extensions, which allow you to use a container, remote machine, or the Windows Subsystem for Linux (WSL) as a full-featured development environment.

Feature highlights in 1.55 include:

You can learn about new extension features and bug fixes in the Remote Development release notes.

GitHub Pull Requests and Issues

Work continues on the GitHub Pull Requests and Issues extension, which allows you to work on, create, and manage pull requests and issues.

To learn about all the new features and updates, you can see the full changelog for the 0.25.0 release of the extension.

Extension authoring

Untitled file API for custom editors & Notebooks

Custom editors and Notebooks now include an untitledDocumentData property on the open context, which includes the buffer of the data included in the untitled file that the user triggered a Reopen With on. This property should be read instead of the URI if populated as the URI doesn’t point to a file on disk in the untitled file case.

Inline values provider API

The proposed inline values provider API introduced last milestone has been finalized and can now be used in extensions published on the Marketplace.

New Copy As submenus

There are two new menu locations, which appear in the UI as a Copy As submenu:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

New extension property on ExtensionContext

Docker compose language

Telemetry enablement API

Workspace Trust development

For several iterations, we have been exploring a security feature we refer to as Workspace Trust. As we near its release, we seek to engage extension authors to start their onboarding process and get feedback. At the present, extensions that are not updated to handle Workspace Trust will inherit safe defaults; however, for an optimal user-experience, we request extension authors read more information in issue #106488 and subscribe for updates as we progress through the next iteration.

Proposed extension APIs

Every milestone comes with new proposed APIs and extension authors can try them out. As always, we want your feedback. This is what you have to do to try out a proposed API:

You cannot publish an extension that uses a proposed API. There may be breaking changes in the next release and we never want to break existing extensions.

Testing

This month our work was focused around resolving the provider portion of the testing APIs. Primarily, moving to an approach that allows for tests to be loaded on-demand and asynchronously. Shifting to an asynchronous approach presented challenges that required semantics new to the extension host API to solve. This iteration we merged in the changes, and will refine them over the coming month. We hope to begin finalizing portions of the testing API in our April iteration.

CodeActionContext.triggerKind

Invoke : Code actions were requested explicitly, either with a keyboard shortcut or command.

Automatic : Code actions were requested without explicit user action. This includes requesting code actions when the contents of a document change.

Providers can use triggerKind to return different sets of results depending on how code actions are requested. For example, a refactoring code action provider that is triggered automatically may only return refactorings for the exact current selection in order to limit how often the code action lightbulb shows up. However when code actions are explicitly requested, the same provider may automatically expand the current selection to try to show all the refactorings that a user may be interested in at the current location.

PortAttributesProvider

Any extension that starts processes that listen on ports and wants to have a stellar experience when used with a VS Code remote extension should consider providing feedback and adopting the new PortsAttributesProvider API. Since VS Code detects and automatically forwards ports when using one of the remote extensions, any extension that listens on ports will have those ports automatically forwarded. Often though, these ports are only important for the internal workings of the extension, and it isn’t useful for the user to have these ports forwarded. This API can be used to set the behavior when a port is detected to prevent unwanted autoforwarding of ports that shouldn’t be user facing.

Quick input options title

The QuickPickOptions passed in to showQuickPick and InputBoxOptions passed into showInputBox now have an optional title property that was previously only available in the createQuickPick API. This property, when set, displays a title bar on the quick input with the title you specified.

Language Server Protocol

A draft version of the diagnostic pull model specification is now available for feedback.

Debug Adapter Protocol

The stopped event can now report the breakpoints that were hit

An optional attribute hitBreakpointIds has been added to the stopped event that contains the IDs of the breakpoints that triggered the event.

Note that VS Code does not yet surface this information in any way. We are discussing possible UI ideas in issue #118743.

Engineering

Faster Snap launch

The snap package now uses the lzo compression algorithm, which provides faster launch times. For more information, see the blog post from Ubuntu about the algorithm.

Progress on Electron sandbox

This milestone we continued to make the VS Code window ready for enabling Electron’s sandbox and context isolation features.

Documentation

VS Code and JavaScript in the classroom

Read the case study of a Computer Science lecturer at Naresuan University in Thailand, who uses VS Code in his introductory Web Development classes with JavaScript and Node.js. Learn about the settings and extensions he recommends for his students, as well as a helpful Node.js and JavaScript Education Extension Pack.

Raspberry Pi

There is a new topic describing how to install VS Code on Raspberry Pi devices.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Notable fixes

Thank you

Last but certainly not least, a big Thank You to the following people who contributed this month to VS Code:

Contributions to our issue tracking:

Contributions to vscode :

Contributions to vscode-emmet-helper :

Contributions to vscode-eslint :

Contributions to vscode-hexeditor :

Contributions to vscode-html-languageservice :

Contributions to vscode-js-debug :

Contributions to vscode-languageserver-node :

Contributions to vscode-mock-debug :

Contributions to vscode-textmate :

Contributions to vscode-vsce :

Contributions to debug-adapter-protocol :

Contributions to language-server-protocol :

Узнайте, как использовать редактор кода

В этом 10-минутном введении, посвященном редактору кода в Visual Studio, мы добавим код в файл, чтобы рассмотреть некоторые способы, упрощающие написание, понимание кода и навигацию по нему в Visual Studio.

Установите Visual Studio бесплатно со страницы скачиваемых материалов Visual Studio, если еще не сделали этого.

Установите Visual Studio бесплатно со страницы скачиваемых материалов Visual Studio, если еще не сделали этого.

Эта статья предполагает, что вы уже знакомы с языком программирования. В противном случае рекомендуется сначала посмотреть одно из кратких руководств по языкам программирования Python или C# либо по созданию консольного приложения с помощью Visual Basic или C++.

Чтобы выполнять действия, описанные в этой статье, выберите нужные параметры C# для Visual Studio. Сведения о настройке параметров для интегрированной среды разработки (IDE) вы найдете в этой статье.

Создание файла кода

Для начала создайте файл и добавьте в него код.

Запустите Visual Studio. Нажмите клавишу ESC или нажмите Продолжить без кода в окне запуска, чтобы открыть среду разработки.

В меню Файл в строке меню выберите пункты Создать>Файл.

В диалоговом окне Новый файл в разделе Общие выберите Класс Visual C# и нажмите кнопку Открыть.

Новый файл открывается в редакторе с каркасом класса C#. (Обратите внимание, что нам не нужно создавать полный проект Visual Studio, чтобы получить некоторые преимущества редактора кода. Вам нужен только файл кода!)

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Запустите Visual Studio. Нажмите клавишу ESC или щелкните команду Продолжить без кода в окне запуска, чтобы открыть среду разработки.

В меню Файл в строке меню выберите элементы Создать>Файл или нажмите клавиши CTRL+N.

В диалоговом окне Новый файл в разделе Общие выберите Класс Visual C# и нажмите кнопку Открыть.

Новый файл открывается в редакторе с каркасом класса C#.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Использование фрагментов кода

Visual Studio предоставляет удобные фрагменты кода, позволяющие быстро и легко создавать часто используемые блоки кода. Фрагменты кода доступны для различных языков программирования, включая C#, Visual Basic и C++.

Давайте добавим фрагмент void Main C# в файл.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Два раза нажмите клавишу TAB, чтобы вставить фрагмент кода.

Для разных языков программирования доступны различные фрагменты кода. Вы можете просмотреть фрагменты кода, доступные для используемого языка, выбрав Изменить>IntelliSense>Вставить фрагмент и указав папку вашего языка. Для C# список выглядит следующим образом.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Два раза нажмите клавишу TAB, чтобы вставить фрагмент кода.

Для разных языков программирования доступны соответствующие фрагменты кода. Вы можете просмотреть фрагменты кода, доступные для используемого языка. Для этого выберите элементы Изменить>IntelliSense>Вставить фрагмент или нажмите клавиши CTRL+K и CTRL+X, а затем укажите папку для своего языка программирования. Для C# список фрагментов кода выглядит следующим образом.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Список включает фрагменты кода для создания класса, конструктора, цикла for, операторов if и switch и многое другое.

Закомментирование кода

Панель инструментов, которая находится в строке кнопок под строкой меню в Visual Studio, поможет повысить продуктивность написания кода. Например, можно переключить режим завершения IntelliSense (IntelliSense — это помощник в написании кода, который отображает список подходящих методов и многое другое), увеличить или уменьшить отступ строки или закомментировать код, который вы не хотите компилировать. В этом разделе мы закомментируем код.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Символы комментария C# // добавляются в начало каждой выбранной строки, чтобы закомментировать код.

Панель инструментов текстового редактора, которая представляет строку с кнопками под строкой меню в Visual Studio, делает написание кода более продуктивным. Например, вы можете переключить режим завершения IntelliSense, увеличить либо уменьшить отступ для строк или закомментировать фрагмент кода, который не нужно компилировать.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Давайте закомментируем некоторую часть кода.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Символы комментария C# // добавляются в начало каждой выбранной строки, чтобы закомментировать код.

Если нужно раскомментировать строки, выберите их, а затем нажмите кнопку Раскомментировать выбранные строки на панели инструментов текстового редактора. Если вы предпочитаете использовать клавиатуру, нажмите клавиши CTRL+K, CTRL+U.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Свертывание блоков кода

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Просмотр определений символов

Щелкните правой кнопкой мыши любой из экземпляров string и выберите пункт Показать определение в контекстном меню. Или нажмите Alt+F12.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Закройте окно просматриваемого определения, щелкнув небольшое поле со знаком «x» в его правом верхнем углу.

В редакторе Visual Studio можно легко проверить определение типа, метода или переменной. Один из способов — перейти к файлу, который содержит определение. Для этого выберите команду Перейти к определению или нажмите клавишу F12 в любом месте, где указана ссылка на этот символ. Сделать это еще быстрее и даже без перемещения фокуса с кода можно, щелкнув команду Показать определение.

Щелкните правой кнопкой мыши любой из экземпляров string и выберите пункт Показать определение в контекстном меню. Или нажмите клавиши ALT+F12.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Закройте окно просматриваемого определения, щелкнув небольшое поле со знаком Х справа в верхнем углу.

Использование IntelliSense для завершения слов

Технология IntelliSense крайне полезна при написании кода. Она может отображать сведения о доступных членах типа или сведения о параметрах для различных перегрузок метода. Вы также можете использовать IntelliSense для завершения слова после того, как ввели достаточно знаков для однозначного его определения. Давайте добавим строку кода для вывода упорядоченных строк в окне консоли — это стандартное место для отображения выходных данных программы.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Чтобы вставить оставшуюся часть слова query с помощью функции завершения слов IntelliSense, нажмите клавишу Tab.

Технология IntelliSense крайне полезна при написании кода. Она может отображать сведения о доступных членах типа или сведения о параметрах для различных перегрузок метода. Вы также можете использовать IntelliSense для завершения слова после того, как ввели достаточно знаков для однозначного его определения.

Давайте добавим строку кода для вывода упорядоченных строк в окне консоли — это стандартное место для отображения выходных данных программы.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Чтобы вставить оставшуюся часть слова query с помощью функции завершения слов IntelliSense, нажмите клавишу TAB.

Рефакторинг имени

Поместите курсор на определение переменной _words и выберите пункт Переименовать в контекстном меню или нажмите клавиши CTRL+R, CTRL+R.

В верхней правой части редактора отображается всплывающее диалоговое окно Переименование.

Введите нужное имя words. Обратите внимание, что ссылка на words в запросе также переименовывается автоматически. Перед нажатием клавиши ВВОД установите флажок Включить комментарии во всплывающем окне Переименование.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Нажмите клавишу ВВОД.

Поместите курсор на определение переменной someWords и выберите команду Переименовать в контекстном меню или нажмите клавишу F2.

Справа в верхней части окна редактора отобразится диалоговое окно Переименование.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Введите имя unsortedWords. Вы увидите, что ссылка на unsortedWords в операторе назначения query также переименовывается автоматически. Прежде чем нажать клавишу ВВОД или щелкнуть действие Применить, установите флажок Включить комментарии во всплывающем окне Переименовать.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Нажмите клавишу ВВОД или щелкните команду Применить в диалоговом окне Переименование.

Оба вхождения someWords в коде, а также текст someWords в комментарии к коду были переименованы.

Welcome to the Visual Studio IDE

This article applies to Visual Studio 2017. If you’re looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

An integrated development environment (IDE) is a feature-rich program that supports many aspects of software development. The Visual Studio IDE is a creative launching pad that you can use to edit, debug, and build code, and then publish an app. Over and above the standard editor and debugger that most IDEs provide, Visual Studio includes compilers, code completion tools, graphical designers, and many more features to enhance the software development process.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The preceding image shows Visual Studio with an open project that shows key windows and their functionality:

In Solution Explorer, at upper right, you can view, navigate, and manage your code files. Solution Explorer can help organize your code by grouping the files into solutions and projects.

The central editor window, where you’ll probably spend most of your time, displays file contents. In the editor window, you can edit code or design a user interface such as a window with buttons and text boxes.

Editions

Visual Studio is available for Windows and Mac. Visual Studio for Mac has many of the same features as Visual Studio for Windows, and is optimized for developing cross-platform and mobile apps. This article focuses on the Windows version of Visual Studio.

There are three editions of Visual Studio: Community, Professional, and Enterprise. See Compare Visual Studio editions to learn about which features are supported in each edition.

Popular productivity features

Some popular features in Visual Studio that improve your productivity when developing software include:

Squiggles are wavy underlines that alert you to errors or potential problems in your code as you type. These visual clues help you fix problems immediately, without waiting to discover errors during build or runtime. If you hover over a squiggle, you see more information about the error. A lightbulb might also appear in the left margin showing Quick Actions you can take to fix the error.

Refactoring includes operations such as intelligent renaming of variables, extracting one or more lines of code into a new method, and changing the order of method parameters.

IntelliSense is a set of features that display information about your code directly in the editor and, in some cases, write small bits of code for you. It’s like having basic documentation inline in the editor, so you don’t have to look up type information elsewhere.

The following illustration shows how IntelliSense displays a member list for a type:

Visual Studio menus, options, and properties can seem overwhelming at times. Visual Studio search, or Ctrl+Q, is a great way to rapidly find IDE features and code in one place.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

For more information, see Quick Launch.

Collaboratively edit and debug with others in real time, regardless of your app type or programming language. You can instantly and securely share your project. You can also share debugging sessions, terminal instances, localhost web apps, voice calls, and more.

The Call Hierarchy window shows the methods that call a selected method. This information can be useful when you’re thinking about changing or removing the method, or when you’re trying to track down a bug.

CodeLens helps you find code references, code changes, linked bugs, work items, code reviews, and unit tests, without leaving the editor.

The Go To Definition feature takes you directly to the location of a function or type definition.

The Peek Definition window shows a method or type definition without opening a separate file.

Install Visual Studio

In this section, you create a simple project to try out some of the things you can do with Visual Studio. You use IntelliSense as a coding aid, debug an app to see a variable value during app execution, and change the color theme.

To get started, download Visual Studio and install it on your system. The modular installer enables you to choose and install workloads, which are groups of features needed for the programming language or platform you prefer. To follow the steps for creating a program, be sure to select the .NET Core cross-platform development workload during installation.

When you open Visual Studio for the first time, you can sign in by using your Microsoft account or your work or school account.

Create a program

Dive in and create a simple program.

Open Visual Studio.

On the menu bar, choose File > New > Project.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoftNew Project on the menu bar.» data-linktype=»relative-path»>

The New Project dialog box shows several project templates. A template contains the basic files and settings needed for a given project type.

Choose the .NET Core template category under Visual C#, and then choose the Console App (.NET Core) template. In the Name text box, type HelloWorld, and then select the OK button.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

If you don’t see the .NET Core category, you need to install the .NET Core cross-platform development workload. To do this, choose the Open Visual Studio Installer link on the bottom left of the New Project dialog. After Visual Studio Installer opens, scroll down and select the .NET Core cross-platform development workload, and then select Modify.

Visual Studio creates the project. It’s a simple «Hello World» application that calls the Console.WriteLine() method to display the literal string «Hello World!» in the console (program output) window.

Shortly, you should see something like the following screen:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The C# code for your application shows in the editor window, which takes up most of the space. Notice that the text is automatically colorized to indicate different parts of the code, such as keywords and types. In addition, small, vertical dashed lines in the code indicate which braces match one another, and line numbers help you locate code later. You can choose the small, boxed minus signs to collapse or expand blocks of code. This code outlining feature lets you hide code you don’t need, helping to minimize onscreen clutter. The project files are listed on the right side in a window called Solution Explorer.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

There are other menus and tool windows available, but let’s move on for now.

Now, start the app. You can do this by choosing Start Without Debugging from the Debug menu on the menu bar. You can also press Ctrl+F5.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoftStart without debugging menu.» data-linktype=»relative-path»>

Visual Studio builds the app, and a console window opens with the message Hello World!. You now have a running app!

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To close the console window, press any key on your keyboard.

Let’s add some more code to the app. Add the following C# code before the line that says Console.WriteLine(«Hello World!»); :

This code displays What is your name? in the console window, and then waits until the user enters some text followed by the Enter key.

Change the line that says Console.WriteLine(«Hello World!»); to the following code:

Run the app again by selecting Debug > Start Without Debugging or by pressing Ctrl+F5.

Visual Studio rebuilds the app, and a console window opens and prompts you for your name.

Enter your name in the console window and press Enter.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Press any key to close the console window and stop the running program.

Use refactoring and IntelliSense

Let’s look at a couple of the ways that refactoring and IntelliSense can help you code more efficiently.

First, rename the name variable:

Double-click the name variable, and type the new name for the variable, username.

A box appears around the variable, and a light bulb appears in the margin.

Select the light bulb icon to show the available Quick Actions. Select Rename ‘name’ to ‘username’.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The variable is renamed across the project, which in our case is only two places.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

A box displays the members of the DateTime class. The description of the currently selected member also displays in a separate box.

Below that line, enter the following lines of code:

Console.Write is different from Console.WriteLine in that it doesn’t add a line terminator after it prints. That means that the next piece of text that’s sent to the output will print on the same line. You can hover over each of these methods in your code to see their descriptions.

Select the screwdriver icon to see available suggestions from Visual Studio. This case shows the Inline temporary variable refactoring to remove a line of code without changing the overall code behavior.

Select Inline temporary variable to refactor the code.

Run the program again by pressing Ctrl+F5. The output looks something like this:

Debug code

When you write code, you should run it and test it for bugs. Visual Studio’s debugging system lets you step through code one statement at a time and inspect variables as you go. You can set breakpoints that stop execution of the code at a particular line, and observe how the variable value changes as the code runs.

Set a breakpoint to see the value of the username variable while the program is running.

Set a breakpoint on the line of code that says Console.WriteLine($»\nHello !»); by clicking in the far-left margin, or gutter, next to the line. You can also select the line of code and then press F9.

A red circle appears in the gutter, and the line is highlighted.

Start debugging by selecting Debug > Start Debugging or pressing F5.

When the console window appears and asks for your name, enter your name.

The focus returns to the Visual Studio code editor, and the line of code with the breakpoint is highlighted in yellow. The yellow highlight means that this line of code will execute next. The breakpoint makes the app pause execution at this line.

Hover your mouse over the username variable to see its value. You can also right-click on username and select Add Watch to add the variable to the Watch window, where you can also see its value.

Press F5 again to finish running the app.

For more information about debugging in Visual Studio, see the Debugger feature tour.

Customize Visual Studio

You can personalize the Visual Studio user interface, including changing the default color theme. To change the color theme:

On the menu bar, choose Tools > Options to open the Options dialog.

On the Environment > General options page, change the Color theme selection to Dark, and then choose OK.

The color theme for the entire IDE changes to Dark.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To learn about other ways you can personalize the IDE, see Personalize Visual Studio.

Next steps

Explore Visual Studio further by following along with one of these introductory articles:

Cover the basics in this Learn module: Introduction to Visual Studio.

Get acquainted with the code editor in Learn to use the code editor.

Learn how Visual Studio organizes code in Learn about projects and solutions.

If you’re ready to dive into more coding, one of the following language-specific quickstarts is a good next step:

Another good place to start with coding is a tutorial:

Welcome to the Visual Studio IDE

An integrated development environment (IDE) is a feature-rich program that supports many aspects of software development. The Visual Studio IDE is a creative launching pad that you can use to edit, debug, and build code, and then publish an app. Over and above the standard editor and debugger that most IDEs provide, Visual Studio includes compilers, code completion tools, graphical designers, and many more features to enhance the software development process.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The preceding image shows Visual Studio with an open project that shows key windows and their functionality:

In Solution Explorer, at upper right, you can view, navigate, and manage your code files. Solution Explorer can help organize your code by grouping the files into solutions and projects.

The central editor window, where you’ll probably spend most of your time, displays file contents. In the editor window, you can edit code or design a user interface such as a window with buttons and text boxes.

In Git Changes at lower right, you can track work items and share code with others by using version control technologies like Git and GitHub.

Editions

Visual Studio is available for Windows and Mac. Visual Studio for Mac has many of the same features as Visual Studio for Windows, and is optimized for developing cross-platform and mobile apps. This article focuses on the Windows version of Visual Studio.

There are three editions of Visual Studio: Community, Professional, and Enterprise. See Compare Visual Studio editions to learn about which features are supported in each edition.

Popular productivity features

Some popular features in Visual Studio that improve your productivity when developing software include:

Squiggles are wavy underlines that alert you to errors or potential problems in your code as you type. These visual clues help you fix problems immediately, without waiting to discover errors during build or runtime. If you hover over a squiggle, you see more information about the error. A lightbulb might also appear in the left margin showing Quick Actions you can take to fix the error.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Refactoring includes operations such as intelligent renaming of variables, extracting one or more lines of code into a new method, and changing the order of method parameters.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

IntelliSense is a set of features that display information about your code directly in the editor and, in some cases, write small bits of code for you. It’s like having basic documentation inline in the editor, so you don’t have to look up type information elsewhere.

The following illustration shows how IntelliSense displays a member list for a type:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual Studio menus, options, and properties can seem overwhelming at times. Visual Studio search, or Ctrl+Q, is a great way to rapidly find IDE features and code in one place.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

For information and productivity tips, see How to use Visual Studio search.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

For information and productivity tips, see How to use Visual Studio search.

Collaboratively edit and debug with others in real time, regardless of your app type or programming language. You can instantly and securely share your project. You can also share debugging sessions, terminal instances, localhost web apps, voice calls, and more.

The Call Hierarchy window shows the methods that call a selected method. This information can be useful when you’re thinking about changing or removing the method, or when you’re trying to track down a bug.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

CodeLens helps you find code references, code changes, linked bugs, work items, code reviews, and unit tests, without leaving the editor.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The Go To Definition feature takes you directly to the location of a function or type definition.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The Peek Definition window shows a method or type definition without opening a separate file.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Install Visual Studio

In this section, you create a simple project to try out some of the things you can do with Visual Studio. You use IntelliSense as a coding aid, debug an app to see a variable value during app execution, and change the color theme.

To get started, download Visual Studio and install it on your system. The modular installer enables you to choose and install workloads, which are groups of features needed for the programming languages or platforms you want. To follow the steps to create a program, be sure to select the .NET Core cross-platform development workload during installation.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To get started, download Visual Studio and install it on your system. In the modular installer, you choose and install workloads, which are groups of features you need for the programming languages or platforms you want. To use the following steps to create a program, be sure to select the .NET desktop development workload during installation.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

When you open Visual Studio for the first time, you can sign in by using your Microsoft account or your work or school account.

Create a program

Dive in and create a simple program.

Open Visual Studio.

The start window appears with options for cloning a repo, opening a recent project, or creating a new project.

Choose Create a new project.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The Create a new project window opens and shows several project templates. A template contains the basic files and settings required for a given project type.

To find the template we want, type or enter .net core console in the search box. The list of available templates is automatically filtered based on the keywords you entered. You can further filter the template results by choosing C# from the All language drop-down list, Windows from the All platforms list, and Console from the All project types list.

Select the Console Application template, and then click Next.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In the Configure your new project window, enter HelloWorld in the Project name box, optionally change the directory location for your project files (the default locale is C:\Users\ \source\repos ), and then click Next.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In the Additional information window, verify that .NET Core 3.1 appears in the Target Framework drop-down menu, and then click Create.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual Studio creates the project. It’s a simple «Hello World» application that calls the Console.WriteLine() method to display the literal string «Hello World!» in the console (program output) window.

Shortly, you should see something like the following screen:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The C# code for your application shows in the editor window, which takes up most of the space. Notice that the text is automatically colorized to indicate different parts of the code, such as keywords and types. In addition, small, vertical dashed lines in the code indicate which braces match one another, and line numbers help you locate code later. You can choose the small, boxed minus signs to collapse or expand blocks of code. This code outlining feature lets you hide code you don’t need, helping to minimize onscreen clutter. The project files are listed on the right side in a window called Solution Explorer.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

There are other menus and tool windows available, but let’s move on for now.

Now, start the app. You can do this by choosing Start Without Debugging from the Debug menu on the menu bar. You can also press Ctrl+F5.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoftStart without Debugging menu item.» data-linktype=»relative-path»>

Visual Studio builds the app, and a console window opens with the message Hello World!. You now have a running app!

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To close the console window, press any key on your keyboard.

Let’s add some more code to the app. Add the following C# code before the line that says Console.WriteLine(«Hello World!»); :

This code displays What is your name? in the console window, and then waits until the user enters some text followed by the Enter key.

Change the line that says Console.WriteLine(«Hello World!»); to the following code:

Run the app again by selecting Debug > Start Without Debugging or by pressing Ctrl+F5.

Visual Studio rebuilds the app, and a console window opens and prompts you for your name.

Enter your name in the console window and press Enter.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Press any key to close the console window and stop the running program.

Start Visual Studio. The start window appears with options for cloning a repo, opening a recent project, or creating a new project.

Choose Create a new project.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The Create a new project window opens and shows several project templates. A template contains the basic files and settings required for a given project type.

To find a template, you can type or enter keywords in the search box. The list of available templates filters based on the keywords you enter. You can further filter the template results by choosing C# from the All languages dropdown list, Windows from the All platforms list, and Console from the All project types list.

Select the Console Application template, and then select Next.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In the Configure your new project window, enter HelloWorld in the Project name box. Optionally, change the project directory location from the default location of C:\Users\ \source\repos, and then select Next.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In the Additional information window, verify that .NET 6.0 appears in the Target Framework drop-down menu, and then select Create.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual Studio creates the project. The program is a simple «Hello World» application that calls the Console.WriteLine() method to display the string Hello, World! in a console window.

The project files appear on the right side of the Visual Studio IDE, in a window called the Solution Explorer. In the Solution Explorer window, select the Program.cs file. The C# code for your app opens in the central editor window, which takes up most of the space.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The code is automatically colorized to indicate different parts, such as keywords and types. Line numbers help you locate code.

Small, vertical dashed lines in the code indicate which braces match one another. You can also choose small, boxed minus or plus signs to collapse or expand blocks of code. This code outlining feature lets you hide code you don’t need to see, helping to minimize onscreen clutter.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Many other menus and tool windows are available.

Start the app by choosing Debug > Start Without Debugging from the Visual Studio top menu. You can also press Ctrl+F5.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoftStart without Debugging menu item.» data-linktype=»relative-path»>

Visual Studio builds the app, and a console window opens with the message Hello, World!. You now have a running app!

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To close the console window, press any key.

Let’s add some more code to the app. Add the following C# code before the line that says Console.WriteLine(«Hello World!»); :

This code displays What is your name? in the console window, and then waits until the user enters some text.

Change the line that says Console.WriteLine(«Hello World!»); to the following line:

Run the app again by selecting Debug > Start Without Debugging or pressing Ctrl+F5.

Visual Studio rebuilds the app, and a console window opens and prompts you for your name.

Type your name in the console window and press Enter.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Press any key to close the console window and stop the running program.

Use refactoring and IntelliSense

Let’s look at a couple of the ways that refactoring and IntelliSense can help you code more efficiently.

First, rename the name variable:

Double-click the name variable, and type the new name for the variable, username.

A box appears around the variable, and a light bulb appears in the margin.

Select the light bulb icon to show the available Quick Actions. Select Rename ‘name’ to ‘username’.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The variable is renamed across the project, which in our case is only two places.

A box displays the members of the DateTime class. The description of the currently selected member also displays in a separate box.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Below that line, enter the following lines of code:

Console.Write is different from Console.WriteLine in that it doesn’t add a line terminator after it prints. That means that the next piece of text that’s sent to the output will print on the same line. You can hover over each of these methods in your code to see their descriptions.

Select the screwdriver icon to see available suggestions from Visual Studio. This case shows the Inline temporary variable refactoring to remove a line of code without changing the overall code behavior.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Select Inline temporary variable to refactor the code.

Run the program again by pressing Ctrl+F5. The output looks something like this:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Debug code

When you write code, you should run it and test it for bugs. Visual Studio’s debugging system lets you step through code one statement at a time and inspect variables as you go. You can set breakpoints that stop execution of the code at a particular line, and observe how the variable value changes as the code runs.

Set a breakpoint to see the value of the username variable while the program is running.

Set a breakpoint on the line of code that says Console.WriteLine($»\nHello !»); by clicking in the far-left margin, or gutter, next to the line. You can also select the line of code and then press F9.

A red circle appears in the gutter, and the line is highlighted.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Start debugging by selecting Debug > Start Debugging or pressing F5.

When the console window appears and asks for your name, enter your name.

The focus returns to the Visual Studio code editor, and the line of code with the breakpoint is highlighted in yellow. The yellow highlight means that this line of code will execute next. The breakpoint makes the app pause execution at this line.

Hover your mouse over the username variable to see its value. You can also right-click on username and select Add Watch to add the variable to the Watch window, where you can also see its value.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Press F5 again to finish running the app.

For more information about debugging in Visual Studio, see the Debugger feature tour.

Customize Visual Studio

You can personalize the Visual Studio user interface, including changing the default color theme. To change the color theme:

On the menu bar, choose Tools > Options to open the Options dialog.

On the Environment > General options page, change the Color theme selection to Dark, and then choose OK.

The color theme for the entire IDE changes to Dark.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

On the menu bar, choose Tools > Options to open the Options dialog.

On the Environment > General options page, change the Color Theme selection to Blue or Light, and then select OK.

The color theme for the entire IDE changes accordingly. The following screenshot shows the Blue theme:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To learn about other ways you can personalize the IDE, see Personalize Visual Studio.

Next steps

Explore Visual Studio further by following along with one of these introductory articles:

Cover the basics in this Learn module: Introduction to Visual Studio.

Get acquainted with the code editor in Learn to use the code editor.

Learn how Visual Studio organizes code in Learn about projects and solutions.

If you’re ready to dive into more coding, one of the following language-specific quickstarts is a good next step:

Another good place to start with coding is a tutorial:

Welcome to the Visual Studio IDE | Visual Basic

An integrated development environment (IDE) is a feature-rich program that supports many aspects of software development. The Visual Studio IDE is a creative launching pad that you can use to edit, debug, and build code, and then publish an app. Over and above the standard editor and debugger that most IDEs provide, Visual Studio includes compilers, code completion tools, graphical designers, and many more features to enhance the software development process.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The preceding image shows Visual Studio with an open Visual Basic project that shows key windows and their functionality:

In Solution Explorer, at upper right, you can view, navigate, and manage your code files. Solution Explorer can help organize your code by grouping the files into solutions and projects.

The central editor window, where you’ll probably spend most of your time, displays file contents. In the editor window, you can edit code or design a user interface such as a window with buttons and text boxes.

Editions

Visual Studio is available for Windows and Mac. Visual Studio for Mac has many of the same features as Visual Studio for Windows, and is optimized for developing cross-platform and mobile apps. This article focuses on the Windows version of Visual Studio.

There are three editions of Visual Studio: Community, Professional, and Enterprise. See Compare Visual Studio editions to learn about which features each edition supports.

Popular productivity features

Some popular features in Visual Studio that improve your productivity when developing software include:

Squiggles are wavy underlines that alert you to errors or potential problems in your code as you type. These visual clues help you fix problems immediately, without waiting to discover errors during build or runtime. If you hover over a squiggle, you see more information about the error. A lightbulb might also appear in the left margin showing Quick Actions you can take to fix the error.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Refactoring includes operations such as intelligent renaming of variables, extracting one or more lines of code into a new method, and changing the order of method parameters.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

IntelliSense is a set of features that display information about your code directly in the editor and, in some cases, write small bits of code for you. It’s like having basic documentation inline in the editor, so you don’t have to look up type information elsewhere.

The following illustration shows how IntelliSense displays a member list for a type:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual Studio menus, options, and properties can seem overwhelming at times. Visual Studio search, or Ctrl+Q, is a great way to rapidly find IDE features and code in one place.

When you start typing the name of something you’re looking for, Visual Studio lists results that take you where you need to go. If you need to add functionality, for example another programming language, you can open the Visual Studio Installer from the search box results to install the workload or component.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Collaboratively edit and debug with others in real time, regardless of your app type or programming language. You can instantly and securely share your project. You can also share debugging sessions, terminal instances, localhost web apps, voice calls, and more.

The Call Hierarchy window shows the methods that call a selected method. This information can be useful when you’re thinking about changing or removing the method, or when you’re trying to track down a bug.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

CodeLens helps you find code references, code changes, linked bugs, work items, code reviews, and unit tests, without leaving the editor.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The Go To Definition feature takes you directly to the location of a function or type definition.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The Peek Definition window shows a method or type definition without opening a separate file.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Install Visual Studio

In this section, you create a simple project to try out some of the things you can do with Visual Studio. You learn how to change the color theme, use IntelliSense as a coding aid, and debug an app to see a variable value during app execution.

To get started, download Visual Studio and install it on your system. The modular installer enables you to select and install workloads, which are groups of features needed for the programming language or platform you prefer. To follow the steps for creating a program, be sure to select the .NET Core cross-platform development workload during installation.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To get started, download Visual Studio and install it on your system. In the modular installer, you choose and install workloads, which are groups of features you need for the programming languages or platforms you want. To use the following steps to create a program, be sure to select the .NET desktop development workload during installation.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

When you open Visual Studio for the first time, you can sign in by using your Microsoft account or your work or school account.

Customize Visual Studio

You can personalize the Visual Studio user interface, including changing the default color theme.

Change the color theme

To change the color theme:

Open Visual Studio. On the start window, select Continue without code.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

On the Visual Studio menu bar, choose Tools > Options to open the Options dialog.

On the Environment > General options page, change the Color theme selection to Dark, and then choose OK.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The color theme for the entire IDE changes to Dark.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Open Visual Studio. On the start window, select Continue without code.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

On the Visual Studio menu bar, choose Tools > Options to open the Options dialog.

On the Environment > General options page, change the Color Theme selection to Blue or Light, and then select OK.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The color theme for the entire IDE changes accordingly. The following screenshot shows the Blue theme:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Select environment settings

You can configure Visual Studio to use environment settings tailored to Visual Basic developers.

On the menu bar, choose Tools > Import and Export Settings.

In the Import and Export Settings Wizard, select Reset all settings, and then select Next.

On the Save Current Settings page, select whether to save your current settings before resetting. If you haven’t customized any settings, select No, just reset settings, overwriting my current settings. Then select Next.

On the Choose a Default Collection of Settings page, choose Visual Basic, and then select Finish.

On the Reset Complete page, select Close.

To learn about other ways you can personalize the IDE, see Personalize Visual Studio.

Create a program

Dive in and create a simple program.

On the Visual Studio menu bar, choose File > New > Project. (Alternatively, press Ctrl+Shift+N.)

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoftNew > Project selection from the Visual Studio 2019 menu bar.» data-linktype=»relative-path»>

The Create a new project window opens and shows several project templates. A template contains the basic files and settings required for a given project type.

To find the template we want, type or enter .net core console in the search box. The list of available templates is automatically filtered based on the keywords you entered. You can further filter the template results by choosing Visual Basic from the All language drop-down list, Windows from the All platforms list, and Console from the All project types list.

Select the Console Application template, and then click Next.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In the Configure your new project window, enter HelloWorld in the Project name box, optionally change the directory location for your project files (the default locale is C:\Users\ \source\repos ), and then click Next.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In the Additional information window, verify that .NET Core 3.1 appears in the Target Framework drop-down menu, and then click Create.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual Studio creates the project. It’s a simple «Hello World» application that calls the Console.WriteLine() method to display the literal string «Hello World!» in the console (program output) window.

Shortly, you should see something like the following:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The Visual Basic code for the app appears in the editor window, which takes up most of the space. Notice that the text is automatically colorized to indicate different parts of the code, such as keywords and types. In addition, small, vertical dashed lines in the code indicate which braces match one another, and line numbers help you locate code later. You can choose the small, boxed minus signs to collapse or expand blocks of code. This code outlining feature lets you hide code you don’t need, helping to minimize onscreen clutter. The project files are listed on the right side in a window called Solution Explorer.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

There are other menus and tool windows available, but let’s move on for now.

Now, start the app. You can do this by choosing Start Without Debugging from the Debug menu on the menu bar. You can also press Ctrl+F5.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoftStart without debugging.» data-linktype=»relative-path»>

Visual Studio builds the app, and a console window opens with the message Hello World!. You now have a running app!

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To close the console window, press any key on your keyboard.

Let’s add some additional code to the app. Add the following Visual Basic code before the line that says Console.WriteLine(«Hello World!») :

This code displays What is your name? in the console window, and then waits until the user enters some text followed by the Enter key.

Change the line that says Console.WriteLine(«Hello World!») to the following code:

Run the app again by pressing Ctrl+F5.

Visual Studio rebuilds the app, and a console window opens and prompts you for your name.

Enter your name in the console window and press Enter.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Press any key to close the console window and stop the running program.

On the Visual Studio menu bar, choose File > New > Project. You can also press Ctrl+Shift+N.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoftNew > Project selection from the Visual Studio menu bar.» data-linktype=»relative-path»>

The Create a new project window opens and shows several project templates. A template contains the basic files and settings that a given project type requires.

To find a template, you can type or enter keywords in the search box. The list of available templates filters based on the keywords you enter. You can further filter the template results by choosing Visual Basic from the All languages dropdown list, Windows from the All platforms list, and Console from the All project types list.

Select the Visual Basic Console Application template, and then select Next.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In the Configure your new project window, enter HelloWorld in the Project name box. Optionally, change the project directory location from the default location of C:\Users\ \source\repos, and then select Next.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

In the Additional information window, verify that .NET 6.0 appears in the Target Framework drop-down menu, and then select Create.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual Studio creates the project. The program is a simple «Hello World» application that calls the Console.WriteLine() method to display the string Hello, World! in a console window.

The project files appear on the right side of the Visual Studio IDE, in a window called the Solution Explorer. In the Solution Explorer window, select the Program.vb file. The Visual Basic code for the app opens in the central editor window, which takes up most of the space.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The code is automatically colorized to indicate different parts, such as keywords and types. Line numbers help you locate code.

Small, vertical dashed lines in the code indicate code structure or code blocks that go together. You can also select the small, boxed minus or plus signs to collapse or expand blocks of code. This code outlining feature lets you hide code you don’t need to see, helping to minimize onscreen clutter.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Many other menus and tool windows are available.

Start the app by choosing Debug > Start Without Debugging from the Visual Studio top menu. You can also press Ctrl+F5.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoftStart without Debugging menu item.» data-linktype=»relative-path»>

Visual Studio builds the app, and a console window opens with the message Hello World!. You now have a running app!

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

To close the console window, press any key.

Let’s add more code to the app. Add the following Visual Basic code before the line that says Console.WriteLine(«Hello World!») :

This code displays What is your name? in the console window, and then waits until the user enters some text.

Change the line that says Console.WriteLine(«Hello World!») to the following line:

Run the app again by selecting Debug > Start Without Debugging or pressing Ctrl+F5.

Visual Studio rebuilds the app, and a console window opens and prompts you for your name.

Type your name in the console window and press Enter.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Press any key to close the console window and stop the running program.

Use refactoring and IntelliSense

Let’s look at a couple of the ways that refactoring and IntelliSense can help you code more efficiently.

First, rename the name variable:

Double-click the name variable, and type the new name for the variable, username.

A box appears around the variable, and a light bulb appears in the margin.

Select the lightbulb icon to show the available Quick Actions. Select Rename ‘name’ to ‘username’.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

The variable renames across the project, which in this case is only two places.

Now take a look at IntelliSense.

A box displays the members of the DateTime class. The description of the currently selected member also displays in a separate box.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Choose the member named Now, which is a property of the class. Either double-click on Now, or select it and press Tab.

Below that line, enter the following lines of code:

Console.Write is different from Console.WriteLine in that it doesn’t add a line terminator after it prints. That means that the next piece of text that’s sent to the output will print on the same line. You can hover over each of these methods in your code to see their descriptions.

Next, use refactoring again to make the code a little more concise.

Select the screwdriver icon to see available suggestions from Visual Studio. This case shows the Inline temporary variable refactoring to remove a line of code without changing the overall code behavior.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Select Inline temporary variable to refactor the code.

Run the program again by pressing Ctrl+F5. The output looks something like this:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Select the lightbulb icon to see available suggestions from Visual Studio. This case shows the Inline temporary variable refactoring to remove a line of code without changing the overall code behavior.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Select Inline temporary variable to refactor the code.

Run the program again by pressing Ctrl+F5. The output looks something like this:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Debug code

When you write code, you should run it and test it for bugs. Visual Studio’s debugging system lets you step through code one statement at a time and inspect variables as you go. You can set breakpoints that stop execution of the code at a particular line, and observe how the variable value changes as the code runs.

Set a breakpoint to see the value of the username variable while the program is running.

Set a breakpoint on the line of code that says Console.WriteLine(«Hello » + username + «!») by clicking in the far-left margin, or gutter, next to the line. You can also select the line of code and then press F9.

A red circle appears in the gutter, and the line is highlighted.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Start debugging by selecting Debug > Start Debugging or pressing F5.

When the console window appears and asks for your name, enter your name.

The focus returns to the Visual Studio code editor, and the line of code with the breakpoint is highlighted in yellow. The yellow highlight means that this line of code will execute next. The breakpoint makes the app pause execution at this line.

Hover your mouse over the username variable to see its value. You can also right-click on username and select Add Watch to add the variable to the Watch window, where you can also see its value.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Press F5 again to finish running the app.

For more information about debugging in Visual Studio, see the Debugger feature tour.

Next steps

Explore Visual Studio further by following along with one of these introductory articles:

Code editing. Redefined.

Free. Built on open source. Runs everywhere.

By using VS Code, you agree to its license and privacy statement.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Meet IntelliSense.

Go beyond syntax highlighting and autocomplete with IntelliSense, which provides smart completions based on variable types, function definitions, and imported modules.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Print statement debugging is a thing of the past.

Debug code right from the editor. Launch or attach to your running apps and debug with break points, call stacks, and an interactive console.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Git commands built-in.

Working with Git and other SCM providers has never been easier. Review diffs, stage files, and make commits right from the editor. Push and pull from any hosted SCM service.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Extensible and customizable.

Want even more features? Install extensions to add new languages, themes, debuggers, and to connect to additional services. Extensions run in separate processes, ensuring they won’t slow down your editor. Learn more about extensions.

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Deploy with confidence and ease

With Microsoft Azure you can deploy and host your React, Angular, Vue, Node, Python (and more!) sites, store and query relational and document based data, and scale with serverless computing, all with ease, all from within VS Code.

VS Code for

Want new features sooner?

Use vscode.dev for quick edits online!

GitHub, Azure Repos, and local files.

License and Privacy Terms

By downloading and using Visual Studio Code, you agree to the license terms and privacy statement. VS Code automatically sends telemetry data and crash dumps to help us improve the product. If you would prefer not to have this data sent please go see How to Disable Crash Reporting to learn how to disable it.

Productivity guide for Visual Studio

If you want to save time while you’re writing code, you’re in the right place. This productivity guide includes tips that can help you get started with Visual Studio, write code, debug code, handle errors, and use keyboard shortcuts—all on one page.

For information about helpful keyboard shortcuts, see Productivity shortcuts. For a complete list of command shortcuts, see Default keyboard shortcuts.

Get started

Save time digging through menus by quickly searching for anything you need, including commands, settings, documentation, and install options. See keyboard shortcuts for commands within your search results in Visual Studio so you can memorize them more easily.

Use Solution Explorer shortcuts. If you’re new to Visual Studio, these shortcuts will come in handy and save you time while you’re coming up to speed on a new codebase. For the full list of shortcuts, see Default keyboard shortcuts in Visual Studio.

Identify and customize keyboard shortcuts in Visual Studio. You can identify keyboard shortcuts for Visual Studio commands, customize those shortcuts, and export them for others to use. You can always find and change a keyboard shortcut in the Options dialog box.

Make Visual Studio more accessible. Visual Studio has built-in accessibility features that are compatible with screen readers and other assistive technologies. See Accessibility tips and tricks for Visual Studio for the full list of available features.

Check out the Visual Studio Product Lifecycle and Servicing. For information on how to get updates for Visual Studio, support options for Enterprise and Professional customers, support for older versions of Visual Studio, and components not covered by Visual Studio servicing, see Visual Studio Product Lifecycle and Servicing.

Install and manage NuGet packages in Visual Studio. The NuGet Package Manager UI in Visual Studio on Windows allows you to easily install, uninstall, and update NuGet packages in projects and solutions. For more information, see Install and manage packages in Visual Studio using the NuGet Package Manager.

Write code

Write code more quickly by using the following features.

Use convenience commands. Visual Studio contains various commands to help you accomplish common editing tasks faster. For example, you can choose a command to easily duplicate a line of code without having to copy it, reposition the cursor, and then paste it. Choose Edit > Duplicate or press Ctrl+E,V. You can also quickly expand or contract a selection of text by choosing Edit > Advanced > Expand Selection or Edit > Advanced > Contract Selection, or by pressing Shift+Alt+= or Shift+Alt+.

Use IntelliSense. As you enter code in the editor, IntelliSense information, such as List Members, Parameter Info, Quick Info, Signature Help, and Complete Word, appears. These features support fuzzy matching of text; for example, the results lists for List Members include not only entries that start with the characters that you have entered but also entries that contain the character combination anywhere in their names. For more information, see Use IntelliSense.

Change auto-insertion of IntelliSense options as you enter code. By switching IntelliSense to suggestion mode, you can specify that IntelliSense options are inserted only if you explicitly choose them.

To enable suggestion mode, choose the Ctrl+Alt+Spacebar keys, or, on the menu bar, choose Edit > IntelliSense > Toggle Completion Mode.

Use code snippets. You can use built-in snippets, or create your own snippets.

To insert a snippet, on the menu bar, choose Edit > IntelliSense > Insert Snippet or Surround With, or open the shortcut menu in a file and choose Snippet > Insert Snippet or Surround With. For more information, see Code Snippets.

Show and edit the definition of a code element. You can quickly show and edit the module in which a code element, such as a member, a variable, or a local, is defined.

To open a definition in a pop-up window, highlight the element and then choose the Alt+F12 keys, or open the shortcut menu for the element and then choose Peek Definition. To open a definition in a separate code window, open the shortcut menu for the element, and then choose Go to Definition.

Use sample applications. You can speed up application development by downloading and installing sample applications from Microsoft Developer Network. You can also learn a particular technology or programming concept by downloading and exploring a Sample Pack for that area.

Change brace formatting with Formatting/New Lines. Use the Formatting options page to set options for formatting code in the code editor, including new lines. For more information on how to use this setting in C#, see Options dialog box: Text Editor > C# > Code Style > Formatting. For C++, see Set your C++ coding preferences in Visual Studio. For Python, see Format Python code.

Change your indentation with Tabs. Use custom editor settings, tailored to each codebase, to enforce consistent coding styles for multiple developers working on the same project across different editors and IDEs. Ensure your whole team follows the same language conventions, naming conventions, and formatting rules. Since these custom settings are portable and travel with your code, you can enforce coding styles even outside of Visual Studio. For more information, see Options, Text Editor, All Languages, Tabs.

Navigate within your code and the IDE

You can use various techniques to find and move to specific locations in your code more quickly. You can also change the layout of your Visual Studio windows based on your preferences.

Bookmark lines of code. You can use bookmarks to navigate quickly to specific lines of code in a file.

To set a bookmark, on the menu bar, choose Edit > Bookmarks > Toggle Bookmark. You can view all of the bookmarks for a solution in the Bookmarks window. For more information, see Set bookmarks in code.

Search for symbol definitions in a file. You can search within a solution to locate symbol definitions and file names, but search results don’t include namespaces or local variables.

To access this feature, on the menu bar, choose Edit > Navigate To.

Browse the overall structure of your code. In Solution Explorer, you can search and browse classes and their types and members in your projects. You can also search for symbols, view a method’s Call Hierarchy, find symbol references, and perform other tasks. If you choose a code element in Solution Explorer, the associated file opens in a Preview tab, and the cursor moves to the element in the file. For more information, see View the structure of code.

Jump to a location in a file with map mode. Map mode displays lines of code, in miniature, on the scroll bar. For more information about this display mode, see How to: Customize the scroll bar.

Understand your code structure with code map. Code maps can help you visualize dependencies across your code, and see how it fits together without reading through files and lines of code. For more information, see Map dependencies with code maps.

See frequently used files with Edit/Go to Recent File. Use the Go To commands in Visual Studio to perform a focused search of your code to help you quickly find specified items. For detailed instructions, see Find code using Go To commands.

Move the Properties window to the right-hand side. If you’re looking for a more familiar window layout, you can move the Properties window in Visual Studio by pressing F4.

Find items faster

You can search across the IDE for commands, files, and options, in addition to filtering the contents of tool windows to show only relevant information for your current task.

Filter the contents of tool windows. You can search within the contents of many tool windows, such as the Toolbox, the Properties window, and Solution Explorer, but display only items whose names contain the characters that you specify.

Display only the errors you want to address. If you choose the Filter button on the Error List toolbar, you can reduce the number of errors that appear in the Error List window. You can display only the errors in the files that are open in the editor, only the errors in the current file, or only the errors in the current project. You can also search within the Error List window to find specific errors.

Find dialog boxes, menu commands, options, and more. In the search box, enter keywords or phrases for the items that you’re trying to find. For example, the following options appear if you enter new project:

Visual studio code microsoft. Смотреть фото Visual studio code microsoft. Смотреть картинку Visual studio code microsoft. Картинка про Visual studio code microsoft. Фото Visual studio code microsoft

Press Ctrl+Q to jump straight to the search box.

Debug code

Debugging can consume a lot of time, but the following tips can help you speed up the process.

Use the Visual Studio debugger tools. In the Visual Studio context, when you debug your app, it usually means that you are running the application in debugger mode. The debugger provides many ways to see what your code is doing while it runs. See First look at the Visual Studio Debugger for a guide to getting started.

Set temporary breakpoints. You can create a temporary breakpoint in the current line of code and start the debugger simultaneously. When you hit that line of code, the debugger enters break mode. For more information, see Navigate through code with the debugger.

To use this feature, choose the Ctrl+F10 keys, or open the shortcut menu for the line of code on which you want to break, and then choose Run To Cursor.

Move the execution point during debugging. You can move the current execution point to a different section of code and then restart debugging from that point. This technique is useful if you want to debug a section of code without having to recreate all of the steps that are required to reach that section. For more information, see Navigate through code with the debugger.

To move the execution point, drag the yellow arrowhead to a location where you want to set the next statement in the same source file, and then choose the F5 key to continue debugging.

Capture value information for variables. You can add a DataTip to a variable in your code and pin it so that you can access the last known value for the variable after debugging has finished. For more information, see View data values in Data Tips.

To add a DataTip, the debugger must be in break mode. Place the cursor on the variable, and then choose the pin button on the DataTip that appears. When debugging is stopped, a blue pin icon appears in the source file next to the line of code that contains the variable. If you point to the blue pin, the value of the variable from the most recent debugging session appears.

Clear the Immediate window. You can erase the contents of the Immediate window at design time by entering >cls or >Edit.ClearAll

For more information about additional commands, see Visual Studio command aliases.

Find code changes and other history with CodeLens. CodeLens lets you stay focused on your work while you find out what happened to your code—without leaving the editor. You can find references to a piece of code, changes to your code, linked bugs, work items, code reviews, and unit tests.

Use Live Share to debug in real time with others. Live Share enables you to collaboratively edit and debug with others in real time, regardless of the programming languages you’re using or app types you’re building. For more information, see What is Visual Studio Live Share?

Use Interactive Window to write and test small code. Visual Studio provides an interactive read-evaluate-print-loop (REPL) window that lets you enter arbitrary code and see immediate results. This way of coding helps you to learn and experiment with APIs and libraries, and to interactively develop working code to include in your projects. For Python, see Work with the Python Interactive window. The Interactive Window feature is also available for C#.

Access Visual Studio tools

You can quickly access the Developer Command Prompt, or another Visual Studio tool, if you pin it to the Start menu or the taskbar.

Manage files, toolbars, and windows

At any one time, you may be working in multiple code files and moving among several tool windows as you develop an application. You can keep organized by using the following tips:

Keep files that you frequently use visible in the editor. You can pin files to the left side of the tab so that they remain visible regardless of how many files are open in the editor.

To pin a file, choose the file’s tab, and then choose the Toggle Pin Status button.

Move documents and windows to other monitors. If you use more than one monitor when you develop applications, you can work on portions of your application more easily by moving files that are open in the editor to another monitor. You can also move tool windows, such as debugger windows, to another monitor and tab dock document and tool windows together to create «rafts.» For more information, see Customize window layouts and personalize tabs in Visual Studio.

You can also manage files more easily by creating another instance of Solution Explorer and moving it to another monitor. To create another instance of Solution Explorer, open a shortcut menu in Solution Explorer, and then choose New Solution Explorer View.

Customize the fonts that appear in Visual Studio. You can change the font face, size, and color that’s used for text in the IDE. For example, you can customize the color of specific code elements in the editor and the font face in tool windows or throughout the IDE. For more information, see How to: Change fonts and colors and How to: Change fonts and colors in the editor.

Источники:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *