Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
else Keyword | Control Structures
C# Basics
course content

Contenido del Curso

C# Basics

C# Basics

1. Getting Started
2. Dealing with Data Types
3. Control Structures
4. Loops
5. Arrays
6. Methods

bookelse Keyword

There is an else keyword which can be used for executing a block of code if the condition is not met.

Syntax:

Example:

cs

main

copy
12345678910111213141516171819
using System; namespace ConsoleApp { internal class Program { static void Main(string[] args) { int x = 5; int y = 7; if(x > y) { Console.WriteLine("x is greater than y"); } else { Console.WriteLine("x is equal or less than y"); } } } }

The following diagram explains the flow of if-else statement:

What keyword is used for executing a piece of code if condition is not met in a conditional statement?

What keyword is used for executing a piece of code if condition is not met in a conditional statement?

Selecciona la respuesta correcta

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 3. Capítulo 7
some-alt