改成CurrentInfo 也可,但结果有所不同
Response.Write(DateTime.Parse("1/2/3",DateTimeFormatInfo.CurrentInfo ));
Response.Write(DateTime.Parse("1/2/3",DateTimeFormatInfo.InvariantInfo));因为InvariantInfo和CurrentInfo都是静态的static ,所以可以如此调用
同理ShortDatePattern 或其他均不可
Response.Write(DateTime.Parse("1/2/3",DateTimeFormatInfo.CurrentInfo ));
Response.Write(DateTime.Parse("1/2/3",DateTimeFormatInfo.InvariantInfo));因为InvariantInfo和CurrentInfo都是静态的static ,所以可以如此调用
同理ShortDatePattern 或其他均不可
这句加上DateTimeFormatInfo.InvariantInfo这参数是不是说明转换成datetime的类型,还是什么其他意思?也就是说起什么作用?
2、为什么不是static就不可如此调用?
2.看看相关的C#参考书,上面对静态变量的作用及用法说得很清楚.