How can I create a generic method so the return type is either a list or an array?
Now for this method I get this error:
(string, int)[]' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'T' in the generic method 'T TournamentsAnalytics.GetParameters()
private void Test()
{
var parameters = GetParameters<List<(string, int )>>();
var parameters2 = GetParameters<(string, int)[]>();
}
private T GetParameters<T>() where T: ICollection<(string, int)>, new()
{
var parameters = new T
{
("nr1", 1),
("nr2", 2),
("nr3", 3),
("nr4", 4),
("nr5", 5),
("nr6", 6)
};
return parameters;
}
(string, int)[]doesn't satisfy constraintnew().