try-catch blocks with the return type

后端 未结 11 1927
半阙折子戏
半阙折子戏 2021-02-07 14:02

If I have a method that returns something, like

public DataTable ReturnSomething()
{
   try
   {  
      //logic here
     return ds.Tables[0];
   }
   catch (Ex         


        
11条回答
  •  借酒劲吻你
    2021-02-07 14:44

    It depends on you application. You can return null, an empty DataTable or whatever is suitable under circumstances.

提交回复
热议问题