Upload
mahmoud-abdallah
View
337
Download
0
Embed Size (px)
Citation preview
Topics
• What is Programming
• Machine Code VS. Programming Languages
• Why C#
• Visual Studio (IDE)
• .NET Framework
• Windows Desktop (Console, Form) Applications
• DEMO
Variables_ Variables are simply containers.
_ We create variables to hold data.
• Name
_ so we can retrieve it when we need to use it, or if we need to put data into the variable. Then we can access it by its name.
• Data type
_ The type of data that we can put inside a variable and it is also will determine the size of the variable.
Example:
int x;
x = 5;
Arrays
_ Array: is a variable that can contain other variables, many variables and then we can reference them by index to pull them out.
Examples:
Operators
_ Operators are the things we can do to data.
Arithmetic: + - * / % ++ --
Comparison: > < >= <= == !=
Logical: ! || &&
Assignment: = += -= *= /= %=
String Concatenation: +
Topics
• What are Decisions?
• IF Statement
• Inline Conditionals
• Switch Statement
• Examples
• DEMOs
Decision Structures
_ Gives our application the ability to make decisions.
_ Controlling the flow of how our program executes code.
_ What code executes based on conditions.
• if( ) { }
• switch( ) { }
Switch Statement_ When we have a lot of conditions, that were things get more complicated.
Example 1
Topics
• What is Looping ?
• While
• Do While
• For
• For Each
• Continue
• Break
• What are Functions ?
• Arguments
• Return
Looping
_ Looping: Executes a block of code until a condition is met.
_ It is our way of running a piece of code multiple times.
• Loop Types:
_ While
_ DoWhile
_ For
_ ForEach
While
_ Loop while a condition is true.
_ Checks condition at the beginning of the loop.
• Example 1: • Example 2:
For
_ Loop repeatedly until an expression evaluates to false.
_ Combines control elements in the for declaration.
• Example 1: • Example 2:
For Each
_ Loop through each element array or collection.
_ Used to iterate through items.
• Example 1:
Continue
_ It allows us to immediately end an iteration of the loop and go
back to the top of the loop and the next iteration.
• Example:
Functions_ They are very useful for extracting reusable code.
_ We want to isolate some pieces of useful code and sort of store them in a function.
_ They are only useful if we actually call or invoke them.
_ Every function has two things: Declaration & Definition.
• Example:
Arguments
_ Arguments are things we can pass into a function and it will do something to them.
_ The function is a factory. We put things into the factory and we get things out of
the factory.
• Example:
Return
_ Return allows us to pass something into our function and then it is going to kick
things back to us.
• Example 1:
Topics
• Event Driven Programming
• The Label Control
• Stateless Buttons
• Buttons with State
• Textbox Control
• Examples
• DEMOs
The Label Control
_ Labels basically are static text that will appear on a form.
_ Labels can be placeholders for data from database or a stuff was pulled from
somewhere else or to the user.
Example:
Stateless Buttons
_ A button is basically a control on the screen that you click or you press a key onto
and it performs some simple action.
_ It doesn’t keep track of any thing, it is just a stateless button.
_ Clicking a button fires an event called click event meaning that you have clicked this
button.
_ So what we can do is we can double click on this button to create our click event.
• Accept button
• Cancel button
Buttons with State
_ Buttons that keep track of their current state.
• Radio buttons
• Check boxes
• Grouping:
_ Basically a container we can use to separate items.
_ Allows to have multiple sections of radio buttons.
Textbox Control
_ Allows us to write things to the user and read things from the user.
_ It is basically a control that contains text, and the text unlike the label is
editable at runtime by the user.
• Text property
• Multiline textbox
• Password box