BindingSource source = new BindingSource();
source.Add(new List<string>() { "1", "2", "3" });
//List<string> theList = source.List;//compile fail. Can't convert from IList to List<T> implicity
List<string> theList = source.List as List<string>;//fail, null
I’ve seen people online creating a method to perform an explicit conversion. This seems like total overkill for this task. Is there a better way to get my list back?
You’re adding a
List<T>as the first item in the list.To retrieve it, you would write
Your code would work if you actually bind to a
List<T>by setting theDataSourceproperty.