Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Start a free Basic trial
to watch this video
Learn how to use the Solution Explorer to work with the files and folders in your projects and solutions.
Keyboard Shortcuts
Build Solution | Ctrl+Shift+B |
Compile | Ctrl+F7 |
Start | F5 |
Start Without Debugging | Ctrl+F5 |
Restart | Ctrl+Shift+F5 |
Run to Cursor | Ctrl+F10 |
Step Into | F11 |
Step Out | Shift+F11 |
Step Over | F10 |
Stop Debugging | Shift+F5 |
Select All | Ctrl+A |
Select Current Word | Ctrl+W |
Copy | Ctrl+C |
Cut | Ctrl+X |
Copy Entire Line | Ctrl+C |
Cut Entire Line | Ctrl+X |
Paste | Ctrl+V |
Undo | Ctrl+Z |
Redo | Ctrl+Y |
Find | Ctrl+F |
Find All References | Shift+F12 |
Find In Files | Ctrl+Shift+F |
Find Next | F3 |
Find Previous | Shift+F3 |
Replace | Ctrl+H |
Replace in Files | Ctrl+Shift+H |
Hold down shift to hightlight everything between the cursor and where the cursor ends up | |
Go To End of Document | Ctrl+End |
Go To Beginning of Document | Ctrl+Home |
Got To Matching Brace | Ctrl+] |
Go To Next Word | Ctrl+Right |
Go To Previous Word | Ctrl+Left |
Go To Line | Ctrl+G |
Go To Declaration | Ctrl+F12 |
Go To Definition | F12 |
Navigate Backwards | Ctrl+- |
Navigate Forewards | Ctrl+Shift+- |
Next Tab | Ctrl+Alt+Page Down |
Previous Tab | Ctrl+Alt+Page Up |
Quick Launch | Ctrl+Q |
Complete Word | Ctrl+Space |
List Members | Ctrl+J |
Paremeter Info | Ctrl+Shift+Space |
Peek at Definition | Alt+F12 |
Quick Info | Ctrl+K, Ctrl+I |
Close Popup Window | Esc |
Make Lowercase | Ctrl+U |
Make Uppercase | Ctrl+Shift+U |
Move Selected Lines Up | Alt+Up |
Move Selected Lines Down | Alt+Down |
Indent | Tab |
Unindent | Shift+Tab |
Format Document | Ctrl+K, Ctrl+D |
Format Selection | Ctrl+K, Ctrl+F |
Comment Section | Ctrl+K, Ctrl+C |
Uncomment Section | Ctrl+K, Ctrl+U |
Rename | Ctrl+R, Ctrl+R |
Extract Method | Ctrl+R, Ctrl+M |
Remove Parameters | Ctrl+R, Ctrl+V |
Reorder Parameters | Ctrl+R, Ctrl+O |
Zoom In / Zoom Out | Ctrl+Scroll Wheel |
-
0:00
All right, we've now created a console application that both builds and runs.
-
0:04
To run it, just click the green start button here on the toolbar.
-
0:18
The program was compiled, ran, and closed without errors.
-
0:22
Most projects in Visual Studio will work from the very start.
-
0:26
I found that it's nice to start in a working environment
-
0:29
with some simple code that runs.
-
0:31
That's what project templates are all about.
-
0:34
Let's take a closer look at what Visual Studio did when it created our project.
-
0:38
We can check this out by looking at the Solution Explorer.
-
0:41
If you don't see the Solution Explorer pane,
-
0:43
you can bring it back up by clicking on View > Solution Explorer.
-
0:48
Right now we're dealing with a console app.
-
0:51
Most solutions in Visual Studio share this basic structure in the Solution Explorer.
-
0:57
At the highest level there's the solution, below that there are one or more projects.
-
1:02
Within each project there's an area for properties, the list of assemblies or
-
1:06
libraries that your project uses are listed under References.
-
1:10
Below that, there's a list of code files, programmed at CS, which is already shown
-
1:16
in the editor here is the C# code file that contains the code for
-
1:20
the console app.
-
1:21
App.config is a special file that provides the runtime configuration for
-
1:26
the console app.
-
1:27
Notice what happens when I click once on the App.config file.
-
1:32
It's displayed in the editor, but its tab is on the right side of the pane.
-
1:36
If I click AssemblyInfo.cs, the tab is replaced with the contents of that file.
-
1:42
This is a preview, so
-
1:44
whatever is selected in Solution Explorer shows up as a tab here.
-
1:48
Unless that is, if it is already opened as a tab.
-
1:52
I can't tell you how much this preview feature helps keeps the editor
-
1:56
pane cleaned up.
-
1:57
You can open the file as a normal tab by double-clicking on it
-
2:00
in the Solution Explorer or by clicking on this button in the Preview tab.
-
2:05
One thing you'll notice about Visual Studio is there's usually
-
2:08
many ways to perform the same action.
-
2:11
Between the toolbars, menus, context menus, keyboard shortcuts,
-
2:16
search facilities, buttons or links and panes, and other cues that may pop up,
-
2:22
there's often at least four or five different ways to do everything.
-
2:25
For the most part, I'm just going to show you one way.
-
2:29
Part of making an ID your own is picking the methods that work best for
-
2:33
you after you try them out.
-
2:35
I'll also include a list of shortcuts in the teacher's notes that you
-
2:38
might find handy.
-
2:39
Now back to the Solution Explorer.
-
2:41
As you create more and
-
2:42
more files you'll probably want to start organizing them in folders.
-
2:46
You can create a folder by right-clicking on the project name,
-
2:50
clicking on Add in the context menu that pops up and then clicking New Folder.
-
2:55
The new folder appears in the Solution Explorer under that project.
-
3:00
You can give it a name by typing over the highlighted text.
-
3:04
This is also how you add files to your project.
-
3:06
You can add files to the top level of the project or inside the folder.
-
3:11
Just right-click on the folder or project name, mouse over Add, then click New Item.
-
3:17
You can pick the type of file you want to add from a list of templates.
-
3:21
This is very similar to how we created a new project from an existing template.
-
3:26
The file templates are organized into categories on the left side of
-
3:29
the dialog window.
-
3:31
I'm going to add another class to the project, so I'll select Class.
-
3:36
Then I'll give it the name InputHandler.cs, and click add.
-
3:45
The new file is added to the project and opened in the editor window.
-
3:49
Notice that the file already has some boiler plate code in it.
-
3:53
This comes from the file template.
-
3:55
It named the class InputHandler after the name of the file.
-
3:58
Also notice that it put the class in the Treehouse.SimpleConsoleApp.Helpers
-
4:04
namespace.
-
4:05
By convention Visual Studio assumes that code in a folder
-
4:09
should be in its own namespace.
-
4:12
You can also add existing files to the project.
-
4:15
I've placed a file in my Documents folder that I want to add to this project.
-
4:19
To add it, I right-click on the project or
-
4:22
folder that I want to add the file to, then click Add > Existing Item.
-
4:28
This opens an open file dialog,
-
4:30
which I can use to navigate to where my file is located.
-
4:33
By default, because this is a C# project,
-
4:36
that filter down here is only set to show C# files.
-
4:40
If you don't see the file you're looking for, change this to All Files.
-
4:44
Now, I can select my file, and click Add.
-
4:47
A copy of the file is made and placed inside the project.
-
4:50
To get a better idea of what's happening behind the scenes
-
4:53
you can always look at the Windows File Explorer.
-
4:56
And easy way to get there is to right-click on the solution name and
-
4:59
click Open Folder in File Explorer.
-
5:01
This opens the file explorer and shows us the folder that contains the solution.
-
5:07
I'm going to have Windows show us the file name extensions.
-
5:10
There, that's better.
-
5:12
This file here with the .sln extension is the solution file.
-
5:16
This is the file that you click on to open the solution in Visual Studio.
-
5:20
Treehouse.SimpleConsoleApp contains the project.
-
5:25
This contains the actual files that make up the project.
-
5:29
Here's the Program.cs file.
-
5:31
Here's the App.config file.
-
5:33
Here's the folder we created and the C# file that we created in that folder.
-
5:39
This file with the .csproj extension
-
5:42
is the project file that contains all the settings for how to build this project.
-
5:47
We also see the file I copied into the project.
-
5:51
Because Visual Studio is a project-based IDE as opposed to a file system-based IDE,
-
5:56
it expects that you'll be creating, moving, and deleting files and
-
5:59
folders only from within Visual Studio.
-
6:03
It won't automatically pick up changes that happen outside of Visual Studio.
-
6:07
For example, if I delete this file here in the file explorer, and then
-
6:12
go back into Visual Studio, you'll notice that it still has the file on the project.
-
6:17
To get Visual Studio to recognize this change,
-
6:20
we need to delete the file from here.
-
6:24
It's the same with moving and adding files.
-
6:27
You can make changes in the file explorer, but you then need to come back here and
-
6:31
tell the ID about those changes.
-
6:33
In general, it's best to do everything from within Visual Studio
-
6:37
as much as possible.
You need to sign up for Treehouse in order to download course files.
Sign up