Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

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

day = Choose(month,31,28,30) 
like image 561
Mike Avatar asked Mar 17 '10 13:03

Mike


People also ask

Why is there a slash in AC?

Senior Member. You read it as "ei-cee" (no "slash" pronounced). In terms of distinguishing between "air conditioning" and "air conditioner," I can think of an example like "Today, I bought a new air conditioner" ("conditioning" not allowed). I personally would not say "Today, I bought a new AC."

What is the mean of AC?

uncountable noun. a/ c is an abbreviation for air-conditioning. Keep your windows up and the a/c on high.

Why is it called AC?

Air conditioning, often abbreviated as A/C or AC, is the process of removing heat from an enclosed space to achieve a more comfortable interior environment (sometimes referred to as 'comfort cooling') and in some cases also strictly controlling the humidity of internal air.


1 Answers

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
like image 105
Jørn Schou-Rode Avatar answered Nov 13 '22 14:11

Jørn Schou-Rode