En la universidad, me habían enseñado que había un punto de entrada y otro punto de salida.
public string DoSomething(string paramOne, string paramTwo)
{
string result = string.Empty;
if(!string.IsNullOrEmpty(paramOne) && string.IsNullOrEmpty(paramOne)){
resultado = paramOne;
}
else if(string.IsNullOrEmpty(paramOne) && !string.IsNullOrEmpty(paramOne)){
resultado = paramTwo;
}
else if(!string.IsNullOrEmpty(paramOne) && !string.IsNullOrEmpty(paramOne)){
resultado = paramOne + "_" + paramTwo;
}
return result;
}
Pero leyendo a MagMax, en este artículo me he dado cuenta de que tengo que desaprender y volver aprender cómo escribir los métodos.
public string DoSomething(string paramOne, string paramTwo)
{
if(string.IsNullOrEmpty(paramOne) && string.IsNullOrEmpty(paramOne)){
return string.Empty;
}
if(!string.IsNullOrEmpty(paramOne) && string.IsNullOrEmpty(paramOne)){
return paramOne;
}
if(string.IsNullOrEmpty(paramOne) && !string.IsNullOrEmpty(paramOne)){
return paramTwo;
}
if(!string.IsNullOrEmpty(paramOne) && !string.IsNullOrEmpty(paramOne)){
return paramOne + "_" + paramTwo;
}
}
No hay comentarios:
Publicar un comentario