about c# by: mark anthony p. cezar

56
About C# BY: MARK ANTHONY P. CEZAR

Upload: layne

Post on 19-Jan-2016

17 views

Category:

Documents


1 download

DESCRIPTION

About C# BY: MARK ANTHONY P. CEZAR. C# C Sharp New Language introduced by Microsoft Goal is to provide ease of working, flexibility, and power of the Java and C++ languages. Fully Object Oriented PL Allows Programmer to develop applications Under windows and web browser. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: About C# BY: MARK ANTHONY P. CEZAR

About C#BY: MARK ANTHONY P. CEZAR

Page 2: About C# BY: MARK ANTHONY P. CEZAR

C# C SharpNew Language introduced by Microsoft Goal is to provide ease of working, flexibility, and power of the Java and C++ languages. Fully Object Oriented PLAllows Programmer to develop applicationsUnder windows and web browser

Page 3: About C# BY: MARK ANTHONY P. CEZAR

Research History

1 Yellow Pad

Page 4: About C# BY: MARK ANTHONY P. CEZAR

Installation.NET Framework v 3.5Visual StudioVisual C# (2008,2010,2011)MSDN – Microsoft Developers Network(optional)

Page 5: About C# BY: MARK ANTHONY P. CEZAR

TerminologiesObjects as a thing . Examples of objects are forms and controls

Properties tell something about object behavior such as names, color, size or location

Methods action associated with objects are called method.Typical methods are Close, Show and Clear.

Page 6: About C# BY: MARK ANTHONY P. CEZAR

Events write methods that execute when a particularEvents occurs. An event occurs when the user takes an action such as clicking a button.

Classes Contain definition of all available properties,Methods and events. It is a template or blueprint used to create a new object.

Page 7: About C# BY: MARK ANTHONY P. CEZAR

GOOD PROGRAMMING3 Steps for Planning and for developing the project.

Planning Programming

1.Design the user interface 1. Define the user interface

1.Plan the properties 2. Set the Properties

1.Plan the c# code 3. Write the code

Page 8: About C# BY: MARK ANTHONY P. CEZAR

IDE MAIN WINDOW Visual Studio Environment and its various child window.IDE main window holds VS menu bar, toolbars, display or hide Windows from the view menu

Page 9: About C# BY: MARK ANTHONY P. CEZAR

IDE MAIN WINDOWConsists of:

Toolbars each button represents a command that can be selectedfrom a menu.

Document Window the largest window in the center of the screen.The items that display in the document window include theForm designer, code editor, project designer, database designerAnd object browser.

Page 10: About C# BY: MARK ANTHONY P. CEZAR

The Form Designer is where you design a form that makes up your user interface.

The Solution Explorer Window holds the filenames for the files included in your project and list of the classes It references.

The Properties Window set properties for the objects in Your project.

The Toolbox holds the tools you use to place controls ona form.

Page 11: About C# BY: MARK ANTHONY P. CEZAR

Three distinct modes are:

Design time

Run time

Debug time

Page 12: About C# BY: MARK ANTHONY P. CEZAR

Writing Your First C# Project

1.Select Visual C# / Windows / Windows FormApplication / Enter name Hello world for the name of The new project.

Note: Customizing windows, floating and docking

Page 13: About C# BY: MARK ANTHONY P. CEZAR

1. Plan the Sketch of the Hello World form

1. Define user interface and place of the controls on the form.

1. Set the name , properties of the object and form.

1. Write codes

The comment statement and hello world–Examples

textBox1.Text = "hello world"; //Assign the message to the Text property.

Page 14: About C# BY: MARK ANTHONY P. CEZAR

The Assignment Statement –General Form

Object.Property – Value

Ending a program by executing a Method

Object.Method()

Examples:

helloButton.Hide();messageLabel.Show();this.Close();

Page 15: About C# BY: MARK ANTHONY P. CEZAR

Syntax Errors

•Breaking rules in punctuation, format or spelling.

Run Time Errors•Project halts during execution•C# display dialog box and highlight statement causing theProblem.

Logic Errors•Program runs but produces in correct results.•Beginners in programming often overlook their logic errors.

Page 16: About C# BY: MARK ANTHONY P. CEZAR

Hands on Programming 1

Great Body gymMembershipMaintenance soupEquipment and AccessoriesClothingInstructorExit Programmed by <Your Name>

Design a layout of a program for the great body gym center to display promotions. Put statement Label for each buttons of the following department.

Page 17: About C# BY: MARK ANTHONY P. CEZAR

Hands on Programming 2Design any program that will use the following objects:

2 Text Box 4 Label Box1 Picture 4 Radio Buttons3 Button 4 Check Box

ex

Page 18: About C# BY: MARK ANTHONY P. CEZAR

Hands on Programming 3This neighborhood store is an independently owned rental business. The owners would like to allow their customer to user the computer to look up aisle number for movies by category.Create a form with a button for each category. When the user clicks on a button, display the corresponding aisle number in a label. Include a button to exit.Include a button that holds your name at the bottom of the form and change the title bar of the form to Generation X Cinema.You may change font properties of the labels and size of your choice.

Page 19: About C# BY: MARK ANTHONY P. CEZAR

1. Clearing Text Boxes and Labels.2. Display a Photo upon selection3. Disabling Controls4. Setting Properties5. Changing the color of text6. Using radio buttons for selecting

colors7. Concatenating Text8. Printing a Form

Page 20: About C# BY: MARK ANTHONY P. CEZAR

Data – Variable and Constant

• Memory locations that hold data that can be changed during project execution are variables.

• Locations that hold data that cannot change during execution are called constants.

Page 21: About C# BY: MARK ANTHONY P. CEZAR

Data Type Use for

Bool True or false

Byte 0 to 255, binary data

Char Single Unicode Character

DateTime 1/1/0001 00:00:00 through 12/31/9999 12:59:59

Decimal Decimal, fractions such as dollar and cents

Float Single precision floating points

Double Double precision floating points

Short Small integer range -32,768 to + 32,767

Int Whole number in the range 2,147,483,648 to 2,147,483,647

Long Larger Whole Number

String Alpha numeric data:letters, digits and other characters

object Any type of data

Page 22: About C# BY: MARK ANTHONY P. CEZAR

Naming Rules

• Consist of letters, digits and underscores

• Begin with letter or underscore• Must not contain of spaces or period• Not a reserve word or keywords

Page 23: About C# BY: MARK ANTHONY P. CEZAR

Naming Conventions

•Identifier must be meaningful•Begin with a lowercase letter and capitalize each successive word of the name.Sample Identifiers

Field of Data Possible IdentifierSocial security number socialSecurityNumberStringPay rate payRateDecimalTax rate(constant) TAX_RATE_DecimalPopulation populationLong

Page 24: About C# BY: MARK ANTHONY P. CEZAR

QuizIndicate whether each of the following identifiers conforms to the rules of c# and to the naming convention. If the identifier is invalid ,give the reason.

0. omitted 6. subString1. #SoldInteger 7. Text2. Number Sold Integer 8. maximum3. Number.Sold.Integer 9. minimumRate4. Amount$Decimal 10. maximumCheckDecimal5. Class 11. companyNameString

Page 25: About C# BY: MARK ANTHONY P. CEZAR

ANSWER

0. omitted does not have a suffix indicate data type

1. #SoldInteger cannot contain character such as #

2. Number Sold Integer cannot contain blank spaces

3. Number.Sold.Integer period use only to separate item such Object.Property

4. Amount$Decimal cannot contain character such as $

5. Class class is a reserve word6. subString valid7. Text reserve word8. Maximum does not indicate clearly data type9. minimumRate a suffix indicate data type used10. maximumCheckDecimalvalid11. companyNameString valid

Page 26: About C# BY: MARK ANTHONY P. CEZAR

Declaration statement example

string customerNameString;string customerNameString = “None”;int totalSoldInteger = 0;float temperatureFloat;float temperatureFloat= 32f;decimal priceDecimal;

Page 27: About C# BY: MARK ANTHONY P. CEZAR

Declaration statement example

string customerNameString;string customerNametring = “None”;int totalSoldInteger = 0;float temperatureFloat;float temperatureFloat= 32f;decimal priceDecimal;

Page 28: About C# BY: MARK ANTHONY P. CEZAR

The MessageBox Statement

General FormMessageBox.Show(TextMessage, TitlebarText, MessageButtons,

MessageIcon);

MessageBox.Show(“Enter numeric data.”);

MessageBox.Show(“Try Again.”, “Data Eror”);

MessageBox.Show(“This is a message.””This is a title bar”, Messagebuttons.OK);

Page 29: About C# BY: MARK ANTHONY P. CEZAR

Controlling Code Flow

Comparison Operator – compare data and return either true or false result. It can be used to compare strings, numbers and even Booleans.

comparison operator Meaning== is equal to != not equal to> greater than< Less than>= Greater than or equal to<= Less than or equal to

Page 30: About C# BY: MARK ANTHONY P. CEZAR

Controlling Code Flow

Logical Operators – combine comparison results and create compound expression.

Operator Description&& Returns a value of true if both values are true|| Returns a value of true if either value is

true! Inverts the true or false result

Page 31: About C# BY: MARK ANTHONY P. CEZAR
Page 32: About C# BY: MARK ANTHONY P. CEZAR
Page 33: About C# BY: MARK ANTHONY P. CEZAR
Page 34: About C# BY: MARK ANTHONY P. CEZAR
Page 35: About C# BY: MARK ANTHONY P. CEZAR
Page 36: About C# BY: MARK ANTHONY P. CEZAR
Page 37: About C# BY: MARK ANTHONY P. CEZAR
Page 38: About C# BY: MARK ANTHONY P. CEZAR
Page 39: About C# BY: MARK ANTHONY P. CEZAR
Page 40: About C# BY: MARK ANTHONY P. CEZAR
Page 41: About C# BY: MARK ANTHONY P. CEZAR
Page 42: About C# BY: MARK ANTHONY P. CEZAR
Page 43: About C# BY: MARK ANTHONY P. CEZAR
Page 44: About C# BY: MARK ANTHONY P. CEZAR
Page 45: About C# BY: MARK ANTHONY P. CEZAR
Page 46: About C# BY: MARK ANTHONY P. CEZAR
Page 47: About C# BY: MARK ANTHONY P. CEZAR
Page 48: About C# BY: MARK ANTHONY P. CEZAR
Page 49: About C# BY: MARK ANTHONY P. CEZAR
Page 50: About C# BY: MARK ANTHONY P. CEZAR
Page 51: About C# BY: MARK ANTHONY P. CEZAR
Page 52: About C# BY: MARK ANTHONY P. CEZAR
Page 53: About C# BY: MARK ANTHONY P. CEZAR
Page 54: About C# BY: MARK ANTHONY P. CEZAR
Page 55: About C# BY: MARK ANTHONY P. CEZAR
Page 56: About C# BY: MARK ANTHONY P. CEZAR