KeyValuePair<TKey, TValue>

作者:追风剑情 发布于:2018-12-4 11:44 分类:C#

示例

using System;
using System.Collections.Generic;

namespace Test3
{
    class Program
    {
        static void Main(string[] args)
        {

            KeyValuePair<string, int> key = new KeyValuePair<string, int>("aaa", 123);
            Console.WriteLine(key.ToString());

            Dictionary<KeyValuePair<string, int>, string> dic = new Dictionary<KeyValuePair<string, int>, string>();
            dic.Add(key, "567");
            Console.WriteLine(dic[key]);

            Console.Read();
        }
    }
}

运行测试

111.png


namespace System.Collections.Generic
{
    public struct KeyValuePair<TKey, TValue>
    {
        public KeyValuePair(TKey key, TValue value);

        public TKey Key { get; }
        public TValue Value { get; }

        public override string ToString();
    }
}

标签: C#

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号