কম্পিউটার টিউটোরিয়াল

C#-এ নেস্টেড if স্টেটমেন্ট ব্যবহার

একটি if বা else if স্টেটমেন্ট অন্য একটি if বা else if স্টেটমেন্টের ভিতরে ব্যবহার করুন। নেস্টেড if স্টেটমেন্টের সিনট্যাক্স নিচের মতো:

if( boolean_expression 1) { 
    /* Executes when the boolean expression 1 is true */ 
    if(boolean_expression 2) { 
        /* Executes when the boolean expression 2 is true */ 
    } 
}

নিচে C#-এ নেস্টেড if স্টেটমেন্ট ব্যবহারের একটি উদাহরণ দেওয়া হলো। এখানে, দুটি if স্টেটমেন্ট আছে যা দুটি শর্ত যাচাই করে।

if (a == 5) { 
    /* if condition is true then check the following */ 
    if (b == 10) { 
        /* if condition is true then print the following */ 
        Console.WriteLine("Value of a is 5 and b is 10"); 
    } 
}

সম্পূর্ণ উদাহরণ

using System; 
namespace Demo { 
    class Program { 
        static void Main(string[] args) { 
            //* local variable definition */ 
            int a = 5; 
            int b = 10; 
            /* check the boolean condition */ 
            if (a == 5) { 
                /* if condition is true then check the following */ 
                if (b == 10) { 
                    /* if condition is true then print the following */ 
                    Console.WriteLine("Value of a is 5 and b is 10"); 
                } 
            } 
            Console.WriteLine("Exact value of a is : {0}", a); 
            Console.WriteLine("Exact value of b is : {0}", b); 
            Console.ReadLine(); 
        } 
    } 
}

আউটপুট

Value of a is 5 and b is 10 
Exact value of a is : 5 
Exact value of b is : 10
  1. এক্সেলে IF এবং নেস্টেড IF স্টেটমেন্ট ব্যবহারের পদ্ধতি

  2. জাভাতে If...Else স্টেটমেন্ট ব্যবহার করার পদ্ধতি

  3. জাভাস্ক্রিপ্টে নেস্টেড while loop ব্যবহার করার উপায়

  4. অ্যান্ড্রয়েড লিস্টভিউতে নেস্টেড অ্যারে ব্যবহার