Is there a C# equivalent of VB6's Choose() function?

c#

Solution

Not really. You can of course create an array an use its indexed getter:

day = new[] { 31, 28, 30 }[month];

Alternatively, you could - I wouldn't - import the `Microsoft.VisualBasic` namespace and do:

day = Interaction.Choose(month, 31, 28, 30);

I do not know how much your example is simplified, but in the case that you are actually looking for a way to find the numbers of days in a specific month, try `DateTime.DaysInMonth()`:

day = DateTime.DaysInMonth(2008, 2);
// day == 29

Problem

Is there a C# equivalent of VB6's Choose() function? ``` day = Choose(month,31,28,30) ```

Original source