Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen If-Anweisung | Kontrollstrukturen
C# Grundlagen

bookIf-Anweisung

Eine if-Anweisung, auch bekannt als Bedingungsanweisung, ist eine Methode, um einen Codeblock basierend auf einer Bedingung auszuführen. Die Syntax einer if-Anweisung ist folgende:

if(condition) {
    // code to execute
}

Sie nimmt einen Ausdruck und führt den Codeblock aus, wenn der Ausdruck true ist.

Zum Beispiel:

main.cs

main.cs

copy
12345678910111213141516
using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { Console.WriteLine("Before Conditional"); if(10 > 9) { Console.WriteLine("10 is greater than 9"); } Console.WriteLine("After Conditional"); } } }

Falls die Bedingung false ist, wird der Codeblock ignoriert:

main.cs

main.cs

copy
12345678910111213141516
using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { Console.WriteLine("Before Conditional"); if(10 > 10) { Console.WriteLine("10 is greater than 9"); } Console.WriteLine("After Conditional"); } } }
question mark

Was ist die Ausgabe des folgenden Codes:

Select the correct answer

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 3. Kapitel 5

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

Suggested prompts:

Can you give an example of an if statement in JavaScript?

What happens if the condition is false?

Can you explain what types of expressions can be used in the condition?

Awesome!

Completion rate improved to 1.59

bookIf-Anweisung

Swipe um das Menü anzuzeigen

Eine if-Anweisung, auch bekannt als Bedingungsanweisung, ist eine Methode, um einen Codeblock basierend auf einer Bedingung auszuführen. Die Syntax einer if-Anweisung ist folgende:

if(condition) {
    // code to execute
}

Sie nimmt einen Ausdruck und führt den Codeblock aus, wenn der Ausdruck true ist.

Zum Beispiel:

main.cs

main.cs

copy
12345678910111213141516
using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { Console.WriteLine("Before Conditional"); if(10 > 9) { Console.WriteLine("10 is greater than 9"); } Console.WriteLine("After Conditional"); } } }

Falls die Bedingung false ist, wird der Codeblock ignoriert:

main.cs

main.cs

copy
12345678910111213141516
using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { Console.WriteLine("Before Conditional"); if(10 > 10) { Console.WriteLine("10 is greater than 9"); } Console.WriteLine("After Conditional"); } } }
question mark

Was ist die Ausgabe des folgenden Codes:

Select the correct answer

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 3. Kapitel 5
some-alt