Posted by : Anwar Hossain
Category : asp.net c # basic tutorial

Nested switch-case statement example in C #

Dear viewers in this tutorial I will explain simple nested switch case statement in asp.net c #. In our practical working we need to take nested decision to find right result. The following example helps anyone to understand nested  switch case statement easily and clearly. The first switch case take decision the person is men or women then the next that means inner switch case take decision that the person married or unmarried.

Nested switch case statement example in C #

 

Nested switch case example in C Sharp

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

 

namespace NestedswitchcaseStatement

{

    class Program

    {

        static void Main(string[] args)

        {

 

            string Men = "Men";

 

            string MartialStatus = "UnMarried";

 

            switch (Men)

            {

                case "Men":

                    switch (MartialStatus)

                    {

                        case "Married":

                            Console.WriteLine("The Person is Men and Married");

                            break;

                        case "UnMarried":

                            Console.WriteLine("The Person is Men and UnMarried");

                            break;

                    }

                    break;

 

                case "Women":

                    switch (MartialStatus)

                    {

                        case "Married":

                            Console.WriteLine("The Person is Women and Married");

                            break;

                        case "UnMarried":

                            Console.WriteLine("The Person is Women and UnMarried");

                            break;

                    }

                    break;

 

                default:

                    Console.WriteLine("The person is not  Men or Women");

                    break;

            }

            Console.ReadLine();

 

    

           

 

          

        }

    }

}

Out Put

Nested-switch-case-c-Sharp



Realted Article Headline

How to find odd number in c #
How to generate random number in c #
Nested For Loop Example in C Sharp
Store C sharp reference type in a List C#
Find number of items in a List C#
Concept about C # List
Custom Time formatting example C #
Custom Date formatting example C #
String Format Example using ASP.Net C#
Simple enum example in C Sharp
Nested switch-case statement example in C #
Combined switch...case statement example in C #
C Sharp switch case statement Example
C# SUM ArrayList Element Example
C# String Class Methods Example
C Sharp String Class Properties and Methods
C Sharp String Class Example
How to join two ArrayList collections in C#.
How to Use C Sharp Math Class
C Sharp ArrayList Property and Method
C Sharp ArrayList Example
C Sharp Arrays Example
C Sharp Logical operator Example
C Sharp Relational operators
C Sharp Arithmetic operators Example
C Sharp Common Assignment Operator
Simple for loop example in c sharp

Article Category

How to create asp.net control dynamically
Learn HTML for beginner
DataList example in C Sharp
Mail sending in asp.net c#
State Management in ASP C #
Basic sql tutorial for Beginner
DataTable example in ASP.Net C#
How to use LINQ in ASP.NET C#
asp.net c # basic tutorial
How to use ajax toolkit in asp.net C#
How to use different types of validation control using asp.net c#
How to use grid view in asp.net c#
Protected by Copyscape Online Plagiarism Detection