In C#, How do I call a function that is returning a list?
static void Main(string[] args)
{
List<string> range = new List<string>();
range.ForEach(item => item.WildcardFiles()); //this is not working
}
List<string> WildcardFiles(string first)
{
List<string> listRange = new List<string>();
listRange.Add("q");
listRange.Add("s");
return listRange;
}
There are various things wrong with your code:
ForEachon it. That’s not going to do anything.WildcardFileson a string, when it’s not a method of string.WildcardFileswhich is an instance method in whatever your declaring type is, but without any instances of that type.WildcardFileswithout passing in an argument for thefirstparameterWildcardFilesWildcardFilesignores its parameterNow I suspect you really wanted something like: