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)");
}真是搞糊涂了,谁能指教一下?一遇到这种时间格式就不知怎么办!
 

解决方案 »

  1.   

    http://topic.csdn.net/u/20100802/13/31198214-f41a-496c-a8d9-80d6876eef3b.html
      

  2.   

    楼上能不能说一下CultureInfo (string name,bool useUserOverride)里的参数问题??
      

  3.   

    哈哈,我终于弄明白了。原来只有当“name”参数和自己电脑上的区域是一样的,设置useUserOverride才是有意义的,否则不管把后者设置为True还是False都是没有效果的。当把"name"设置为“zh-CN”时,把useUserOverride设为TRUE或FALSE就有了作用。所以当name与电脑上的不一致时,还是使用CultureInfo (string name)更好些。Jesus cherist,我太笨了...我该怎么学编程啊...