0

I have the following method in my C# class.

For the parameter called 'collections' I would like to have the flexibility of either passing a List or string[ ] array. I know I could simply set the parameter type as object type, but is there any other more efficient type I could use to do this?

public string ProcessDoc(List<string> collections, string userName)
{
  //code goes here
   string result = null;
   ...
   ...
   return result;
}
Sunil
  • 20,653
  • 28
  • 112
  • 197

1 Answers1

7

You could use IList<string>:

public string ProcessDoc(IList<string> collections, string userName)
{
  //code goes here
   string result = null;
   ...
   ...
   return result;
}

Why array implements IList?

Community
  • 1
  • 1
Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939