1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)
-
Upload
aleah-rufus -
Category
Documents
-
view
215 -
download
1
Transcript of 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)
1 of 31
Images from Africa
2 of 31
My little Haitian friend Antoine (1985)
3 of 31
Solid Terrain Models
http://www.stm-usa.com/
5 of 31
Overview
Variables & ExpressionsBasic C# SyntaxCommentsDeclaring & initializing variables
Flow controlBoolean logicBranching & looping
Advanced typesenum, struct, Array
Type conversionsFunctionsVariable scope
6 of 31
Basic C# Syntax
7 of 31
Comments
//, ///, /* */
8 of 31
Declaring & Initializing variables
<type> <name>;<name> = <initial_value>;
OR<type> <name> = <initial_value>;
9 of 31
Types – esp. Value
Apart from bool, char,& enum, value types havea range of numbers theysupport (p. 37)
Type Range
byte 0 to 255
sbyte -128 to 127
short -32768 to 32767
int -2147483648 to2147483647
10 of 31
For real numbers …
11 of 31
Most commonly used types
int
string
double
bool
char
12 of 31
Variable names & initial values
<type> <name> = <initial_value>;
Variable namesCannot
Be a C# keywordBegin with a number or special char except _ and @Contain numbers and chars (-, ', etc)
ShouldBe camelCaseDescribe the content
Initial values0 for numbers or what makes sense for appstring.Empty / "" for strings, etc.
13 of 31
Expressions<variable> = <operand> <operator> <operand><variable> = <operator> <operand><variable> = <operand>
Output
z = ++x // z assigned value x + 1z = x++ // z assigned value of x before x is incremented
14 of 31
Overview
Variables & ExpressionsBasic C# SyntaxCommentsDeclaring & initializing variables
Flow controlBoolean logicBranching & looping
Advanced typesenum, struct, Array
Type conversionsFunctionsVariable scope
15 of 31
Boolean Logic
16 of 31
Branching with if
17 of 31
Branching with switch
18 of 31
Looping with for
19 of 31
Looping with while
If condition is false, while is not executed at all.
20 of 31
Looping with do
Executed once before condition is checked
21 of 31
Interrupting loops
breakExit from loop
continueReturn to top of loop
returnExit from loop & containing function
22 of 31
Overview
Variables & ExpressionsBasic C# SyntaxCommentsDeclaring & initializing variables
Flow controlBoolean logicBranching & looping
Advanced typesenum, struct, Array
Type conversionsFunctionsVariable scope
23 of 31
Advanced types – enum
To constrain the possible values for a variableDeclared at same level as classPlain text names associated with number
24 of 31
Advanced types – struct
A custom, multi-valued, type that can have functions
Declared at same level as classCan contain value types (int, long, double, etc) and strings
25 of 31
Advanced types – Array
Making it easier to create/access groups of values of the same type
26 of 31
Overview
Variables & ExpressionsBasic C# SyntaxCommentsDeclaring & initializing variables
Flow controlBoolean logicBranching & looping
Advanced typesenum, struct, Array
Type conversionsFunctionsVariable scope
27 of 31
Type conversions
Types with smaller range can be implicitly converted to types with larger rangeOther types MAY be explicitly converted target_type outvar = (target_type) variableName
28 of 31
Functions: Defining and calling
Syntax for defining functions: [scope] [static] return_type name ([params]){ // C# statements [return [return_value]];}
0 or more params are declared like variables and comma separated.
29 of 31
Params by ref and by value
30 of 31
Variable Scope
31 of 31
Funny if it wasn’t true
air transat ad
My version