鸟语天空
KeyValuePair<TKey, TValue>
post by:追风剑情 2018-12-4 11:44

示例

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();
    }
}

评论:
发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容