I try to rewrite this method using short-hand if:
public string checkInputParamters(string baseUrl, string owner, string documentId, string user, string secret, string type)
{
if (String.IsNullOrEmpty(baseUrl))
return ExceptionsCodes.BASE_URL_CANNOT_BE_NULL_OR_EMPTY.ToString("g");
if (String.IsNullOrEmpty(owner))
return ExceptionsCodes.OWNER_CANNOT_BE_NULL_OR_EMPTY.ToString("g");
return "";
}
I cannot do like this because return forces me to put a value after “:” iso “;”.
public string checkInputParamters(string baseUrl, string owner, string documentId, string user, string secret, string type)
{
return ((null == baseUrl) || (string.Empty == baseUrl)) ? ExceptionsCodes.BASE_URL_CANNOT_BE_NULL_OR_EMPTY.ToString("g");
return ((null == owner) || (string.Empty == owner)) ? ExceptionsCodes.OWNER_CANNOT_BE_NULL_OR_EMPTY.ToString("g");
}
Any ideas?
1 Answer