ch1 – a 1 st program using c#. program set of instructions which tell a computer what to do....
TRANSCRIPT
ProgramSet of instructions which tell a computer what to
do.Machine Language
Basic language computers use to control its switches
0 = switch is off1 = switch is on
High-Level Programming LanguageUses ‘reasonable’ words as instructions
SyntaxLanguage rules
Programming Vocabulary
CompilerTranslates high-level language
into machine codeSyntax-error
Incorrect use of programming languageLogic
Instructions in the correct order to produce the desired results
DebuggingCorrecting syntax and logic errors
Programming Vocabulary
Object-Oriented Programming (OOP)an approach to designing modular, reusable software systems
VariableComputer memory storage location
IdentifierVariable name
ObjectContains its own variables, methodsSimilar to real-world objects (green racing car)
Object-Oriented Programming Vocabulary
AttributesObjects characteristics
StatesValue of an attribute
ClassCategory of objects
InstanceAn individual member of an object
Methoda collection of statements grouped together to perform an
operation.
Add a to b = c
Object-Oriented Programming Vocabulary
Racing
AutomobileGreen racing
car
Class (Automobiles)(attributes,methods)
Object(year, make, model, color)
(attributes, methods, variables)
Instance(Green racing car)
Instance(Blue suburban)
Object-Oriented Programming Vocabulary
EncapsulationPackaging an object’s attributes
and methods into an undivided entity.Polymorphism
Creates methods which act appropriately depending on the context.
InheritanceThe ability to extend a class so as to create a
more specific class.
Object-Oriented Programming Vocabulary
Filling your dog v. filling your car
Automobile v. RacingCars
C# - object-oriented and component-oriented language.
Literal StringA series of characters which will be used
exactly as enteredEnclosed within double quotation marks “ “Label the literal string on the diagram
Argument Info a method needs to perform its task.Enclosed within double parentheses ( )Label the argument on the diagram
Writing a C# Program Vocabulary
“Hello, world!”
(“Hello, world!”)
WriteLine () – a method which displays output and positions the cursor on the next line.Label the method on the diagram
NamespaceA way to group similar classes.System namespace = holds commonly used classesLabel the namespace on the diagram
Label the Main method on the diagramMethod Header
Method name Info about what will pass into and be returned from the
method.Label the method header on the diagram
Writing a C# Program Vocabulary
Method Body All the instructions executed by the method. Enclosed between double {}Label the method body on the diagram
WhitespaceBlank linesLabel one example of whitespace on the diagram
KeywordPredefined/reserved identifier which has special
meaning to the compiler.Static – method executed through a class, not by an
objectVoid – method does not return any valueUse Table 1-1 on page 13 to label the keyword(s) on the
diagram
Writing a C# Program Vocabulary
Access ModifierDefines the circumstances about when the method
may be used.Private – other classes may not use the methodPublic – other classes may use the methodLabel the access modifier(s) body on the
diagramSource Code
The text of the program you write
Writing a C# Program Vocabulary
Turn to page 40 and answerReview Questions 9 – 14 and
17.NEXT
Turn to page 41 and answerExercises 2 and 3.
Questions and Problems
Identifiers MUSTBegin with an underscore, @, or a letterContains only letters or digitsCannot be a C# reserved keyword
Programming Standard (see page 14 Table 1-2)Begin with uppercase letterUse uppercase letters to improve readability
Selecting Identifiers
Turn to page 40 and answerReview Questions 15 - 16.
NEXTTurn to page 41 and answer
Exercise #1.
Questions and Problems
Line CommentsBegin with two forward slashes //
Block CommentsBegin with a forward slash and an asterisk /*End with and asterisk and a forward slash */Write comments on the diagram stating
something the program is doing
Adding Comments
; ‘period’ at the end of each line
. Separate the names of namespace, class, object, method
Additional Syntax
1. Open Microsoft Visual C# 20102 Express2. Click File, New, Project3. Click Console Application4. Type the name of the project in the Name bar
HelloWorld5. Browse to your W: drive in the Location bar6. Create a C# folder W:\IntroPgming\C#\7. Make sure the location bar has your W: drive and folder
name!!!8. Click OK.9. Turn to page 30 and enter the code in figure 1-19.
(some is already there)Type at least one comment.
10. Click Save.11. Click Build, Build Solution12. Click Debug, Start with Debut if there are errors13. Click Debug, Start without Debug if there are no errors
1st C# Program