.NET Get month names using System.Globalization.DateTimeFormatInfo

By Jatin Prajapati

In this FAQ we will see how to get month names using System.Globalization.DateTimeFormatInfo class.

By using System.Globalization.DateTimeFormatInfo class we can get month names for our use. Please see the below example.

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {
        string[] monthNames = System.Globalization.DateTimeFormatInfo.CurrentInfo.MonthNames;
        foreach (string s in monthNames)
             Response.Write(string.Format("{0}<br/>", s));
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Get Month names</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        
     </div>
    </form>
</body>
</html>

.NET Get month names using System.Globalization.DateTimeFormatInfo  (1070 Views)