TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Maha
NA
0
326.5k
Turn an integer into a month name
Oct 3 2012 11:33 AM
In this program please explain the reason to have 1, monthNumber and four M. Problem is highlighted.
using System;
class Test
{
static void Main()
{
string s = GetMonth(1);
Console.WriteLine(s);
s = GetMonth(12);
Console.WriteLine(s);
Console.ReadKey();
}
static string GetMonth(int monthNumber)
{
if (monthNumber < 1 || monthNumber > 12)
throw new ArgumentOutOfRangeException();
return new DateTime(
1
,
monthNumber
,
1
).ToString("
MMMM
");
}
}
/*
January
December
*/
Reply
Answers (
2
)
C# calling an executable problem
What’s wrong with this program?