This workshop will be retired on May 1, 2025.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses 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 |
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
All right, we've now created a console
application that both builds and runs.
0:00
To run it, just click the green
start button here on the toolbar.
0:04
The program was compiled, ran,
and closed without errors.
0:18
Most projects in Visual Studio
will work from the very start.
0:22
I found that it's nice to
start in a working environment
0:26
with some simple code that runs.
0:29
That's what project
templates are all about.
0:31
Let's take a closer look at what Visual
Studio did when it created our project.
0:34
We can check this out by looking
at the Solution Explorer.
0:38
If you don't see
the Solution Explorer pane,
0:41
you can bring it back up by clicking
on View > Solution Explorer.
0:43
Right now we're dealing
with a console app.
0:48
Most solutions in Visual Studio share this
basic structure in the Solution Explorer.
0:51
At the highest level there's the solution,
below that there are one or more projects.
0:57
Within each project there's an area for
properties, the list of assemblies or
1:02
libraries that your project uses
are listed under References.
1:06
Below that, there's a list of code files,
programmed at CS, which is already shown
1:10
in the editor here is the C# code
file that contains the code for
1:16
the console app.
1:20
App.config is a special file that
provides the runtime configuration for
1:21
the console app.
1:26
Notice what happens when I click
once on the App.config file.
1:27
It's displayed in the editor, but
its tab is on the right side of the pane.
1:32
If I click AssemblyInfo.cs, the tab is
replaced with the contents of that file.
1:36
This is a preview, so
1:42
whatever is selected in Solution Explorer
shows up as a tab here.
1:44
Unless that is,
if it is already opened as a tab.
1:48
I can't tell you how much this
preview feature helps keeps the editor
1:52
pane cleaned up.
1:56
You can open the file as a normal
tab by double-clicking on it
1:57
in the Solution Explorer or by clicking
on this button in the Preview tab.
2:00
One thing you'll notice about
Visual Studio is there's usually
2:05
many ways to perform the same action.
2:08
Between the toolbars, menus,
context menus, keyboard shortcuts,
2:11
search facilities, buttons or links and
panes, and other cues that may pop up,
2:16
there's often at least four or
five different ways to do everything.
2:22
For the most part,
I'm just going to show you one way.
2:25
Part of making an ID your own is
picking the methods that work best for
2:29
you after you try them out.
2:33
I'll also include a list of shortcuts
in the teacher's notes that you
2:35
might find handy.
2:38
Now back to the Solution Explorer.
2:39
As you create more and
2:41
more files you'll probably want to
start organizing them in folders.
2:42
You can create a folder by
right-clicking on the project name,
2:46
clicking on Add in the context menu that
pops up and then clicking New Folder.
2:50
The new folder appears in
the Solution Explorer under that project.
2:55
You can give it a name by typing
over the highlighted text.
3:00
This is also how you add
files to your project.
3:04
You can add files to the top level
of the project or inside the folder.
3:06
Just right-click on the folder or project
name, mouse over Add, then click New Item.
3:11
You can pick the type of file you
want to add from a list of templates.
3:17
This is very similar to how we created
a new project from an existing template.
3:21
The file templates are organized
into categories on the left side of
3:26
the dialog window.
3:29
I'm going to add another class to
the project, so I'll select Class.
3:31
Then I'll give it the name
InputHandler.cs, and click add.
3:36
The new file is added to the project and
opened in the editor window.
3:45
Notice that the file already has
some boiler plate code in it.
3:49
This comes from the file template.
3:53
It named the class InputHandler
after the name of the file.
3:55
Also notice that it put the class in
the Treehouse.SimpleConsoleApp.Helpers
3:58
namespace.
4:04
By convention Visual Studio
assumes that code in a folder
4:05
should be in its own namespace.
4:09
You can also add existing
files to the project.
4:12
I've placed a file in my Documents folder
that I want to add to this project.
4:15
To add it, I right-click on the project or
4:19
folder that I want to add the file to,
then click Add > Existing Item.
4:22
This opens an open file dialog,
4:28
which I can use to navigate
to where my file is located.
4:30
By default, because this is a C# project,
4:33
that filter down here is
only set to show C# files.
4:36
If you don't see the file you're
looking for, change this to All Files.
4:40
Now, I can select my file, and click Add.
4:44
A copy of the file is made and
placed inside the project.
4:47
To get a better idea of what's
happening behind the scenes
4:50
you can always look at
the Windows File Explorer.
4:53
And easy way to get there is to
right-click on the solution name and
4:56
click Open Folder in File Explorer.
4:59
This opens the file explorer and shows us
the folder that contains the solution.
5:01
I'm going to have Windows show
us the file name extensions.
5:07
There, that's better.
5:10
This file here with the .sln
extension is the solution file.
5:12
This is the file that you click on to
open the solution in Visual Studio.
5:16
Treehouse.SimpleConsoleApp contains
the project.
5:20
This contains the actual files
that make up the project.
5:25
Here's the Program.cs file.
5:29
Here's the App.config file.
5:31
Here's the folder we created and the C#
file that we created in that folder.
5:33
This file with the .csproj extension
5:39
is the project file that contains all the
settings for how to build this project.
5:42
We also see the file I
copied into the project.
5:47
Because Visual Studio is a project-based
IDE as opposed to a file system-based IDE,
5:51
it expects that you'll be creating,
moving, and deleting files and
5:56
folders only from within Visual Studio.
5:59
It won't automatically pick up changes
that happen outside of Visual Studio.
6:03
For example, if I delete this file
here in the file explorer, and then
6:07
go back into Visual Studio, you'll notice
that it still has the file on the project.
6:12
To get Visual Studio to
recognize this change,
6:17
we need to delete the file from here.
6:20
It's the same with moving and
adding files.
6:24
You can make changes in the file explorer,
but you then need to come back here and
6:27
tell the ID about those changes.
6:31
In general, it's best to do
everything from within Visual Studio
6:33
as much as possible.
6:37
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up