Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Projects and Solutions6:38 with Jeremy McLain
Learn how to use the Solution Explorer to work with the files and folders in your projects and solutions.
|Start Without Debugging||Ctrl+F5|
|Run to Cursor||Ctrl+F10|
|Select Current Word||Ctrl+W|
|Copy Entire Line||Ctrl+C|
|Cut Entire Line||Ctrl+X|
|Find All References||Shift+F12|
|Find In Files||Ctrl+Shift+F|
|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|
|Next Tab||Ctrl+Alt+Page Down|
|Previous Tab||Ctrl+Alt+Page Up|
|Peek at Definition||Alt+F12|
|Quick Info||Ctrl+K, Ctrl+I|
|Close Popup Window||Esc|
|Move Selected Lines Up||Alt+Up|
|Move Selected Lines Down||Alt+Down|
|Format Document||Ctrl+K, Ctrl+D|
|Format Selection||Ctrl+K, Ctrl+F|
|Comment Section||Ctrl+K, Ctrl+C|
|Uncomment Section||Ctrl+K, Ctrl+U|
|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|
All right, we've now created a console application that both builds and runs.
To run it, just click the green start button here on the toolbar.
The program was compiled, ran, and closed without errors.
Most projects in Visual Studio will work from the very start.
I found that it's nice to start in a working environment
with some simple code that runs.
That's what project templates are all about.
Let's take a closer look at what Visual Studio did when it created our project.
We can check this out by looking at the Solution Explorer.
If you don't see the Solution Explorer pane,
you can bring it back up by clicking on View > Solution Explorer.
Right now we're dealing with a console app.
Most solutions in Visual Studio share this basic structure in the Solution Explorer.
At the highest level there's the solution, below that there are one or more projects.
Within each project there's an area for properties, the list of assemblies or
libraries that your project uses are listed under References.
Below that, there's a list of code files, programmed at CS, which is already shown
in the editor here is the C# code file that contains the code for
the console app.
App.config is a special file that provides the runtime configuration for
the console app.
Notice what happens when I click once on the App.config file.
It's displayed in the editor, but its tab is on the right side of the pane.
If I click AssemblyInfo.cs, the tab is replaced with the contents of that file.
This is a preview, so
whatever is selected in Solution Explorer shows up as a tab here.
Unless that is, if it is already opened as a tab.
I can't tell you how much this preview feature helps keeps the editor
pane cleaned up.
You can open the file as a normal tab by double-clicking on it
in the Solution Explorer or by clicking on this button in the Preview tab.
One thing you'll notice about Visual Studio is there's usually
many ways to perform the same action.
Between the toolbars, menus, context menus, keyboard shortcuts,
search facilities, buttons or links and panes, and other cues that may pop up,
there's often at least four or five different ways to do everything.
For the most part, I'm just going to show you one way.
Part of making an ID your own is picking the methods that work best for
you after you try them out.
I'll also include a list of shortcuts in the teacher's notes that you
might find handy.
Now back to the Solution Explorer.
As you create more and
more files you'll probably want to start organizing them in folders.
You can create a folder by right-clicking on the project name,
clicking on Add in the context menu that pops up and then clicking New Folder.
The new folder appears in the Solution Explorer under that project.
You can give it a name by typing over the highlighted text.
This is also how you add files to your project.
You can add files to the top level of the project or inside the folder.
Just right-click on the folder or project name, mouse over Add, then click New Item.
You can pick the type of file you want to add from a list of templates.
This is very similar to how we created a new project from an existing template.
The file templates are organized into categories on the left side of
the dialog window.
I'm going to add another class to the project, so I'll select Class.
Then I'll give it the name InputHandler.cs, and click add.
The new file is added to the project and opened in the editor window.
Notice that the file already has some boiler plate code in it.
This comes from the file template.
It named the class InputHandler after the name of the file.
Also notice that it put the class in the Treehouse.SimpleConsoleApp.Helpers
By convention Visual Studio assumes that code in a folder
should be in its own namespace.
You can also add existing files to the project.
I've placed a file in my Documents folder that I want to add to this project.
To add it, I right-click on the project or
folder that I want to add the file to, then click Add > Existing Item.
This opens an open file dialog,
which I can use to navigate to where my file is located.
By default, because this is a C# project,
that filter down here is only set to show C# files.
If you don't see the file you're looking for, change this to All Files.
Now, I can select my file, and click Add.
A copy of the file is made and placed inside the project.
To get a better idea of what's happening behind the scenes
you can always look at the Windows File Explorer.
And easy way to get there is to right-click on the solution name and
click Open Folder in File Explorer.
This opens the file explorer and shows us the folder that contains the solution.
I'm going to have Windows show us the file name extensions.
There, that's better.
This file here with the .sln extension is the solution file.
This is the file that you click on to open the solution in Visual Studio.
Treehouse.SimpleConsoleApp contains the project.
This contains the actual files that make up the project.
Here's the Program.cs file.
Here's the App.config file.
Here's the folder we created and the C# file that we created in that folder.
This file with the .csproj extension
is the project file that contains all the settings for how to build this project.
We also see the file I copied into the project.
Because Visual Studio is a project-based IDE as opposed to a file system-based IDE,
it expects that you'll be creating, moving, and deleting files and
folders only from within Visual Studio.
It won't automatically pick up changes that happen outside of Visual Studio.
For example, if I delete this file here in the file explorer, and then
go back into Visual Studio, you'll notice that it still has the file on the project.
To get Visual Studio to recognize this change,
we need to delete the file from here.
It's the same with moving and adding files.
You can make changes in the file explorer, but you then need to come back here and
tell the ID about those changes.
In general, it's best to do everything from within Visual Studio
as much as possible.
You need to sign up for Treehouse in order to download course files.Sign up