//Enerweb Test
//Task 1
//Complete this program so that the list of companies can be loaded from a file and also saved to a file
//HINT: make use of XML serialization
//You may need to create the test xml data file by hand or any other mechanism
//Task 2
//Change the interface for the Company class so that the companies can be sorted by number of employees
//HINT: Use IComparable
//Task 3 - Advanced - if time available
//Create a generic Template Function for Loading any complex type from a file and saving any complex type to a file
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
namespace EnerwebTest
{
class Employee
string ID;
string Name;
decimal Salary;
}
//Task 1 - Complete this class, members and attributes for XML serialization
class Company
List<Employee> employees = new List<Employee>();
public Company(string aName)
Name = aName;
public override string ToString()
return string.Format("Company {0}: Employees {1}", Name, employees.Count);
class Program
static void Main(string[] args)
List<Company> companies = Load("companies.xml");
ShowCompanies(companies);
//TASK 2: by changing the interface of the Company class - the following
//line of code is all that is needed to sort the list
companies.Sort();
Save("companies.xml", companies);
//TASK 3 - the new generic overloaded Load/Save functions are used like this
companies = Load<List<Company>>("companies.xml");
Save<List<Company>>("companies.xml", companies);
//TASK 1 - complete this
private static List<Company> Load(string FileName)
//TODO: complete this
return null;
private static void Save(string FileName, List<Company> companies)
//TASK 3 - advanced - complete this
private static T Load<T>(string FileName)
return default(T);
private static void Save<T>(string FileName, T t)
private static void ShowCompanies(List<Company> companies)
System.Console.WriteLine("List of companies:\n\n");
foreach (Company company in companies)
System.Console.WriteLine(company.ToString());
System.Console.WriteLine("Done:\n\n\n");
Help me to solve this....plz