je tente de réécrire cette méthode en utilisant sténographie si:retour en sténographie si
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 "";
}
Je ne peux pas faire comme cela parce que le retour me force à mettre une valeur après « : » 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");
}
Des idées?
Dans le premier exemple, vous ne renvoyez rien si les deux instructions 'if' sont fausses. Cela donnera une erreur de compilation. Pourriez-vous corriger votre code? –
Corrigé, merci. –
quel est le point d'utiliser une main courte si? cela rend le code laid et illisible, surtout dans ce cas, alors que les deux «if» dans le code ci-dessus sont clairs au premier coup d'œil. –