I’m relatively inexperienced with C# in Visual Studio. I have created a class called Visitor and I want to track be able to access these visitors in different Forms. What would be the best way of doing this. I thought of having a Visitors class which was a list that could be accessed. However, I can’t seem to find a way of doing this. I get the following error
Error CS1955 Non-invocable member 'Visitors' cannot be used like a method.
He is the code for my Visitors Class…
namespace VisitorSignInSystem
{
public class Visitors
{
List<Visitor> current { get; set; }
public Visitors()
{
current = new List<Visitor>();
}
public Visitors(Visitor v) {
current.Add(v);
}
}
}
I initialise the list on the first form….
public Form1()
{
InitializeComponent();
Visitors();
}
And try and ass something to the list in a different form…
public VisitorSignInWelcome(Visitor v)
{
InitializeComponent();
Visitors(v);
}
Any help greatly appreciated or a signpost to the correct way of doing this please.
3