I have a string which has short month name in it.\
string month = "Jun";
I need to get month in digit from this month name.
Say i do this:
int monthInDigit = getMonth(month);
monthInDigit <-- 6
How can i achieve this. If you cant get my question pleases comment i will explain it proprly.
Thanxx in advance
int monthInDigit = DateTime.ParseExact(month, "MMM", CultureInfo.InvariantCulture).Month;
You can parse it to a DateTime
first:
DateTime dt = DateTime.ParseExact("Jun", "MMM", CultureInfo.InvariantCulture);
int month = dt.Month;
if(month < 6)
{
// do something...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With