Link to home
Create AccountLog in
Avatar of Anjeneya Murthy
Anjeneya MurthyFlag for India

asked on

error CS0051: Inconsistent accessibility

Hi All,
I am trying out a sample for observer pattern in C#. I have added the snippet for your reference.
I am getting errors
error CS0051: Inconsistent accessibility: parameter type 'ObserverPattern01.BaseObserver' is less accessible than method 'ObserverPattern01.ConcreteSubject1.Register(ObserverPattern01.BaseObserver)'
\ObserverPattern01\Program.cs(53,21): error CS0051: Inconsistent accessibility: parameter type 'ObserverPattern01.BaseObserver' is less accessible than method 'ObserverPattern01.ConcreteSubject1.UnRegister(ObserverPattern01.BaseObserver)'

Can  you please help me resolve this issue?

Thanks in Advance
interface BaseObserver
    {
        void update();
        char[] Name();
    }
    interface BaseSubject
    {
        void Register(BaseObserver obs);
        void UnRegister(BaseObserver obs);
        void Notify();        
    }
    public class ConcreteObserver1 : BaseObserver  
    {
        public void update()
        {
            System.Console.WriteLine("ConcreteObserver1: I know Subject changed");
        }
        public char[] Name()
        {
            return "ConcreteObserver1";
        }
    }
public class ConcreteSubject1 : BaseSubject
    {
        public void Register(BaseObserver obs)
        {
            Console.WriteLine("Registered: " + obs.Name());            
        }
        public void UnRegister(BaseObserver obs)
        {
            Console.WriteLine("UnRegistered: " + obs.Name());
        }
        public void Notify()
        {
        }
        private ArrayList observers;
    }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of daveamour
daveamour
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Also Observer Observable is achieved in .net through Delegates and Events