Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

error CS0051: Inconsistent accessibility

Avatar of Anjeneya Murthy
Anjeneya MurthyFlag for India asked on
2 Comments1 Solution3366 ViewsLast Modified:
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;
Avatar of daveamour
daveamourFlag of United Kingdom of Great Britain and Northern Ireland image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answers