confusion on interface IDataReader
Peter Osucha <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.cx |
|---|---|
| Message-ID | <[email protected]> |
I was looking over some example code that was handling data access to a SQL
db. A method for the code was similar to....
public IDataReader PerformStoredProcedure_DataReader ( string spName,
CommandBehavior behavior )
{
IDataReader result = null;
SqlCommand cmd = new SqlCommand ( spName, (SqlConnection)Connection );
cmd.CommandType = CommandType.StoredProcedure;
result = cmd.ExecuteReader ( behavior );
return result;
}
Now what has me confused is that this method returns an object of type
IDataReader - which I thought (from reviewing MSDN) was not allowed since
IDataReader is an interface (ie, I thought such a method could return an
object that implemented IDataReader but not an instance of an IDataReader
object itself since there really wasn't any such thing as an IDataReader
object). IOW, it seems that there should be no problem returning an object
of, say, type SqlDataReader from this method.
I'm obviously not understanding something. Why is it allowed to return on
object of type IDataReader here?
Peter
===================================
This list is hosted by DevelopMentorĀ® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com