Nested if statements are nothing but if statement blocks within if statement blocks. Similarly, we can nest else if statement blocks. This is a simple code snippet:
private static void NestedIfStatementExample()
{
WriteLine("nested if statement example.");
Write("Enter your age:");
int age = Convert.ToInt32(ReadLine());
if (age < 18)
{
WriteLine("Your age should be equal or greater than 18yrs.");
if (age < 15)
{
WriteLine("You need to complete your school first");
}
}
}