Return the number for the specified month by the specified number. - CSharp System

CSharp examples for System:DateTime Month

Description

Return the number for the specified month by the specified number.

Demo Code


using System.Collections;
using System;//from   ww w.  j  av a 2  s .c  o  m

public class Main{
        /// <summary>
        /// Return the number for the specified month by the specified number.
        /// </summary>
        /// <param name="number">The month number</param>
        /// <returns>The name of a given month</returns>
        public static string GetMonthName(int number) {
            switch (number) {
                case (0):
                case (1):
                    return "January";
                case (2):
                    return "February";
                case (3):
                    return "March";
                case (4):
                    return "April";
                case (5):
                    return "May";
                case (6):
                    return "June";
                case (7):
                    return "July";
                case (8):
                    return "August";
                case (9):
                    return "September";
                case (10):
                    return "October";
                case (11):
                    return "November";
                case (12):
                    return "December";
                default:
                    return "January";
            }
        }
}

Related Tutorials