3. Topics
• What is Programming
• Machine Code VS. Programming Languages
• Why C#
• Visual Studio (IDE)
• .NET Framework
• Windows Desktop (Console, Form) Applications
• DEMO
25. 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;
26. Data Types
• bool
• char
• string
• byte
• short
• int
• long
• float
• double
…..
39. 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( ) { }
50. 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
51. While
_ Loop while a condition is true.
_ Checks condition at the beginning of the loop.
• Example 1: • Example 2:
52. Do While
_ Loop while a condition is true.
_ Checks condition at the end of the loop.
Example1
60. 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:
61. 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:
62. Return
_ Return allows us to pass something into our function and then it is going to kick
things back to us.
• Example 1:
68. 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:
69. 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
71. 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.
76. 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