4 c# programming constructs

15

Click here to load reader

Upload: tuan-ngo

Post on 10-May-2015

1.257 views

Category:

Technology


9 download

TRANSCRIPT

Page 1: 4   c# programming constructs

C# programming Constructs

[email protected]

Programming in C#

Page 2: 4   c# programming constructs

Selection Constructs

Page 3: 4   c# programming constructs

Selection Constructs

if…else…if http://pastebin.com/cRw1mL1d

Page 4: 4   c# programming constructs

Selection Constructs

Switch…case http://pastebin.com/7kNQwQaY

The expression must be int, char, byte or short.

Page 5: 4   c# programming constructs

Loop Constructs

Page 6: 4   c# programming constructs

Selection Constructs

while (pre-test loop) http://pastebin.com/1WPRbaed

Page 7: 4   c# programming constructs

Selection Constructs

do-while(post-test loop) http://pastebin.com/jnNvyB07

Page 8: 4   c# programming constructs

Selection Constructs

for(post-test loop) https://gist.github.com/2318139

Page 9: 4   c# programming constructs

Selection Constructs

nested for

for(initial, condition, increment/decrement) {

for(initial, condition, increment/decrement)

{

….

} }

Page 10: 4   c# programming constructs

Selection Constructs

foreach https://gist.github.com/2318146

foreach(<datatype> <indentifier> in <list>) { }

Page 11: 4   c# programming constructs

Jump Statements

Page 12: 4   c# programming constructs

Break

is used in the selection and loop constructs.

http://pastebin.com/1ENSu2f9

Page 13: 4   c# programming constructs

Continue

mostly used in loop constructs.

end the current iteration of the loop and begin another

http://pastebin.com/QzZSVZhP

Page 14: 4   c# programming constructs

Goto

directly execute a labeled statement or a labeled block of statement cannot use goto inside for, while or do-while loops.

http://pastebin.com/1Pk2f7fE

Page 15: 4   c# programming constructs

Return