jeudi 16 mai 2019

2 Interface(i1, i2), 2 abstract class(A:i1, B:i2), one class(Summary :i1,i2). How to access all methods of abstract class

I have Two abstract Class IExcelHelper and ICoreExcelHelper inherit by ExcelHelper and CoreExcelHelper. I have on e class that inherit tow interface IExcelHelper & ICoreExcelHelper. I want to access all method of abstract class whether methods are implemented of not. Here i am unable to access the Test Method of ExcelHelper.

any suggestion ?

public interface IExcelHelper
{
    void GenerateReport();
}
public interface ICoreExcelHelper
{
    void GenerateReport();
}

public abstract class ExcelHelper : IExcelHelper
{
    public abstract void GenerateReport();

    public void Test()
    {
        Console.WriteLine("Test");
    }
}

public abstract class CoreExcelHelper : ICoreExcelHelper
{
    public abstract void GenerateReport();
}

public class GenerateExcelStrategySummary : IExcelHelper, ICoreExcelHelper
{
    void IExcelHelper.GenerateReport()
    {
        Console.WriteLine("GenerateReport");
    }

    void ICoreExcelHelper.GenerateReport()
    {
        Console.WriteLine("CoreGenerateReport");
    }
}

class Program
{
    static void Main(string[] args)
    {
        IExcelHelper obj = new GenerateExcelStrategySummary();
        obj.GenerateReport();

        obj.Test();

        ICoreExcelHelper obj1 = new GenerateExcelStrategySummary();
        obj1.GenerateReport();

        Console.WriteLine("Hello World!");
        Console.ReadLine();
    }
}

Aucun commentaire:

Enregistrer un commentaire