about c# by: mark anthony p. cezar
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 PresentationTRANSCRIPT
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
Research History
1 Yellow Pad
Installation.NET Framework v 3.5Visual StudioVisual C# (2008,2010,2011)MSDN – Microsoft Developers Network(optional)
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.
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.
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
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
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.
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.
Three distinct modes are:
Design time
Run time
Debug time
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
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.
The Assignment Statement –General Form
Object.Property – Value
Ending a program by executing a Method
Object.Method()
Examples:
helloButton.Hide();messageLabel.Show();this.Close();
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.
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.
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
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.
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
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.
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
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
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
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
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
Declaration statement example
string customerNameString;string customerNameString = “None”;int totalSoldInteger = 0;float temperatureFloat;float temperatureFloat= 32f;decimal priceDecimal;
Declaration statement example
string customerNameString;string customerNametring = “None”;int totalSoldInteger = 0;float temperatureFloat;float temperatureFloat= 32f;decimal priceDecimal;
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);
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
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