Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Dictionary that tells which key was not present
//Extended dictionary using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class MyDictionary<TKey, TValue> : Dictionary<TKey, TValue> { public TValue this[TKey key] { get { TValue val; if(base.TryGetValue(key, out val)) { return val; } else { throw new KeyNotFoundException(string.Format("The given key ({0}) was not present in the dictionary.", key)); } } set { base[key] = value; } } } public class Program { public static void Main(string[] args) { //Dictionary<string, string> dic = new Dictionary<string, string>() //{ // {"a", "b"} //}; MyDictionary<string, string> dic = new MyDictionary<string, string>() { {"a", "b"} }; Console.WriteLine(dic["aa"]); } } }
run
|
edit
|
history
|
help
0
test
JavaScript
Finding a Substring in a Main String
My Test
Practical
Extension Methods (edited)
Need to convert datetime containg '/' to '-' format
4.4.20
CodeAdvent
hh