C# nested if-else Statement :

nested if-else Statement :

Sometimes the programming logic in a program or an application needs to be represented by multiple if-structures contained in each other. We call them nested if or nested if-else structures.

Example :

  1. /* Description: simple nested if-else program */
  2. using System;
  3. namespace DemoProgramming
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int first = 5,second = 3;
  10. if (first == second)
  11. {
  12. Console.WriteLine("These two numbers are equal.");
  13. }
  14. else
  15. {
  16. if (first > second)
  17. {
  18. Console.WriteLine("The first number is greater.");
  19. }
  20. else
  21. {
  22. Console.WriteLine("The second number is greater.");
  23. }
  24. }
  25. Console.ReadKey();
  26. }
  27. }
  28. }

Output :

C Sharp Language simple nested if-else program

Next Update

Loading...

We create a new YouTube channel (NightHawk) for gaming purpose like online games streaming or games review.

We need some time for make video tutorials (CodeX) so, stay with us and keep supporting and you know already we make a Collaboration with HackIsOn YouTube channel long time ago So, please Subscribe Our Channels

Protection died IPs active, this IP range is not allowed !