Error 1 Cannot implicitly convert type 'System.Collections.Generic.List<dynamic>' to 'System.Collections.Generic.List<string>'
var objects = new List<dynamic>();
//filling objects here
List<string> things = objects.Select(x => x.nameref.ToString()).ToList();
So isn't it a valid List of strings? Why compiler is assuming that this list is of type dynamic?
I've tried also converting from this answer, but it keeps giving me same error.
Why isn't it working? Because you can make mess like this:
public class Test
{
public int ToString()
{
return 0;
}
}
and compiler won't know if ToString returns string or int.
Can you answer this question?
Write Answer1 Answers