From the course: Visual Studio 2019 Essential Training

Explore the code editor windows - Visual Studio Tutorial

From the course: Visual Studio 2019 Essential Training

Start my 1-month free trial

Explore the code editor windows

- [Instructor] I'd like to take a brief tour of the code editor interface in Visual Studio and point out some of the features that help you understand and navigate your code and the subsections of your code. The first step is to open some code files. From my C# project I'll open this CSS file, this XML file, and this Book.cs file. And in my Visual Basic project I'll open Module1.vb. Today I want to explore the navbar feature of the editor window. It's this section right across the top of the editor. If you do not see it, it's enabled in Tools, Options. Choose this All Language General node and then check Navigation bar. Now you should see it. But to be clear, you only see it if the person that wrote this code editor decided to switch on that feature. In the Visual Basic editor I can see it. If I look at this XML file it's not there, and it's not in this CSS file either. But it is in my C# file. So I'll start by looking in the VB file. And let's take a look at the three sections, this left section isn't important for most developers, so I'll focus on the middle and right sections. In the VB file I'm inside a module, all the code that's shown here is inside this module and I've got a main method, and I've got an enumeration declared here. So if you look at the drop-down in the middle of the navbar you'll see the module and you'll see the Tour Type declared. Over in the C# file I've got more than that. Over here they're inside a namespace, that's how you separate types and C# files, by namespaces, and if you look it's ConsoleCSharp, that's the name of the namespace. Now when I go up to this drop-down I can see I've got four entities inside this file and they all are named with the namespace, period, and then the entity. So this first one, what is this? This is a class. Second entity is another class in the same file. Typically you would separate your classes into separate files but I kept them in the same file for this demonstration. The third entity is BookStyle, that looks like it's an enum. And then the fourth one, Genre is also a declaration of an enumeration. So that shows you the quick way of looking at what's inside a file, and it let's me navigate to them. So where you see that when I pick the item like when I pick BookStyle I can nav to it. Now in the newer versions of Visual Studio you can also get there another way. Let's go look at the book class over here in the Solution Explorer. And open this up, and you can see those four items listed below here in the tree view, and it's the same thing if I double-click on BookInfo it takes me to that spot in the file, or double-click on genre. So it's your choice, if you'd rather not use the navbar and use the Solution Explorer that's another way of navigating around. Next let's take a look at what's in this third right-most drop-down. I'll pick the Book class, and then look at this drop-down, and here I can see that there is the Genre, this symbol here means it's a property so I'll select it and I see that that's a property defined inside this class. This is also a property, Price, Info, and Title and then there are two methods defined, GetWordCount and SaveBook. Now again I can do the same thing over here in the Solution Explorer. Open up Book and there's the properties, and there's the two methods. Next we'll go take a look at the BookInfo. That is a class and it has PageCount, Style, and the lightning bolt here means it's an event handler. When I look at the Style, this is an enumeration remember, so when I click on this drop-down I see the enumerated values, so I can go here and take a look and see what Hardcover is, what's the value that's assigned to that enumeration value. Think I can see that over here in Solution Explorer, let's find out. I'm in the wrong spot, I should have opened up BookStyle not BookInfo. There they are. And then finally let's look at Genre. Again I get a list of the enumerated values. So now you know how to look at the members available and the basic code editor window. Watch the next video and I'll explore how Visual Studio chooses which of these editors to open when you edit a file.

Contents