I have provided a minimum code below to convey my situation. I just want to figure out a way to create a delegate function for add(IClient client) in ClientList.cs and consume it in Program.cs
I have provided comments in the code below to better explain my situation. If you need any other information let me know, I'll update it here.
Program.cs
namespace sample
{
class Program
{
static void Main(string[] args)
{
Program p = new Program();
p.Go();
Console.ReadKey();
}
private void Go()
{
//Code logic
using (ClientList clientList = new ClientList()) //Instantiated an object of the ClientList class
{
//Code Logic
//Make use of functions from the object instances here.
clientList.add(client); //Works
//ERROR : BUT, the below does not work . What am i doing wrong here.? Why is it not accessible here ?
clientList.add
clientList.Sort();
}
//Code logic
}
}
}
ClientList.cs
namespace sample
{
public delegate void addItems(IClient client); //ERROR in editor. (Red underline on addItems.)
class ClientList : IDisposable
{
//Member variables
private List<IClient> clientlist = null;
private string time;
//Member Properties
public string Time { get => time; set => time = value; }
//Default Constructor
public ClientList()
{
clientlist = new List<IClient>();
}
//Member Methods
public void add(IClient client)
{
clientlist.Add(client);
}
//Indexer
public IClient this[int position]
{
get { return clientlist[position]; }
}
}
}
UPDATE #1:
The red underline error is as follows: CS0059: Inconsistent accessibility: parameter type 'IClient' is less accessible than delegate 'addItems'