当前位置: 首页>>代码示例>>C#>>正文


C# DateTimeFormatInfo.GetMonthName方法代码示例

本文整理汇总了C#中DateTimeFormatInfo.GetMonthName方法的典型用法代码示例。如果您正苦于以下问题:C# DateTimeFormatInfo.GetMonthName方法的具体用法?C# DateTimeFormatInfo.GetMonthName怎么用?C# DateTimeFormatInfo.GetMonthName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DateTimeFormatInfo的用法示例。


在下文中一共展示了DateTimeFormatInfo.GetMonthName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetMonthName

 public void GetMonthName(DateTimeFormatInfo format, string[] expected)
 {
     for (int i = MinMonth; i <= MaxMonth; ++i)
     {
         Assert.Equal(expected[i], format.GetMonthName(i));
     }
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:7,代码来源:DateTimeFormatInfoGetMonthName.cs

示例2: VerificationHelper

    private bool VerificationHelper(DateTimeFormatInfo info, string[] expected, string errorno)
    {
        bool retval = true;

        for (int i = c_MIN_MONTH_VALUE; i <= c_MAX_MONTH_VALUE; ++i)
        {
            string actual = info.GetMonthName(i);
            if (actual != expected[i])
            {
                TestLibrary.TestFramework.LogError(errorno + "." + i, "GetAbbreviatedDayName returns wrong value");
                TestLibrary.TestFramework.LogInformation("WARNING[LOCAL VARIABLES] i = " + i + ", expected[i] = " + expected[i] + ", actual = " + actual);
                retval = false;
            }
        }

        return retval;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:17,代码来源:datetimeformatinfogetmonthname.cs

示例3: NegTest1

    public bool NegTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("NegTest1: ArgumentOutOfRangeException should be thrown when dayofweek is not a valid System.DayOfWeek value. ");

        try
        {
            DateTimeFormatInfo info = new DateTimeFormatInfo();

            info.GetMonthName(c_MIN_MONTH_VALUE - 1);

            TestLibrary.TestFramework.LogError("101.1", "ArgumentOutOfRangeException is not thrown");
            retVal = false;
        }
        catch (ArgumentOutOfRangeException)
        {
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("101.2", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        try
        {
            DateTimeFormatInfo info = new DateTimeFormatInfo();

            info.GetMonthName(c_MAX_MONTH_VALUE + 1);

            TestLibrary.TestFramework.LogError("101.3", "ArgumentOutOfRangeException is not thrown");
            retVal = false;
        }
        catch (ArgumentOutOfRangeException)
        {
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("101.4", "Unexpected exception: " + e);
            TestLibrary.TestFramework.LogInformation(e.StackTrace);
            retVal = false;
        }

        return retVal;
    }
开发者ID:CheneyWu,项目名称:coreclr,代码行数:46,代码来源:datetimeformatinfogetmonthname.cs

示例4: VerificationHelper

 private void VerificationHelper(DateTimeFormatInfo info, string[] expected)
 {
     for (int i = c_MIN_MONTH_VALUE; i <= c_MAX_MONTH_VALUE; ++i)
     {
         string actual = info.GetMonthName(i);
         Assert.Equal(expected[i], actual);
     }
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:8,代码来源:DateTimeFormatInfoGetMonthName.cs

示例5: TestInvalidDayOfWeek

        public void TestInvalidDayOfWeek()
        {
            DateTimeFormatInfo info1 = new DateTimeFormatInfo();
            Assert.Throws<ArgumentOutOfRangeException>(() =>
            {
                info1.GetMonthName(c_MIN_MONTH_VALUE - 1);
            });

            DateTimeFormatInfo info2 = new DateTimeFormatInfo();
            Assert.Throws<ArgumentOutOfRangeException>(() =>
           {
               info2.GetMonthName(c_MAX_MONTH_VALUE + 1);
           });
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:14,代码来源:DateTimeFormatInfoGetMonthName.cs

示例6: GetPeriodDescription

 protected string GetPeriodDescription(int value, int year)
 {
     int groupBy = Utils.GetIntegerOnly(ddlGroupBy.SelectedValue);
     if (groupBy == 0) {
         DateTime firstDayOfYear = new DateTime(year, 1, 1);
         DateTime dateTime = firstDayOfYear.AddDays(value - 1);
         return dateTime.Day.ToString("00") + "." + dateTime.Month.ToString("00");
     } else if (groupBy == 1) {
         return "Week " + value;
     } else if (groupBy == 2) {
         DateTimeFormatInfo dtfi = new DateTimeFormatInfo();
         return dtfi.GetMonthName(value);
     } else if (groupBy == 3) {
         return value.ToString();
     } else if (groupBy == 4) {
         return "Q" + value.ToString();
     }
     return value.ToString();
 }
开发者ID:kyvkri,项目名称:MG,代码行数:19,代码来源:ReportsPage.aspx.cs

示例7: Page_Init

 protected void Page_Init(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         for (int day = 1; day < 32; day++)
         {
             ListItem li = new ListItem();
             li.Text = day.ToString();
             li.Value = day.ToString();
             ddldate.Items.Add(li);
         }
         DateTimeFormatInfo dtfi = new DateTimeFormatInfo();
         for (int month = 1; month < 13; month++)
         {
             ListItem li = new ListItem();
             li.Text = dtfi.GetMonthName(month);
             li.Value = month.ToString();
             ddlmonth.Items.Add(li);
         }
         int thisYear = System.DateTime.Now.Year;
         int startYear = thisYear - 16;
         for (int year = startYear; year > startYear - 100; year--)
         {
             ListItem li = new ListItem();
             li.Text = year.ToString();
             li.Value = year.ToString();
             ddlyear.Items.Add(li);
         }
     }
 }
开发者ID:unifamz,项目名称:UniversityManagementSystem,代码行数:30,代码来源:registeration.aspx.cs


注:本文中的DateTimeFormatInfo.GetMonthName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。