troubleshooting Question

error CS0051: Inconsistent accessibility

Avatar of Anjeneya Murthy
Anjeneya MurthyFlag for India asked on
C#
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;
    }
ASKER CERTIFIED SOLUTION
daveamour

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

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros