.NET(C#)代码性能优化

①string ax=string.Empty;     
6ne ~b Kg0注:不要使用: string ax="";  I don't konw why.But it's Microsoft's convention.
0Ys0[ x3tEb Y0判断ax是否为空:
g%xjC%R&W0ax.Length==0   >  ax==string.EmptyITPUB个人空间 }'t9JK"eB


    Info         : "To test for empty strings, check if String.Length is ITPUB个人空间7CG HN}3s/l
                   equal to zero. Constructs such as "".Equals(someString) ITPUB个人空间:|P/o#SsvH}
                   and String.Empty.Equals(someString) are less efficient
x{sr9e*I ? r'h&b0                   than testing the string length. Replace these with
F)@&?]vA:g%s0r0                   checks for someString.Length == 0."

KM#c d5D ];d0
n6F gr4e6y*N]UA$E0②Catch{}要捕获详细异常,不要再乱抛ITPUB个人空间O6N$a0LG-~$VV+R
catch the specific exception than "System.Exception" or rethrow the exception.ITPUB个人空间~XUG/v&iPA'd&{}
Catching generic exception types can hide run-time problems from the library user,ITPUB个人空间3o3[0W"Eph^
and can complicate debugging.

③比较字符串时不要用.ToLower()   /   .ToUpper()
I2H O G;pqT&M#N0replace by Equals()     
?'wgE }.l(W0Don't create a string never used later.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值