When I hit this line of code
(T)Convert.ChangeType(data.Split(new char[] { '¤' }), typeof(T));
I get an error of Object doesn't implement IConvertible. T
is an IEnumerable<String>
and data
is String
typed. What can be done about it?
I've tried converting it to a bunch of different stuff explicitly before the change of type but I can't get it to work. I'm converting other stuff to Dictionary
and native types but this particular one gives me headache.
Why do you need to call Convert.ChangeType()
?
In the following code, theEnumerable
is of type IEnumerable<string>
.
var inputString = "a,b,c";
var theEnumerable = inputString.Split(',').AsEnumerable();
Fundementally the type of an object cannot be an Interface, only a type that implements one. Since Array implements IEnumberable your string[] already is what you want it to be.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With