Windows Programming 1 Part 1 dbg --- Getting Acquainted with Visual Studio.NET and C#

16
Windows Programming 1 Part 1 dbg --- Getting Acquainted with Visual Studio.NET and C#

Transcript of Windows Programming 1 Part 1 dbg --- Getting Acquainted with Visual Studio.NET and C#

Page 1: Windows Programming 1 Part 1 dbg --- Getting Acquainted with Visual Studio.NET and C#

Windows Programming 1

Part 1 dbg --- Getting Acquainted with Visual Studio.NET and C#

Page 2: Windows Programming 1 Part 1 dbg --- Getting Acquainted with Visual Studio.NET and C#

2

The Visual Studio.NET IDE

• Visual Studio.NET is an Integrated Development Environment (IDE).

• It contains:– the Designer which makes it easy to create Graphical

User Interfaces (GUIs) – a context-sensitive text editor – various language compilers (we will be using C#)– a runtime environment for testing/debugging our code

• Visual Studio.NET can be used with other programming languages such as C++ and Visual Basic

Page 3: Windows Programming 1 Part 1 dbg --- Getting Acquainted with Visual Studio.NET and C#

3

Programming Windows with .NET

• .NET is a “programming platform” for Windows. • An important feature is that applications are

especially “tuned” for network use.• Another interesting feature is that the platform

allows applications written with several different languages to directly communicate with each other.

Page 4: Windows Programming 1 Part 1 dbg --- Getting Acquainted with Visual Studio.NET and C#

4

The .NET Framework

Common Language Specification

ASP.NET: Web Services and Web Forms

Windows Forms

ADO.NET: Data and XML

Framework Class Library

Common Language Runtime

VB C++ C# J# …V

isual S

tud

io.N

ET

Page 5: Windows Programming 1 Part 1 dbg --- Getting Acquainted with Visual Studio.NET and C#

Procedural programming + classes

Where Does C# Fit?

1967 1970 1972 1985 1998 2000

BCPL B C C++ C++ C++.NET

1997 2000

BASIC Visual BASIC BASIC.NET

MS Visual

MS Visual

1965 1991 2000

C# combines the best features of C/C++, Java, and VB in a new visual, fully object-oriented, event-driven programming language designed for use with the .NET

platform.

Procedural programming + classes

MS

1995 2000

Sun MicrosystemsJava

GU

Is

Web

Pro

gram

min

g

Fu

lly OO

P

ANSI/ISO

MS VisualC#.NET

Page 6: Windows Programming 1 Part 1 dbg --- Getting Acquainted with Visual Studio.NET and C#

6

Programming Windows with C#

• A new language designed specifically for .NET• Fully object-oriented• Type safe language • Built-in Visual Editor for GUI development• Fundamental programming syntax resembles

that of C++ and Java

Page 7: Windows Programming 1 Part 1 dbg --- Getting Acquainted with Visual Studio.NET and C#

7

Importance of C#

• Microsoft wrote much of .NET system programming in C# and is currently writing next version of Windows (Longhorn) in C#.

• In “Special Report: Security”, PC Magazine, pg 78, 8/3/04 issue:

“ ‘In the course of putting together Longhorn,’ says Nash, [of Microsoft] ‘… we’re making sure that in the design phase, the implementation phase, as we build the product , we’re looking for security and quality issues.’

The company is also using design tools that are far more conducive to building secure code. It has discarded notoriously insecure languages like C and C++ in favor of C# and the Microsoft .NET platform.”

Page 8: Windows Programming 1 Part 1 dbg --- Getting Acquainted with Visual Studio.NET and C#

8

C# Features

• A considerable amount of pre-defined code resides in the Framework Class Library (FCL).

• C# can be used to develop– Console applications (procedural programming)– Interactive Windows Forms applications (GUIs)– Web Services (server programs)– Interactive Web Forms (via ASP.NET)

• Like other .NET languages, code is compiled first into MSIL (MS Intermediary Language) and then into machine language.

Page 9: Windows Programming 1 Part 1 dbg --- Getting Acquainted with Visual Studio.NET and C#

Objects

Getting Started with Object Oriented Programming

Page 10: Windows Programming 1 Part 1 dbg --- Getting Acquainted with Visual Studio.NET and C#

10

Objects (nouns)

• An object is a person, place or thing.• In theory, we should be able to

describe all of our experience and surroundings as objects.

• All objects have attributes and operations.

Page 11: Windows Programming 1 Part 1 dbg --- Getting Acquainted with Visual Studio.NET and C#

11

Attributes (adjectives)

• Attributes are characteristics.• Use attributes to describe the appearance of an

object.• Size, shape and color could be attributes of

many objects.• A football is brown in color and roughly oval in

shape; these characteristics represent values assigned to attributes.

Page 12: Windows Programming 1 Part 1 dbg --- Getting Acquainted with Visual Studio.NET and C#

12

Operations (verbs)

• Operations are actions.• User operations to describe the

“active” behavior of an object.• A football might, spiral, tumble, roll

or bounce.• These behaviors become evident if

a specific operation of the object is activated.

Page 13: Windows Programming 1 Part 1 dbg --- Getting Acquainted with Visual Studio.NET and C#

13

Classes (templates)

• Classes are patterns for objects.• You might think of a class as a cookie cutter and

a set of objects as cookies created with that cutter (class).

• An object is an instance of a class, and the process of creating an object is called instantiation.

ClassObjects

Page 14: Windows Programming 1 Part 1 dbg --- Getting Acquainted with Visual Studio.NET and C#

14

Classes

• In practice, a class is a unit or module of code that may be used to define the attributes and operations of an object.

• Some classes will exist within the Windows applications we will write.

• Other classes pre-exist and are stored in special files called libraries.

Page 15: Windows Programming 1 Part 1 dbg --- Getting Acquainted with Visual Studio.NET and C#

15

Data and Actions

• Within a class, attributes are represented by variables. After an object is created from a class, values may be assigned to these variables to adjust attributes.

• Within a class, operations are represented by methods. After an object is created from a class, an operation may be triggered by running a method.

Page 16: Windows Programming 1 Part 1 dbg --- Getting Acquainted with Visual Studio.NET and C#

16

Encapsulation

• It is not necessary for a programmer who uses a pre-existing class to know or understand its code structure.

• This concept is called encapsulation; its implications are significant.