Anjeneya Murthy
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.BaseObs erver' is less accessible than method 'ObserverPattern01.Concret eSubject1. Register(O bserverPat tern01.Bas eObserver) '
\ObserverPattern01\Program .cs(53,21) : error CS0051: Inconsistent accessibility: parameter type 'ObserverPattern01.BaseObs erver' is less accessible than method 'ObserverPattern01.Concret eSubject1. UnRegister (ObserverP attern01.B aseObserve r)'
Can you please help me resolve this issue?
Thanks in Advance
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.BaseObs
\ObserverPattern01\Program
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
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Also Observer Observable is achieved in .net through Delegates and Events