c# - Getting compilation error with method: "not all code paths return a value" -


i can't figure out why keep getting compilation error: "not code paths return value". writing simple class method supposed return true if account available use , false if account not available or null/empty. code method below:

public static bool accountavailable(int accountid) {     try     {                     bool accountavailable;          string querytransaction = "select count(accountid) accounts accountid = " + accountid.tostring() + " , accountused = 0";          //grab connection database         database database = databasefactory.createdatabase();          //create instance of command         dbcommand command = database.getsqlstringcommand(querytransaction);          object dataobject = command.executescalar();          if (dataobject == null || string.isnullorempty(convert.tostring(dataobject)))         {             accountavailable = false;         }          else if (convert.toint32(dataobject) == 0)         {             accountavailable = false;         }          else if (convert.toint32(dataobject) > 0)         {             accountavailable = true;         }          else         {             accountavailable = true;         }          return accountavailable;     }      catch     {      } } 

any or advice on appreciated. thanks!!

if exception thrown in code before return value control moves catch block. reaches end of method without returning anything.

either return within, or after, catch block.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -