C.7. Kontrollstrukturen
Name | Bedeutung | Beispiel |
---|---|---|
if (else) | Verzweigung | if (Zahl != 0) Kehrwert = 1/Zahl; else Text = "nicht teilbar"; |
switch case | Mehrfachauswahl | switch (Variable) { case 1 : Text = "Eins"; case 2 : Text = "Zwei"; } |
while | Wiederholung | while (x < 10) x++; |
do while | Wiederholung | do { x++; } while (x < 10); |
for | Zählschleife | for (i = 1; i < 10; i++) x = 2*i; |
foreach | Zählschleife | foreach (Element in Daten) Element = ""; |
try catch | Fehlerkontrolle | Try { Ergebnis = 1/Zahl; } catch { Text = "Zahl = 0?"; } |
Get Spieleprogrammierung mit dem XNA Framework: Entwickeln für PC und Xbox now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.