Lecture 5 - Conditional Statements
Lecture 5 - Conditional Statements
https://sites.google.com/a/quest.edu.pk/dr-irfana-memon/lecture-slides
C# Programming
language constructs,
Creating Methods,
3
C# Conditional statements
• if construct
• if...else construct
• if...else if construct
• Nested if construct
5
C# Conditional statements
• if statement construct:
6
C# Conditional statements
• if...else construct
if (boolean-expression)
{
// statements executed if boolean- expression is true
}
7
C# Conditional statements
• if...else construct using System;
class Fund
if (boolean-expression) {
{ public static void Main()
// statements executed if boolean- {
expression is true int x1 = 50;
} int x2 = 100;
else if(x1>x2)
16
C# switch construct
using System;
class Switchexample
{
public static void Main()
{
int wday = 2;
switch(wday)