本文整理汇总了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));
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
});
}
示例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();
}
示例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);
}
}
}