I have attempted to create a Computer object to hold data that is stored in a list and when I attempt to view any of the data it comes back with no output data...
The Object I have created is like so:
class Computer
{
string companyName;
string locationName;
string serverName;
string deviceName;
string lastOnline;
public Computer(string companyName, string locationName, string serverName,
string deviceName, string lastOnline)
{
this.companyName = companyName;
this.locationName = locationName;
this.serverName = serverName;
this.deviceName = deviceName;
this.lastOnline = lastOnline;
}
public string CompanyName { get; set; }
public string LocationName { get; set; }
public string ServerName { get; set; }
public string DeviceName { get; set; }
public string LastOnline { get; set; }
}
I initialize the list as so:
List<Computer> computerList = new List<Computer>();
For a test I have added five items to the list:
computerList.Add(new Computer("Hello", "World", "Test", "Machine", "2-12-13"));
computerList.Add(new Computer("Hello", "World", "Test", "Machine", "2-12-13"));
computerList.Add(new Computer("Hello", "World", "Test", "Machine", "2-12-13"));
computerList.Add(new Computer("Hello", "World", "Test", "Machine", "2-12-13"));
computerList.Add(new Computer("Hello", "World", "Test", "Machine", "2-12-13"));
and to output my items I use:
foreach (var author in computerList)
{
Console.WriteLine("Test : {0}", author.LastOnline);
}
Can anybody see why I am getting no output other than:
Test :
Test :
Test :
Test :
Test :