Switch Case in C# MVC

2309
Views
1
Answers

How to implement Switch case in Asp.net MVC?

edit | flag
William Patrick
Asked on: Jun 16, 2011 at 4:59AM

1 Answers

15
5
15

Try this..

string month;
int monthNumber = 3;

        switch (monthNumber) {

       
case 1:

             month
="January";

             
break;

       
case 2:

            month
="February";

             
break;

       
case 3:

             month
="March";

             
break;

       
case 4:

            month
="April";

             
break;

       
case 5:

            month
="May";

             
break;

       
case 6:

             month
="June";

             
break;

       
case 7:

             month
="July";

             
break;

       
case 8:

              month
="August";

             
break;

       
case 9:

             month
="September";

             
break;

       
case 10:

             month
="October";

             
break;

       
case 11:

             month
=November";

              break;

        case 12:

             month="
December";

              break;

        default:

              month="
Invalid month.";

              break;

        }
edit | flag
Gokul A
Answered on: Jun 16, 2011 at 8:34PM

Post your Answer

Search

Welcome to Ask Amoeba!
This is 100% free and interactive site for sharing professional Questions and Answers, Opensource projects, Interview questions.
Learners, beginners, Experts stop and share your knowledge and ideas!

Browse Categories

Browse Tags