C# Tutorial MSM_Murach chapter-01-slides

20
Murach’s C# 2010, C1 © 2010, Mike Murach & Associates, Inc. Slide 1 C hapter1 How to getstarted w ith VisualStudio

Transcript of C# Tutorial MSM_Murach chapter-01-slides

Murach’s C# 2010, C1 © 2010, Mike Murach & Associates, Inc. Slide 1

Chapter 1

How to get started with Visual Studio

Murach’s C# 2010, C1 © 2010, Mike Murach & Associates, Inc. Slide 2

A Windows Forms application running on the Windows desktop

Radio Button

Label

Text Box

Button

Form and Controls

Murach’s C# 2010, C1 © 2010, Mike Murach & Associates, Inc. Slide 3

A Web Forms application running in a Web browser

Murach’s C# 2010, C1 © 2010, Mike Murach & Associates, Inc. Slide 4

Visual Studio 2010 Editions Edition Description Express Edition A free, downloadable edition that supports just

one of the Visual Studio programming languages. There is also an Express Edition of SQL Server called SQL Server 2008 Express.

Professional Edition For individual developers who want to build a wide variety of Windows, web, mobile, and Office-based solutions

Premium Edition For individuals and teams who want to build scalable applications; includes standard testing tools, database deployment and change-management tools, and basic lifecycle management tools.

Ultimate Edition For teams; includes full testing, modeling, database, and lifecycle management tools.

Murach’s C# 2010, C1 © 2010, Mike Murach & Associates, Inc. Slide 5

Programming languages supported by Visual Studio 2010 Visual Basic Visual C# Visual C++ Visual F#

Murach’s C# 2010, C1 © 2010, Mike Murach & Associates, Inc. Slide 6

The .NET Framework

Operating System and Hardware

Windows XP Windows Vista Windows 7 Other Operating Systems

.NET Framework

.NET Applications

Visual Basic Visual C# Visual C++ Visual F#

.NET Framework Class Library

Windows Forms classes ASP.NET classes Other classes

Common Language Runtime

Managed applications Common Type System Intermediate Language

Murach’s C# 2010, C1 © 2010, Mike Murach & Associates, Inc. Slide 7

The Visual Studio IDE

Murach’s C# 2010, C1 © 2010, Mike Murach & Associates, Inc. Slide 8

How a C# application is compiled and run

Solution

.NET FrameworkVisual Studio

Project

CommonLanguageRuntime

IntegratedDevelopmentEnvironment

Source files

C#compiler

1 2 3

Assembly

Intermediate Language (IL)

Class references

Murach’s C# 2010, C1 © 2010, Mike Murach & Associates, Inc. Slide 9

The Visual Studio Start Page

Murach’s C# 2010, C1 © 2010, Mike Murach & Associates, Inc. Slide 10

The Open Project dialog box

Murach’s C# 2010, C1 © 2010, Mike Murach & Associates, Inc. Slide 11

Project and solution concepts Every C# project has a project file with an extension of csproj that

keeps track of the files that make up the project and records various settings for the project.

Every solution has a solution file with an extension of sln that keeps track of the projects that make up the solution.

When you open a project file, Visual Studio opens the solution that contains the project. And when you open a solution file, Visual Studio automatically opens all the projects contained in the solution.

The project file can be stored in the same directory as the solution file or in one of its subdirectories.

Murach’s C# 2010, C1 © 2010, Mike Murach & Associates, Inc. Slide 12

The Form Designer window of Visual Studio

Murach’s C# 2010, C1 © 2010, Mike Murach & Associates, Inc. Slide 13

The Code Editor window of Visual Studio

Murach’s C# 2010, C1 © 2010, Mike Murach & Associates, Inc. Slide 14

The Solution Explorer

Murach’s C# 2010, C1 © 2010, Mike Murach & Associates, Inc. Slide 15

Project files The Solution Explorer uses different icons to distinguish between

source code files that define forms and those that don’t. Each form is defined by two C# source files where each file

contains a partial class. The file with the cs extension contains the code that’s entered by the programmer; the file with the Designer.cs extension contains the code that’s generated when the programmer works with the Form Designer. When the project is compiled, these partial classes are combined into a single class that determines the appearance and operation of the form.

A source code file that doesn’t define a form is usually stored in a single C# source file that contains a single class.

The References folder contains references to the assemblies for the namespaces that the application can use. These namespaces contain the classes that the project requires. In most cases, all the references that you need are included when the project is created.

Murach’s C# 2010, C1 © 2010, Mike Murach & Associates, Inc. Slide 16

Visual Studio with two floating windows and a hidden window

Murach’s C# 2010, C1 © 2010, Mike Murach & Associates, Inc. Slide 17

How to rearrange windows To undock a docked window so it floats on the screen, drag it by its

title bar away from the edge of the application window or double-click its title bar.

To dock a floating window, drag it by its title bar onto one of the positioning arrows that become available. Or hold down the Ctrl key and double-click its title bar to return it to its previous docked location.

To hide a docked window, click its Auto Hide button. Then, the window is displayed as a tab at the edge of the screen, and you can display it by placing the mouse pointer over the tab.

If two or more windows are grouped into tabbed windows, you can display any window in the group by clicking on its tab.

If you dock, undock, hide, or unhide a tabbed window, all the windows in the group are docked, undocked, hidden, or unhidden.

Murach’s C# 2010, C1 © 2010, Mike Murach & Associates, Inc. Slide 18

The form that’s displayed when the Financial Calculations project is run

Murach’s C# 2010, C1 © 2010, Mike Murach & Associates, Inc. Slide 19

How to build a project without running it Use the BuildBuild Solution command. Or, right-click the

project in the Solution Explorer and select the Build command from the shortcut menu.

How to run a project You can run a project by clicking on the Start Debugging button

in the Standard toolbar or by pressing F5. Then, the first form of the project is displayed on top of the Visual Studio window.

If the project hasn’t already been built, the project is first built and then run.

Activity

• Use the information in Appendix A to download sample files from Murach’s web site

• Work your way through the exercises at the end of chapter 1

Murach’s C# 2010, C1 © 2010, Mike Murach & Associates, Inc. Slide 20