コード例 #1
0
    public void CanEnumerateKeysAndValuesWithDelegate()
    {
        string result = "";
        var dictionary = new MultiValueDictionary<string, string>();
        dictionary.AddValue("Key1", "Value1");
        dictionary.AddValue("Key2", "Value2");
        dictionary.AddValue("Key2", "Value1");
        dictionary.AddValue("Key3", "Value7");

        dictionary.ForEach((key, value) => result += key + ": " + value + "\r\n");

        Assert.Equal("Key1: Value1\r\n" +
                     "Key2: Value2\r\n" +
                     "Key2: Value1\r\n" +
                     "Key3: Value7\r\n", result);
    }
コード例 #2
0
    public void CanEnumerateKeysAndValuesWithDelegate()
    {
        string result     = "";
        var    dictionary = new MultiValueDictionary <string, string>();

        dictionary.AddValue("Key1", "Value1");
        dictionary.AddValue("Key2", "Value2");
        dictionary.AddValue("Key2", "Value1");
        dictionary.AddValue("Key3", "Value7");

        dictionary.ForEach((key, value) => result += key + ": " + value + "\r\n");

        Assert.Equal(@"Key1: Value1
Key2: Value2
Key2: Value1
Key3: Value7
", result);
    }