How to store multiple items in IDictionary?

前端 未结 1 490
说谎
说谎 2021-01-29 10:25

I have this IDictionary declaration: IDictionary trace;
Inside of it I want save a list of element returned by a json deseri

相关标签:
1条回答
  • 2021-01-29 10:58

    Looks like you'd be better off using a dedicated class, something like this:

    public class TraceInfo
    {
        public string Date { get; set; }
        public string Type { get; set; }
        public List<string> ContextItems { get; set; }
    }
    

    Then for every value in obj, create a TraceInfo object using new TraceInfo() and set its properties.

    You can then store them in a List<TraceInfo> or in a Dictionary<string, TraceInfo>, the choice is yours.

    0 讨论(0)
提交回复
热议问题