What is the easiest way to cast a SqlDataReader to IDatareader.
Or is it easier / possible to convert a List<> object to a IDataReader
What is the easiest way to convert a SqlDataReader to IDatareader
Since SqlDataReader
implements IDataReader
, this is just an implicit cast:
SqlDataReader typedReader = ...
IDataReader untypedReader = typedReader;
What is the easiest way to convert a SqlDataReader to IDatareader
You can not. A SqlDataReader
CLASS is not an IDataReader
interfadce.
For casting (assign to variable) use
IDataReader untypedReader = typedReader;
BUT: this is NOT a conversion. It is a cast. A conversion to an inteerface is per defintiion not possible as interfaces can not be instantiated.
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