I’m having problems when using linq on a datatable.asenumerable().
This throws InvalidCastException.
DateTime date=r.Field<DateTime>("date");
This works fine.
DateTime date = DateTime.Parse(r.Field<string>("date"));
What am I missing?
Regards Sven
Why would you expect it to work? The following code doesn’t compile:
Whereas this does:
As in, you can’t just cast a string to a DateTime, so if your value is a string, you need to explicitly convert it.