C.7. Kontrollstrukturen

NameBedeutungBeispiel
if (else)Verzweigung
if (Zahl != 0)
  Kehrwert = 1/Zahl;
else
  Text = "nicht teilbar";
switch caseMehrfachauswahl
switch (Variable)
{
   case 1 : Text = "Eins";
   case 2 : Text = "Zwei";
}
whileWiederholung
while (x < 10)
   x++;
do whileWiederholung
do
{ x++; }
while (x < 10);
forZählschleife
for (i = 1; i < 10; i++)
  x = 2*i;
foreachZählschleife
foreach (Element in Daten)
  Element = "";
try catchFehlerkontrolle
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.