1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

31
1 of 31 Images from Africa

Transcript of 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

Page 1: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

1 of 31

Images from Africa

Page 2: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

2 of 31

My little Haitian friend Antoine (1985)

Page 3: 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/

Page 4: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

4 of 31

3D Touch Table

Page 5: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

5 of 31

Overview

Variables & ExpressionsBasic C# SyntaxCommentsDeclaring & initializing variables

Flow controlBoolean logicBranching & looping

Advanced typesenum, struct, Array

Type conversionsFunctionsVariable scope

Page 6: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

6 of 31

Basic C# Syntax

Page 7: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

7 of 31

Comments

//, ///, /* */

Page 8: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

8 of 31

Declaring & Initializing variables

<type> <name>;<name> = <initial_value>;

OR<type> <name> = <initial_value>;

Page 9: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

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

Page 10: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

10 of 31

For real numbers …

Page 11: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

11 of 31

Most commonly used types

int

string

double

bool

char

Page 12: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

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.

Page 13: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

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

Page 14: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

14 of 31

Overview

Variables & ExpressionsBasic C# SyntaxCommentsDeclaring & initializing variables

Flow controlBoolean logicBranching & looping

Advanced typesenum, struct, Array

Type conversionsFunctionsVariable scope

Page 15: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

15 of 31

Boolean Logic

Page 16: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

16 of 31

Branching with if

Page 17: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

17 of 31

Branching with switch

Page 18: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

18 of 31

Looping with for

Page 19: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

19 of 31

Looping with while

If condition is false, while is not executed at all.

Page 20: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

20 of 31

Looping with do

Executed once before condition is checked

Page 21: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

21 of 31

Interrupting loops

breakExit from loop

continueReturn to top of loop

returnExit from loop & containing function

Page 22: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

22 of 31

Overview

Variables & ExpressionsBasic C# SyntaxCommentsDeclaring & initializing variables

Flow controlBoolean logicBranching & looping

Advanced typesenum, struct, Array

Type conversionsFunctionsVariable scope

Page 23: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

23 of 31

Advanced types – enum

To constrain the possible values for a variableDeclared at same level as classPlain text names associated with number

Page 24: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

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

Page 25: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

25 of 31

Advanced types – Array

Making it easier to create/access groups of values of the same type

Page 26: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

26 of 31

Overview

Variables & ExpressionsBasic C# SyntaxCommentsDeclaring & initializing variables

Flow controlBoolean logicBranching & looping

Advanced typesenum, struct, Array

Type conversionsFunctionsVariable scope

Page 27: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

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

Page 28: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

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.

Page 29: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

29 of 31

Params by ref and by value

Page 30: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

30 of 31

Variable Scope

Page 31: 1 of 31 Images from Africa. 2 of 31 My little Haitian friend Antoine (1985)

31 of 31

Funny if it wasn’t true

air transat ad

My version