edkceosc

edkceosc

  • NA
  • 3
  • 1.2k

How to use params instead of method overloading...

Aug 18 2013 3:33 PM
Hello there, I'm a noob to programming and C#. So far I love programming and in fact C#. I've got a question (probably a dummie one) but If you guys can help me out or put me in the right direction.. I'll apreciate it..

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

Answers (3)