Catching Exception inside Using statement

后端 未结 9 700
不知归路
不知归路 2021-02-04 01:27

I know that Using statement disposes out the object that is being created. Like if I wanted to do something like this:

    Using(SqlConnection conn = new SqlConn         


        
9条回答
  •  猫巷女王i
    2021-02-04 02:15

    class SqlConnection
    {
       using(sqlConnection)
       {
    
       }
    }
    
    class Consumer
    {
       try
      {
    
      }
      catch(SqlException)
      {
    
      }
    
    }
    

    It is up to the consumer of the class to decide what to do with the exception.

提交回复
热议问题