0

Hy,
I have some methods which are identical as functionality but dependent on the parameter received from the method.For example:

 public long GetElementsFromList(long el,List<long> lst)
        {
            Random rndElement = new Random();        
            int random = rndElement.Next(0, this.lst.Count - 1);
            if (random >= this.lst.IndexOf(el)) random += 1;
            return this.lst[random];
        }
       public string GetElements2FromList(string el,List<string> lst)
        {
            Random rndElement = new Random();  
            int random = rndElement.Next(0,this.sucursale.Count-1);
            if (random >= this.lst.IndexOf(el)) random += 1;
            return this.lst[random];
        }

I want to have a generic method which is not dependent on the return value and also on the type of parameter.
I'm thinking about generics but i cannot handle myself.

Some advice?Thank you

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by pritaeas
0

have you tried using Val or Value ? it should store the value you store in it in the most appropriate format type.

Edited by ChrisHunter

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.