Equivalent Classes



Format 1 - Array Format

This is better because the StaffClass contains all the information about the staff member including the "id".

public class AllTheStaff 
{
    public System.Collections.Generic.List<StaffClass> staff { get; set; }
}

public class StaffClass
{
    public int id { get; set; }
    public string firstName { get; set; }
    public string lastName { get; set; }
}

If you need to convert a List into a Dictionary you can use this:

System.Collections.Generic.Dictionary<string, StaffClass> StaffDictionary; 
StaffDictionary = AllTheStaff.StaffClass.ToDictionary(staff => staff.id);

Format 2 - Dynamic Keys


public class AllTheStaff 
{
    public System.Collections.Generic.Dictionary<string, StaffClass> StaffDictionary { get; set; }
}

public class StaffClass
{
    public string firstName { get; set; }
    public string lastName { get; set; }
}




© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrev