You are on page 1of 9

CIS 3260 – Intro.

to Programming with C#

Introduction to
Programming and
Visual C# 2008

McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved.

 Describe the process of visual program


design and development
 Explain the term object-oriented
programming
 Explain the concepts of classes, objects,
properties, methods, and events
 Describe the various files that make up a C#
project

McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-2

 Identify the elements in the Visual Studio


environment
 Define design time, run time, and debug time
 Identify syntax errors, run-time errors, and
logic errors
 Look up C# topics in Help

McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-3

Dr. David McDonald Chapter 1 – Page 1


CIS 3260 – Intro. to Programming with C#

 Your C# programs will


look and act like
standard Windows
programs
 Use tools to create:
◦ Labels
◦ Text boxes
◦ Buttons
◦ Radio buttons
◦ Picture box
◦ Check box
◦ Menu Bar
◦ Drop-down list
◦ List box
◦ Group box

McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-4

 Windows GUI defines how elements look and


function
 Windows are called forms
 Elements are called controls
 Add controls to your forms using the toolbox
 C# projects follow the object-oriented
programming (OOP) technique

McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-5

 Procedural — Basic, C, Cobol, Fortran, PL/1,


Pascal
◦ Program specifies exact sequence of operations
 Object Oriented Programming (OOP) — C#,
Java, Visual Basic
◦ User controls the sequence
◦ User actions cause events to occur which trigger
methods

McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-6

Dr. David McDonald Chapter 1 – Page 2


CIS 3260 – Intro. to Programming with C#

 Objects have properties, methods and


events
 An object is based on a class
◦ Objects (noun or thing)
 Forms, Controls
◦ Properties (adjectives)
 Name, Color, Size, Location
◦ Methods (verbs)
 Close, Show, Clear
◦ Events (occurs when user takes action)
 Click, KeyPress, Scroll, Close window
◦ Classes (template or blueprint)
 Contain definition of all available properties, methods and
events

McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-7

 Object.Property
◦ SalesForm.Text
 Object.Method
◦ BillingForm.Show()
◦ exitButton.Show()

McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-8

 Class = automobile
 Object = one individual automobile
◦ Object is an instance of the automobile class
 Properties = make, model, color, engine,
number of doors
 Methods = start, speedup, slowdown, stop
 Events = arrive, crash

McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-9

Dr. David McDonald Chapter 1 – Page 3


CIS 3260 – Intro. to Programming with C#

.NET 3.5 Framework


◦ Environment that allows objects from different
languages to operate together, standardizes
references to data and objects
◦ .NET languages all compile (translate) to
Microsoft Intermediate Language (MSIL)
◦ MSIL runs in the Common Language Runtime
(CLR)
 Programming Languages
◦ Visual C#, Visual C++, Visual Basic
 C# Versions
◦ Express Edition, Standard Edition, Professional
Edition, Team System
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-10

 Solution file
◦ A C# application is called a solution and can
consist of one or more projects
◦ .sln extension
 Project file
◦ Describes project and lists files included
◦ .csproj extension
 Form files
◦ .cs, .Designer.cs, .resx extensions
 The Visual Studio environment creates
several more files

McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-11

 .NET Framework – Three major components


◦ Common Language Runtime (CLR)
◦ Class Library
◦ ASP.NET

 Integrated Development Environment

McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-12

Dr. David McDonald Chapter 1 – Page 4


CIS 3260 – Intro. to Programming with C#

 Manages execution of code


◦ Integrates components developed in different
languages (a.k.a. managed code)
◦ Handles errors across languages
◦ Provides security
◦ Manages storage and destruction of objects
(garbage collector)
◦ Manages data

McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-13
1-13

 Stores all classes and interfaces of the


.NET language
 Stored in a library known as the .NET
Framework class library
 Namespaces – sections within the library
that contain classes, structures,
enumerations, delegates, interfaces
 Standardized through the Common
Language Specifications (CLS)
.NET Framework Developer’s Guide
Contains the rules for CLS compliance
McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-14

 ASP.NET 3.0 is the newest version of Active


Server Pages (ASP)
 Web development environment that compiles
applications written in .NET compatible
languages
 Uses CLR and managed code features
 Makes Web development easier by providing
development and debugging support for Web
applications and Web Services similar to that
for Windows applications

McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-15

Dr. David McDonald Chapter 1 – Page 5


CIS 3260 – Intro. to Programming with C#

Integrated
Development Environment (IDE)

 Includes various tools


◦ Form designer
◦ Editor for entering and modifying C# code
◦ Compiler
◦ Debugger
◦ Object Browser
◦ Help

McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-16

 Visual Studio 2008 allows selection of default


IDE profile
◦ Available with full version of Visual Studio
◦ Choose Visual C# Development Settings
 Text uses the Visual C# settings
 Settings can be saved for more than one language
 To switch between the settings for languages:
 Select Tools/Import and Export Settings
 Choose Reset all settings

McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-17

 Select File/New Project


◦ New Project Dialog Box Opens Select the Windows Forms
Application template

Select Visual C#
Windows

Enter the Project


Name

McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-18

Dr. David McDonald Chapter 1 – Page 6


CIS 3260 – Intro. to Programming with C#

Solution
Toolbox Explorer

Properties
window

Main
Document
window

Each window can be moved, resized, closed, or customized

McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-19

 Toolbar buttons are shortcuts


 Each button’s command is also a menu
selection
 Select View/Toolbars to display or hide a
toolbar
 Three commonly used toolbars
◦ Standard
◦ Layout
◦ Text Editor

McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-20

 Use tabs to switch between open documents


 Items in Document window
◦ Form Designer
◦ Code Editor
◦ Project Designer
◦ Database Designer
◦ Object Browser

McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-21

Dr. David McDonald Chapter 1 – Page 7


CIS 3260 – Intro. to Programming with C#

 Design forms for user interface


 Change size of form using sizing handles or
selection border
 A new default form is added when a new C#
application is started

McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-22

 Solution Explorer window


◦ Holds filenames for project files
◦ Lists classes referenced
◦ Holds name of solution (.sln) file
 Properties Window
◦ Used to set properties for objects in project

McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-23

 Holds tools to place


controls on form
 Tools vary depending
on edition of C#

McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-24

Dr. David McDonald Chapter 1 – Page 8


CIS 3260 – Intro. to Programming with C#

Help with specific tasks Selected Topic Help Search

Filter

Help Index Help Contents Help Favorites Index Results

McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-25

 Design Time
◦ Design user interface (forms)
◦ Write code
 Run Time
◦ Testing project
◦ Running project
 Debug Time
◦ Run-time errors
◦ Pause program execution

McGraw-Hill © 2010 The McGraw-Hill Companies, Inc. All rights reserved. 1-26

Dr. David McDonald Chapter 1 – Page 9

You might also like