Why can't the datareader be initialized?

we use the abstract keyword up to classname to constrain by instantiating the class.

But the datareader is not an abstract class, but we cannot instantiate it. Could you explain why?

I was looking for this, then I found that it does not have a constructor, so we cannot create an object, but as far as I know, if there is no constructor, then the compiler automatically creates a default constructor.

Please, help...

+4
source share
1 answer

DbDataReader - . SqlDataReader, , . internal (ILSpy):

// System.Data.SqlClient.SqlDataReader
internal SqlDataReader(SqlCommand command, CommandBehavior behavior)
{
    // ...
}

MSDN:

SqlDataReader, ExecuteReader SqlCommand .

, DataReader, SqlCommand.ExecuteReader.

+4

Source: https://habr.com/ru/post/1525767/


All Articles