C# Tips

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()


posted @ 2011-12-28 17:38  BiG5  阅读(130)  评论(0编辑  收藏  举报