Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DataRow and the protected internal constructor

How can a DataTable create a new instance of a DataRow with the NewRow method if the constructor of the DataRow class is protected internal and DataTable doesn't inherit from DataRow?

Example:

class Program
{
    static void Main()
    {
        // error: inaccessible due to its protection level
        DataRow dr = new DataRow(); 

        // works
        DataRow dr = new DataTable().NewRow();
    }
}
like image 669
Snake Avatar asked Mar 23 '26 20:03

Snake


1 Answers

protected internal means "accessible by derived classes" and "accessible by other classes in the same assembly". DataTable and DataRow are in the same assembly, so DataTable has access to all of DataRow's internal members.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!