+ 2
returning a list from a method c#
I am working on another challenge. However, I am stuck. I am not sure what I am missing or it's the format for returning a list from a function. I get the response System.Collections.Generic.List`1[System.String]. Please see the attached code. https://code.sololearn.com/cl30G2zqRN61/?ref=app
2 Respuestas
+ 1
it's working fine, how do you want the returned list to be printed?
it's printing its type name.
try
List<string> wrd = GetWords(new List<string> {"a", "b", "c", "a", "d" });
Console.WriteLine(wrd[0]);
if you want the whole string you either have to join it or iterate over the returned list to print its content.
0
i see, GetWords method return a list, but you try to print it in Main