Friday, 3 March 2017

c# - Should I use IEnumerable or List for parameters from WebApi?

Let's say that I have




[HttpPost("some/route")]
public void AddSomething([FromBody] QueryParameter parameter){
DoSomething();
}


and my parameter is:



public class QueryParameter  {

public int ElementId { get; set; }
public IEnumerable YearIds{ get; set; }
}


The question is: can I keep IEnumerable or it should be List?
What is better practice and why?

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...