Last active
August 29, 2015 13:57
-
-
Save ViIvanov/9533018 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Collections.ObjectModel; | |
internal static class Program | |
{ | |
private static TValue GetValueOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> source, TKey key) { return default(TValue); } | |
private static TValue GetValueOrDefault<TKey, TValue>(this IReadOnlyDictionary<TKey, TValue> source, TKey key) { return default(TValue); } | |
private static void Main() { | |
var dictionary = new Dictionary<int, int>(); | |
var v1 = dictionary.GetValueOrDefault(0); // error CS0121: The call is ambiguous between the following methods or properties… | |
var readOnly = new ReadOnlyDictionary<int, int>(dictionary); | |
var v2 = readOnly.GetValueOrDefault(0); // error CS0121: The call is ambiguous between the following methods or properties… | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment