diff --git a/runtime/CSharp/Antlr4.Runtime/Sharpen/Collections.cs b/runtime/CSharp/Antlr4.Runtime/Sharpen/Collections.cs index 1aa625af7..49faa5753 100644 --- a/runtime/CSharp/Antlr4.Runtime/Sharpen/Collections.cs +++ b/runtime/CSharp/Antlr4.Runtime/Sharpen/Collections.cs @@ -59,7 +59,11 @@ namespace Sharpen public static IDictionary SingletonMap(TKey key, TValue value) #endif { +#if NET_4_5 + return new ReadOnlyDictionary(new Dictionary { { key, value } }); +#else return new Dictionary { { key, value } }; +#endif } private static class EmptyListImpl