.NET Get Week Days names from System.Globalization.DateTimeFormatInfo

By Jatin Prajapati

In this FAQ we will see how to get week day names using System.Globalization.DateTimeFormatInfo.

By using System.Globalization.DateTimeFormatInfo class we can get week day names. 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[] daysOfWeek = System.Globalization.DateTimeFormatInfo.CurrentInfo.DayNames;
        foreach (string s in daysOfWeek)
             Response.Write(string.Format("{0}<br/>", s));
    }
</script>

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

.NET Get Week Days names from System.Globalization.DateTimeFormatInfo  (1346 Views)