日期:2014-05-18  浏览次数:20422 次

|M| 今天看了别人写的一个SqlHelper 大家看看这里是什么意思
if   (connection   ==   null)
        {
                throw   new   ArgumentNullException( "connection ");
        }
---------------------------------
public   ArgumentNullException(string   paramName)   :   base(Environment.GetResourceString( "ArgumentNull_Generic "),   paramName)
{
        base.SetErrorCode(-2147467261);
}

------------------------------------
我一般是写
  if   (connection   ==   null)
        {
                throw   new   Exception( "未建立数据库连接 ");
        }
请问一下他上面是什么意思
为什么要这样写
还有我写的有什么不足

------解决方案--------------------
它的Expection更准确,你的只是个模糊的Exception
------解决方案--------------------
还有你是从Reflector里看的代码吧?

------解决方案--------------------
catch到更具体的exception,就能够做相应的错误处理

------解决方案--------------------
up一下
~
it 's time going
------解决方案--------------------
自己定义了一个异常类,然后返回一个这样的异常
------解决方案--------------------
知道错了,还要知道是什么错..
------解决方案--------------------
GZ+SC
关注加收藏:)
------解决方案--------------------
Environment.GetResourceString( "ArgumentNull_Generic ") 从资源文件中取 ArgumentNull_Generic对应的值.
------解决方案--------------------
来晚了,楼上说完了