Question: I'm writing a simple C# class that handle SQL queries in a specific contest. Most of the queries will be `SELECT` statement with 3-4 parameters that should be escaped properly, so the function will be something like this

```
public DataTable Select(string query, string[] parameters) {
    # some code
}

```

Should `parameters` be an `Array` or a `List<>`? Is there some best practice when choosing between these two types as function parameter or is it just a matter of preferences?

P.S. I usually prefer `List<>` because of the flexibility but here the possibility to create an `Array` on the fly is a good point.

Answer: 
You should use IEnumerable, then it can be either since both [`list`](https://msdn.microsoft.com/en-us/library/6sh2ey19%28v=vs.110%29.aspx) and [`array`](https://msdn.microsoft.com/en-us/library/system.array%28v=vs.110%29.aspx) implement this

```
public DataTable Select(string query, IEnumerable<string> parameters)

```

They also both implement `IList` and `ICollection`, which may offer other useful properties as shown by Tim Schmelter in the comments
If your parameters have all the same type (here string) you can use params keyword with string array.

```
public DataTable Select(string query, params string[] parameters) 

```

Thus you can call it like below

```
Select(myQuery, param1, param2, ...);

```