I have a class employees.
I have one generic class <tkey,tdata>
I have one dictionary <tkey,tdata>
I want to store the Employee info to a file.
After saving the object of Employees to Tdata (value) of dictionary, I cannot get the info of employee (firstname, lastname...) from dictionary in order to create a xml file.
Any idea to cast the value of dictionary to Employee to get the properties of employee class?
I can get the object of Employee by a foreach(var item in dictionary) => item.Value
but I cannot cast to get the properties of the employee class!
EmployeeMNG<string,employees> empMNG= new EmployeeMNG<string,employees>();
Employees s= new Employees();
s.empNo = 11;
s.firstName = "khoaxml";
s.lastName = "nguyen";
s.address = "47 nguyen hong";
s.country = "VN";
empMNG.add("stu", s); empMNG.save("file.xml");
public class EmpMNG<tkey,tdata> : IEmpMNG<<tkey,tdata>
private Dictionary<tkey,tdata> cache;
cache = new Dictionary<tkey,tdata>();
public TData add(TKey key, TData data)
cache[key] = data;
public void Save(string xmlPath)
foreach (var item in cache)