Thomas Nielsne

Thomas Nielsne

  • NA
  • 40
  • 454

Make list global and accessible everywhere as datasource

Nov 8 2019 4:16 AM
Hello,
 
I have a class where I have a static list. 
My challenge is, how to use the _list as datasource to a datagrid in a form?
 
Anyone that can help with howto do that? 
 
Below is the class: 
 
static class MyList
{
static List<InstalledServices> _list;
static MyList()
{
_list = new List<InstalledServices>();
}
public static void Add(string value, string value2, string value3)
{
_list.Add(new InstalledServices()
{
Service = value,
Name = value2,
Status = value3
});
}
public static void Show()
{
foreach (var value in _list)
{
Console.WriteLine(value);
}
}
class InstalledServices
{
public string Service { get; set; }
public string Name { get; set; }
public string Status { get; set; }
}
}

Answers (2)