Public string [] ListQureyDataReader ()
{
int i=0;
[DataCount string [] res2=new string ());
String res="";
SqlConnection SLQ=new SqlConnection (SQLSentence CreatStrCon (_serverAddress _databaseName));
String sqlStr=SQLTurnover. SelectOper (out res);
If (string. IsNullOrEmpty (sqlStr))
{
return;
}
How to write the return to perform certain error
How does a great god out of this function
CodePudding user response:
Return nullCodePudding user response:
A function returns a value, or throw throw exceptions, design should be standardized, are not allowed to "jump out" with a mind,CodePudding user response:
What to return values (object or null), this is actually the logical design problem, not writing code,CodePudding user response:
You can use the Win32 API style writing:
Public String ListQureyDataReader (String [] res2)
{
int i=0;
[DataCount res2=new string ()];
String res="";
SqlConnection SLQ=new SqlConnection (SQLSentence CreatStrCon (_serverAddress _databaseName));
String sqlStr=SQLTurnover. SelectOper (out res);
If (string. IsNullOrEmpty (sqlStr))
{
Return "the Result is empty.";
}
CodePudding user response:
Threw new Exception (${sqlStr} "does not allow null")CodePudding user response:
If you are really don't know what should be returned according to the function return value type, you can write aReturn the default; Except (void)