”
Microsoft.Globalization : Because the behavior of ‘int.Parse(string)’ could vary based on the current user’s locale settings, replace this call in ‘_Default.CalculateImageButton_Click(object, ImageClickEventArgs)’ with a call to ‘int.Parse(string, IFormatProvider)’. If the result of ‘int.Parse(string, IFormatProvider)’ will be displayed to the user, specify ‘CultureInfo.CurrentCulture’ as the ‘IFormatProvider’ parameter. Otherwise, if the result will be stored and accessed by software, such as when it is persisted to disk or to a database, specify ‘CultureInfo.InvariantCulture’.”
这意味着当你读到“1234”从数据文件或数据库记录,然后试图通过解析丢给Int,你会得到1234在美国和德国。警告给好的建议——如果你与用户互动,指定CurrentCulture(感谢安德鲁!),如果你与一个文件系统或数据库交互(或任何东西!用户),使用InvariantCulture