Link to home
Start Free TrialLog in
Avatar of DylanJones1
DylanJones1

asked on

C# Month number to Month Name

Is there a simple C# function that when given an int  1 - 12 will return the string name for the month - January
Avatar of Darren
Darren
Flag of Ireland image

MessageBox.Show(MonthName(12))
Hope this helps
Sorry thats VB
Avatar of DylanJones1
DylanJones1

ASKER

Looks like excatly what I want  what do I need to  reference (using) to get it to work?
Yep just add

Using Microsoft.VisualBasic ;
SOLUTION
Avatar of DotNetThinker
DotNetThinker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Seems that you may have to create your own.

Pitty though.
I got it ti work

Have to add a reference to the Microsoft.VisualBasic assembly and then call then the following code will work

using Microsoft.VisualBasic;

MessageBox.Show(DateAndTime.MonthName(12,false));
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Very nice touch, Bob.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I normally use justdriveon's approach.  Doesn't require the "using Microsoft.VisualBasic;"
It would make sense if someone didn't know it was there.  Look at how deep you have to look into the .NET framework to find it.

Bob
Thanks All!!!