C# Tips

来源:互联网 发布:淘宝冠军店铺 编辑:程序博客网 时间:2024/05/08 13:40
1. 十六进制和十进制的相互转换
//z 2011-12-28 5:37 PM is2120@csdn
int decValue = 2120;

将十进制转换为 十六进制
string hexValue =decValue.ToString("X");

将十六进制转回十进制
int decAgain = int.Parse(hexValue,System.Globalization.NumberStyles.HexNumber);

2. Input string was not in a correct format.
Unhandled Exception: System.FormatException: Input string was not in a correct format.
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolea
n parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)


//z 2011-12-28 5:40 PM is2120@csdn
出现这个错误的几种情况:
int.Parse (“”);
int.Parse (null);
int.Parse (string.Empty);
int.Parse ("2120D@is2120");

//z 2011-12-28 5:40 PM is2120@csdn

3. 得到当前方法相关信息
System.Reflection.MethodBase.GetCurrentMethod()


原创粉丝点击