Month To String - CSharp System

CSharp examples for System:DateTime Month

Description

Month To String

Demo Code


using System;/*w  ww.  j  a  va2s  .co  m*/

public class Main{
        public static string MonthToString(int m)
		{
			string result = m.ToString();
			switch (m) {
				case 1:
					result = "Jan";
                    break;
				case 2:
					result = "Feb";
                    break;
				case 3:
					result = "Mar";
                    break;
				case 4:
					result = "Apr";
                    break;
				case 5:
					result = "May";
                    break;
				case 6:
					result = "Jun";
                    break;
				case 7:
					result = "Jul";
                    break;
				case 8:
					result = "Aug";
                    break;
				case 9:
					result = "Sep";
                    break;
				case 10:
					result = "Oct";
                    break;
				case 11:
					result = "Nov";
                    break;
				case 12:
					result = "Dec";
                    break;
			}
			return result;
		}
}

Related Tutorials