我有以下用于日历的 buildculture 功能:
private void buildCulture(string culture, string calendarType)
{
CultureInfo ci=null;
try
{
if (string.IsNullOrEmpty(culture))
{
ci = System.Threading.Thread.CurrentThread.CurrentCulture;
}
else
{
try
{
ci = new CultureInfo(culture);
}
catch (System.ArgumentException)
{
ci = System.Threading.Thread.CurrentThread.CurrentCulture;
}
}
// Calendar is from system.windows.control.calendar,
// ci is from system.globalization.calendar:
Calendar originalCal = ci.Calendar;
if (!string.IsNullOrEmpty(culture) ||
originalCal.ToString().Replace("System.Globalization.", "") != culture)
{
foreach (Calendar supportCal in ci.OptionalCalendars)
{
if (calendarType ==
supportCal.ToString().Replace("System.Globalization.", ""))
{
ci.DateTimeFormat.Calendar = supportCal;
}
}
}
}
}
此功能在 .net 3.5 版中仍然有效。但是在我升级到 .net 4.5 后,出现以下行的错误Calendar originalCal = ci.Calendar:Calendar is an ambiguous reference between system.windows.control.calendar and system globalization.calendar.
我们如何解决这些家伙?
慕盖茨4494581
绝地无双
相关分类