how to initialize dictionary as (key,value,value) pair in C#

后端 未结 9 1126
悲&欢浪女
悲&欢浪女 2020-12-31 11:37

I want to store values as key,value,value pair. My data is of type

Key -> int & both values -> ulong,

How to initialize & fet

9条回答
  •  萌比男神i
    2020-12-31 12:24

    Create a structure to store your values:

    struct ValuePair
    {
        public ulong Value1;
        public ulong Value2;
    }
    

    Dictionary initialization:

    Dictionary dictionary = new Dictionary();
    

    Maybe List is enough, if you use int as key?

    List:

    List list = new List();
    

    ValuePair can be added to the list as following:

    list.Add(new ValuePair { Value1 = 1, Value2 = 2 });
    

提交回复
热议问题