显示格里高利历作为Hijri日历asp.net Web表单

时间:2015-12-29 06:48:58

标签: c# asp.net vb.net calendar

我需要在asp.net webform中显示Hijri日历。为此,我尝试使用以下代码,实际上是在VB版本http://findanycode.com/54laAAnmwlGw/how-to-display-arabic-dates-in-the-gregorian-calendar.html

我将此代码转换为C#,但它没有编译

它让我对Foreach循环表示厌恶,声明查询正文必须以select子句结束

CultureInfo ci = CultureInfo.CreateSpecificCulture(" ar-SA");

     Response.Write("<table width=300px>");

foreach (CultureInfo ci in (from c in CultureInfo.GetCultures(CultureTypes.AllCultures) orderby c.Name where c.Name.StartsWith("ar-ae")))
        {
                Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(ci.Name);
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(ci.Name);
                Response.Write(string.Format("<tr><td>{0}</td> <td style='direction:rtl;font-size:20px;'>{1:d MMMM yyyy}</td></tr>", ci.Name, Today));

        }

Response.Write("</table>");
Response.End();

1 个答案:

答案 0 :(得分:1)

错误本身告诉您在过滤数据后必须选择一些内容,因此您的linq查询应该是

from c in CultureInfo.GetCultures(CultureTypes.AllCultures) orderby c.Name where c.Name.StartsWith("ar-AE") select c;

您也可以使用下面提到的查询

CultureInfo.GetCultures(CultureTypes.AllCultures).Where(p => p.Name.StartsWith("ar-AE")).OrderBy(q => q.Name);

您使用了ar-ae它应该是ae-AE

相关问题