agileDev
agileDev

Reputation: 441

Accessing Protected member from a class in different assembly from the code behind class(partial class) of C#

I've a class with protected member from a project of a solution:

public class FPrintImage
{
    protected static Byte[] fpImage1;
    protected static Byte[] fpImage2;
}

Now I want to access these protected members of the class from a different class of project , which is also the code behind class of a xaml page :

public partial class MainWindow : Window
{
}

Upvotes: 0

Views: 457

Answers (1)

Frits
Frits

Reputation: 314

It is not possible to access protected members of a class.

However, what can be done is derive a subclass from FPrintImage:

public class MyFPrintImage : FPrintImage
{
    public static Byte[] getFPImage1()
    {
        return fpImage1;
    }

    public static void setFPImage1(Byte[] _fpImage1)
    {
        fpImage1 = _fpImage1;
    }

}   

Then you can access the protected members.

EDIT: it is indeed not possible to inherit from two base classes, but you can create an instance of the subclass in the MainWindow class.

Upvotes: 2

Related Questions