The thing is I have this method in my class where I use the overloading caracteristics...
protected bool SinInformacion(string prueba)
{
bool valor;
valor = string.IsNullOrEmpty(prueba);
return valor;
}
protected bool SinInformacion(string prueba, string prueba2)
{
bool valor;
valor = string.IsNullOrEmpty(prueba) && string.IsNullOrEmpty(prueba2);
return valor;
}
protected bool SinInformacion(string prueba, string prueba2, string prueba3)
{
bool valor;
valor = string.IsNullOrEmpty(prueba) && string.IsNullOrEmpty(prueba2) && string.IsNullOrEmpty(prueba3);
return valor;
}
And my question raises When I try to be "efficient" and apply "good software practices"
How can I use "params" instead of overloading?
I'm trying to figure out the logic but my unexperience in programming just don't help me
I'd appreciate if someone help me here, thanks in advance
Jignesh TrivediPosted Aug 18, 2013, 11:00 PM
hi,
Please refer below link it might help you.
http://msdn.microsoft.com/en-us/library/w5zay9db.aspx
http://www.dotnetperls.com/params
edkceoscPosted Aug 18, 2013, 9:42 PM
VulpesPosted Aug 18, 2013, 4:49 PM
protected bool SinInformacion(params string[] prueba)
{
if (prueba == null || prueba.Length == 0) return true; // if whole array null or empty say
bool valor = string.IsNullOrEmpty(prueba[0]);
for(int i = 1; i < prueba.Length; i++)
{
valor = valor && string.IsNullOrEmpty(prueba[i]);
}
return valor;
}