CultureInfo类的其中一个构造函数为:public CultureInfo (string name,bool useUserOverride),它的一个参数的解释为:useUserOverride
一个布尔值,它指示是使用用户选定的区域性设置 (true),还是使用默认区域性设置 (false)。
我想不懂的是,既然已经指定了name,比如说设置name参数为 "en-US", 那么还设置useUserOverride有用吗?我把它设置为TRUE或FALSE,出来的结果都是一样的,真不明白它所说的“使用用户选定的区域性设置”以及“使用默认区域性设置”到底是什么意思。 public static void Main()
{ // Creates and initializes a DateTimeFormatInfo associated with the en-US culture.
DateTimeFormatInfo myDTFI = new CultureInfo("en-US",false ).DateTimeFormat;//把此行的FALSE改为TRUE结果还是一样的,不知道为什么。
// Creates a DateTime with the Gregorian date January 3, 2002 (year=2002, month=1, day=3).
// The Gregorian calendar is the default calendar for the en-US culture.
DateTime myDT = new DateTime(2002, 1, 3); // Displays the format pattern associated with each format character.
Console.WriteLine(" d {0}", myDT.ToString("d"));
Console.WriteLine(" {0} {1}\n", myDTFI.ShortDatePattern, "(ShortDatePattern)");
Console.WriteLine(" D {0}", myDT.ToString("D"));
Console.WriteLine(" {0} {1}\n", myDTFI.LongDatePattern, "(LongDatePattern)");
}真是搞糊涂了,谁能指教一下?一遇到这种时间格式就不知怎么办!
一个布尔值,它指示是使用用户选定的区域性设置 (true),还是使用默认区域性设置 (false)。
我想不懂的是,既然已经指定了name,比如说设置name参数为 "en-US", 那么还设置useUserOverride有用吗?我把它设置为TRUE或FALSE,出来的结果都是一样的,真不明白它所说的“使用用户选定的区域性设置”以及“使用默认区域性设置”到底是什么意思。 public static void Main()
{ // Creates and initializes a DateTimeFormatInfo associated with the en-US culture.
DateTimeFormatInfo myDTFI = new CultureInfo("en-US",false ).DateTimeFormat;//把此行的FALSE改为TRUE结果还是一样的,不知道为什么。
// Creates a DateTime with the Gregorian date January 3, 2002 (year=2002, month=1, day=3).
// The Gregorian calendar is the default calendar for the en-US culture.
DateTime myDT = new DateTime(2002, 1, 3); // Displays the format pattern associated with each format character.
Console.WriteLine(" d {0}", myDT.ToString("d"));
Console.WriteLine(" {0} {1}\n", myDTFI.ShortDatePattern, "(ShortDatePattern)");
Console.WriteLine(" D {0}", myDT.ToString("D"));
Console.WriteLine(" {0} {1}\n", myDTFI.LongDatePattern, "(LongDatePattern)");
}真是搞糊涂了,谁能指教一下?一遇到这种时间格式就不知怎么办!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货