[{"data":1,"prerenderedAt":903},["ShallowReactive",2],{"blog:2009:dictionaryt-look-up-or-create-made-simpler":3,"blogMore-Development":727,"comments-dictionaryt-look-up-or-create-made-simpler":740},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"category":11,"tags":12,"excerpt":15,"body":40,"_type":719,"_id":720,"_source":721,"_file":722,"_stem":723,"_extension":724,"url":725,"wordCount":726,"minutes":151,"commentCount":263},"/blog/2009/dictionaryt-look-up-or-create-made-simpler","2009",false,"en","Dictionary\u003CT> look-up or create made simpler","The design of a Dictionary\u003CT> lends itself well to a caching or identification mechanism and as a result you often see code that looks like this:","2009-08-04T16:24:04+00:00","Development",[13,14],".NET","C#",{"type":16,"children":17},"root",[18,35],{"type":19,"tag":20,"props":21,"children":22},"element","p",{},[23,26,33],{"type":24,"value":25},"text","The design of a ",{"type":19,"tag":27,"props":28,"children":30},"code",{"className":29},[],[31],{"type":24,"value":32},"Dictionary\u003CT>",{"type":24,"value":34}," lends itself well to a caching or identification mechanism and as a result you often see code that looks like this:",{"type":19,"tag":20,"props":36,"children":37},{},[38],{"type":24,"value":39},"It’s not that it is particularly difficult but it can be a bit error prone and when you’re doing it over and over. What would be nicer is something that let you do:",{"type":16,"children":41,"toc":717},[42,52,337,341,430,435,702,711],{"type":19,"tag":20,"props":43,"children":44},{},[45,46,51],{"type":24,"value":25},{"type":19,"tag":27,"props":47,"children":49},{"className":48},[],[50],{"type":24,"value":32},{"type":24,"value":34},{"type":19,"tag":53,"props":54,"children":59},"pre",{"className":55,"code":56,"language":57,"meta":58,"style":58},"language-csharp shiki shiki-themes everforest-light dracula","private static Dictionary\u003Cstring, Employee> employees = new Dictionary\u003Cstring, Employee>();\n\npublic static Employee GetByName(string name) {\n  Employee employee;\n  if (!employees.TryGetValue(name, out employee)) {\n    employee = new Employee(whatever);\n    employees.Add(name, employee);\n  }\n  return employee;\n}\n","csharp","",[60],{"type":19,"tag":27,"props":61,"children":62},{"__ignoreMap":58},[63,149,159,203,217,261,287,306,315,328],{"type":19,"tag":64,"props":65,"children":68},"span",{"class":66,"line":67},"line",1,[69,75,80,86,92,98,103,108,113,118,124,128,132,136,140,144],{"type":19,"tag":64,"props":70,"children":72},{"style":71},"--shiki-default:#F57D26;--shiki-dark:#FF79C6",[73],{"type":24,"value":74},"private",{"type":19,"tag":64,"props":76,"children":77},{"style":71},[78],{"type":24,"value":79}," static",{"type":19,"tag":64,"props":81,"children":83},{"style":82},"--shiki-default:#3A94C5;--shiki-default-font-style:inherit;--shiki-dark:#8BE9FD;--shiki-dark-font-style:italic",[84],{"type":24,"value":85}," Dictionary",{"type":19,"tag":64,"props":87,"children":89},{"style":88},"--shiki-default:#5C6A72;--shiki-dark:#F8F8F2",[90],{"type":24,"value":91},"\u003C",{"type":19,"tag":64,"props":93,"children":95},{"style":94},"--shiki-default:#3A94C5;--shiki-dark:#FF79C6",[96],{"type":24,"value":97},"string",{"type":19,"tag":64,"props":99,"children":100},{"style":88},[101],{"type":24,"value":102},", ",{"type":19,"tag":64,"props":104,"children":105},{"style":82},[106],{"type":24,"value":107},"Employee",{"type":19,"tag":64,"props":109,"children":110},{"style":88},[111],{"type":24,"value":112},"> employees ",{"type":19,"tag":64,"props":114,"children":115},{"style":71},[116],{"type":24,"value":117},"=",{"type":19,"tag":64,"props":119,"children":121},{"style":120},"--shiki-default:#F85552;--shiki-dark:#FF79C6",[122],{"type":24,"value":123}," new",{"type":19,"tag":64,"props":125,"children":126},{"style":82},[127],{"type":24,"value":85},{"type":19,"tag":64,"props":129,"children":130},{"style":88},[131],{"type":24,"value":91},{"type":19,"tag":64,"props":133,"children":134},{"style":94},[135],{"type":24,"value":97},{"type":19,"tag":64,"props":137,"children":138},{"style":88},[139],{"type":24,"value":102},{"type":19,"tag":64,"props":141,"children":142},{"style":82},[143],{"type":24,"value":107},{"type":19,"tag":64,"props":145,"children":146},{"style":88},[147],{"type":24,"value":148},">();\n",{"type":19,"tag":64,"props":150,"children":152},{"class":66,"line":151},2,[153],{"type":19,"tag":64,"props":154,"children":156},{"emptyLinePlaceholder":155},true,[157],{"type":24,"value":158},"\n",{"type":19,"tag":64,"props":160,"children":162},{"class":66,"line":161},3,[163,168,172,177,183,188,192,198],{"type":19,"tag":64,"props":164,"children":165},{"style":71},[166],{"type":24,"value":167},"public",{"type":19,"tag":64,"props":169,"children":170},{"style":71},[171],{"type":24,"value":79},{"type":19,"tag":64,"props":173,"children":174},{"style":82},[175],{"type":24,"value":176}," Employee",{"type":19,"tag":64,"props":178,"children":180},{"style":179},"--shiki-default:#8DA101;--shiki-dark:#50FA7B",[181],{"type":24,"value":182}," GetByName",{"type":19,"tag":64,"props":184,"children":185},{"style":88},[186],{"type":24,"value":187},"(",{"type":19,"tag":64,"props":189,"children":190},{"style":94},[191],{"type":24,"value":97},{"type":19,"tag":64,"props":193,"children":195},{"style":194},"--shiki-default:#5C6A72;--shiki-default-font-style:inherit;--shiki-dark:#FFB86C;--shiki-dark-font-style:italic",[196],{"type":24,"value":197}," name",{"type":19,"tag":64,"props":199,"children":200},{"style":88},[201],{"type":24,"value":202},") {\n",{"type":19,"tag":64,"props":204,"children":206},{"class":66,"line":205},4,[207,212],{"type":19,"tag":64,"props":208,"children":209},{"style":82},[210],{"type":24,"value":211},"  Employee",{"type":19,"tag":64,"props":213,"children":214},{"style":88},[215],{"type":24,"value":216}," employee;\n",{"type":19,"tag":64,"props":218,"children":220},{"class":66,"line":219},5,[221,226,231,236,241,246,251,256],{"type":19,"tag":64,"props":222,"children":223},{"style":120},[224],{"type":24,"value":225},"  if",{"type":19,"tag":64,"props":227,"children":228},{"style":88},[229],{"type":24,"value":230}," (",{"type":19,"tag":64,"props":232,"children":233},{"style":71},[234],{"type":24,"value":235},"!",{"type":19,"tag":64,"props":237,"children":238},{"style":88},[239],{"type":24,"value":240},"employees.",{"type":19,"tag":64,"props":242,"children":243},{"style":179},[244],{"type":24,"value":245},"TryGetValue",{"type":19,"tag":64,"props":247,"children":248},{"style":88},[249],{"type":24,"value":250},"(name, ",{"type":19,"tag":64,"props":252,"children":253},{"style":71},[254],{"type":24,"value":255},"out",{"type":19,"tag":64,"props":257,"children":258},{"style":88},[259],{"type":24,"value":260}," employee)) {\n",{"type":19,"tag":64,"props":262,"children":264},{"class":66,"line":263},6,[265,270,274,278,282],{"type":19,"tag":64,"props":266,"children":267},{"style":88},[268],{"type":24,"value":269},"    employee ",{"type":19,"tag":64,"props":271,"children":272},{"style":71},[273],{"type":24,"value":117},{"type":19,"tag":64,"props":275,"children":276},{"style":120},[277],{"type":24,"value":123},{"type":19,"tag":64,"props":279,"children":280},{"style":82},[281],{"type":24,"value":176},{"type":19,"tag":64,"props":283,"children":284},{"style":88},[285],{"type":24,"value":286},"(whatever);\n",{"type":19,"tag":64,"props":288,"children":290},{"class":66,"line":289},7,[291,296,301],{"type":19,"tag":64,"props":292,"children":293},{"style":88},[294],{"type":24,"value":295},"    employees.",{"type":19,"tag":64,"props":297,"children":298},{"style":179},[299],{"type":24,"value":300},"Add",{"type":19,"tag":64,"props":302,"children":303},{"style":88},[304],{"type":24,"value":305},"(name, employee);\n",{"type":19,"tag":64,"props":307,"children":309},{"class":66,"line":308},8,[310],{"type":19,"tag":64,"props":311,"children":312},{"style":88},[313],{"type":24,"value":314},"  }\n",{"type":19,"tag":64,"props":316,"children":318},{"class":66,"line":317},9,[319,324],{"type":19,"tag":64,"props":320,"children":321},{"style":120},[322],{"type":24,"value":323},"  return",{"type":19,"tag":64,"props":325,"children":326},{"style":88},[327],{"type":24,"value":216},{"type":19,"tag":64,"props":329,"children":331},{"class":66,"line":330},10,[332],{"type":19,"tag":64,"props":333,"children":334},{"style":88},[335],{"type":24,"value":336},"}\n",{"type":19,"tag":20,"props":338,"children":339},{},[340],{"type":24,"value":39},{"type":19,"tag":53,"props":342,"children":344},{"className":55,"code":343,"language":57,"meta":58,"style":58},"public static Employee GetByName(string name) {\n  return employees.GetOrAdd(name, () => new Employee(whatever));\n}\n",[345],{"type":19,"tag":27,"props":346,"children":347},{"__ignoreMap":58},[348,383,423],{"type":19,"tag":64,"props":349,"children":350},{"class":66,"line":67},[351,355,359,363,367,371,375,379],{"type":19,"tag":64,"props":352,"children":353},{"style":71},[354],{"type":24,"value":167},{"type":19,"tag":64,"props":356,"children":357},{"style":71},[358],{"type":24,"value":79},{"type":19,"tag":64,"props":360,"children":361},{"style":82},[362],{"type":24,"value":176},{"type":19,"tag":64,"props":364,"children":365},{"style":179},[366],{"type":24,"value":182},{"type":19,"tag":64,"props":368,"children":369},{"style":88},[370],{"type":24,"value":187},{"type":19,"tag":64,"props":372,"children":373},{"style":94},[374],{"type":24,"value":97},{"type":19,"tag":64,"props":376,"children":377},{"style":194},[378],{"type":24,"value":197},{"type":19,"tag":64,"props":380,"children":381},{"style":88},[382],{"type":24,"value":202},{"type":19,"tag":64,"props":384,"children":385},{"class":66,"line":151},[386,390,395,400,405,410,414,418],{"type":19,"tag":64,"props":387,"children":388},{"style":120},[389],{"type":24,"value":323},{"type":19,"tag":64,"props":391,"children":392},{"style":88},[393],{"type":24,"value":394}," employees.",{"type":19,"tag":64,"props":396,"children":397},{"style":179},[398],{"type":24,"value":399},"GetOrAdd",{"type":19,"tag":64,"props":401,"children":402},{"style":88},[403],{"type":24,"value":404},"(name, () ",{"type":19,"tag":64,"props":406,"children":407},{"style":71},[408],{"type":24,"value":409},"=>",{"type":19,"tag":64,"props":411,"children":412},{"style":120},[413],{"type":24,"value":123},{"type":19,"tag":64,"props":415,"children":416},{"style":82},[417],{"type":24,"value":176},{"type":19,"tag":64,"props":419,"children":420},{"style":88},[421],{"type":24,"value":422},"(whatever));\n",{"type":19,"tag":64,"props":424,"children":425},{"class":66,"line":161},[426],{"type":19,"tag":64,"props":427,"children":428},{"style":88},[429],{"type":24,"value":336},{"type":19,"tag":20,"props":431,"children":432},{},[433],{"type":24,"value":434},"Here’s an extension method to drop-in to a static class of your choosing that achieves just that.",{"type":19,"tag":53,"props":436,"children":438},{"className":55,"code":437,"language":57,"meta":58,"style":58},"public static TDictionaryValue GetOrAdd\u003CTKey, TDictionaryValue>(\n  this IDictionary\u003CTKey, TDictionaryValue> dictionary,\n  TKey key,\n  Func\u003CTDictionaryValue> newValue\n) {\n  TDictionaryValue value;\n  if (!dictionary.TryGetValue(key, out value)) {\n    value = newValue.Invoke();\n    dictionary.Add(key, value);\n  }\n  return value;\n}\n",[439],{"type":19,"tag":27,"props":440,"children":441},{"__ignoreMap":58},[442,487,531,548,573,580,593,631,658,675,682,694],{"type":19,"tag":64,"props":443,"children":444},{"class":66,"line":67},[445,449,453,458,463,467,473,477,482],{"type":19,"tag":64,"props":446,"children":447},{"style":71},[448],{"type":24,"value":167},{"type":19,"tag":64,"props":450,"children":451},{"style":71},[452],{"type":24,"value":79},{"type":19,"tag":64,"props":454,"children":455},{"style":82},[456],{"type":24,"value":457}," TDictionaryValue",{"type":19,"tag":64,"props":459,"children":460},{"style":179},[461],{"type":24,"value":462}," GetOrAdd",{"type":19,"tag":64,"props":464,"children":465},{"style":88},[466],{"type":24,"value":91},{"type":19,"tag":64,"props":468,"children":470},{"style":469},"--shiki-default:#3A94C5;--shiki-default-font-style:inherit;--shiki-dark:#FFB86C;--shiki-dark-font-style:italic",[471],{"type":24,"value":472},"TKey",{"type":19,"tag":64,"props":474,"children":475},{"style":88},[476],{"type":24,"value":102},{"type":19,"tag":64,"props":478,"children":479},{"style":469},[480],{"type":24,"value":481},"TDictionaryValue",{"type":19,"tag":64,"props":483,"children":484},{"style":88},[485],{"type":24,"value":486},">(\n",{"type":19,"tag":64,"props":488,"children":489},{"class":66,"line":151},[490,495,500,504,508,512,516,521,526],{"type":19,"tag":64,"props":491,"children":492},{"style":71},[493],{"type":24,"value":494},"  this",{"type":19,"tag":64,"props":496,"children":497},{"style":82},[498],{"type":24,"value":499}," IDictionary",{"type":19,"tag":64,"props":501,"children":502},{"style":88},[503],{"type":24,"value":91},{"type":19,"tag":64,"props":505,"children":506},{"style":82},[507],{"type":24,"value":472},{"type":19,"tag":64,"props":509,"children":510},{"style":88},[511],{"type":24,"value":102},{"type":19,"tag":64,"props":513,"children":514},{"style":82},[515],{"type":24,"value":481},{"type":19,"tag":64,"props":517,"children":518},{"style":88},[519],{"type":24,"value":520},"> ",{"type":19,"tag":64,"props":522,"children":523},{"style":194},[524],{"type":24,"value":525},"dictionary",{"type":19,"tag":64,"props":527,"children":528},{"style":88},[529],{"type":24,"value":530},",\n",{"type":19,"tag":64,"props":532,"children":533},{"class":66,"line":161},[534,539,544],{"type":19,"tag":64,"props":535,"children":536},{"style":82},[537],{"type":24,"value":538},"  TKey",{"type":19,"tag":64,"props":540,"children":541},{"style":194},[542],{"type":24,"value":543}," key",{"type":19,"tag":64,"props":545,"children":546},{"style":88},[547],{"type":24,"value":530},{"type":19,"tag":64,"props":549,"children":550},{"class":66,"line":205},[551,556,560,564,568],{"type":19,"tag":64,"props":552,"children":553},{"style":82},[554],{"type":24,"value":555},"  Func",{"type":19,"tag":64,"props":557,"children":558},{"style":88},[559],{"type":24,"value":91},{"type":19,"tag":64,"props":561,"children":562},{"style":82},[563],{"type":24,"value":481},{"type":19,"tag":64,"props":565,"children":566},{"style":88},[567],{"type":24,"value":520},{"type":19,"tag":64,"props":569,"children":570},{"style":194},[571],{"type":24,"value":572},"newValue\n",{"type":19,"tag":64,"props":574,"children":575},{"class":66,"line":219},[576],{"type":19,"tag":64,"props":577,"children":578},{"style":88},[579],{"type":24,"value":202},{"type":19,"tag":64,"props":581,"children":582},{"class":66,"line":263},[583,588],{"type":19,"tag":64,"props":584,"children":585},{"style":82},[586],{"type":24,"value":587},"  TDictionaryValue",{"type":19,"tag":64,"props":589,"children":590},{"style":88},[591],{"type":24,"value":592}," value;\n",{"type":19,"tag":64,"props":594,"children":595},{"class":66,"line":289},[596,600,604,608,613,617,622,626],{"type":19,"tag":64,"props":597,"children":598},{"style":120},[599],{"type":24,"value":225},{"type":19,"tag":64,"props":601,"children":602},{"style":88},[603],{"type":24,"value":230},{"type":19,"tag":64,"props":605,"children":606},{"style":71},[607],{"type":24,"value":235},{"type":19,"tag":64,"props":609,"children":610},{"style":88},[611],{"type":24,"value":612},"dictionary.",{"type":19,"tag":64,"props":614,"children":615},{"style":179},[616],{"type":24,"value":245},{"type":19,"tag":64,"props":618,"children":619},{"style":88},[620],{"type":24,"value":621},"(key, ",{"type":19,"tag":64,"props":623,"children":624},{"style":71},[625],{"type":24,"value":255},{"type":19,"tag":64,"props":627,"children":628},{"style":88},[629],{"type":24,"value":630}," value)) {\n",{"type":19,"tag":64,"props":632,"children":633},{"class":66,"line":308},[634,639,643,648,653],{"type":19,"tag":64,"props":635,"children":636},{"style":88},[637],{"type":24,"value":638},"    value ",{"type":19,"tag":64,"props":640,"children":641},{"style":71},[642],{"type":24,"value":117},{"type":19,"tag":64,"props":644,"children":645},{"style":88},[646],{"type":24,"value":647}," newValue.",{"type":19,"tag":64,"props":649,"children":650},{"style":179},[651],{"type":24,"value":652},"Invoke",{"type":19,"tag":64,"props":654,"children":655},{"style":88},[656],{"type":24,"value":657},"();\n",{"type":19,"tag":64,"props":659,"children":660},{"class":66,"line":317},[661,666,670],{"type":19,"tag":64,"props":662,"children":663},{"style":88},[664],{"type":24,"value":665},"    dictionary.",{"type":19,"tag":64,"props":667,"children":668},{"style":179},[669],{"type":24,"value":300},{"type":19,"tag":64,"props":671,"children":672},{"style":88},[673],{"type":24,"value":674},"(key, value);\n",{"type":19,"tag":64,"props":676,"children":677},{"class":66,"line":330},[678],{"type":19,"tag":64,"props":679,"children":680},{"style":88},[681],{"type":24,"value":314},{"type":19,"tag":64,"props":683,"children":685},{"class":66,"line":684},11,[686,690],{"type":19,"tag":64,"props":687,"children":688},{"style":120},[689],{"type":24,"value":323},{"type":19,"tag":64,"props":691,"children":692},{"style":88},[693],{"type":24,"value":592},{"type":19,"tag":64,"props":695,"children":697},{"class":66,"line":696},12,[698],{"type":19,"tag":64,"props":699,"children":700},{"style":88},[701],{"type":24,"value":336},{"type":19,"tag":20,"props":703,"children":704},{},[705],{"type":19,"tag":706,"props":707,"children":708},"em",{},[709],{"type":24,"value":710},"[)amien",{"type":19,"tag":712,"props":713,"children":714},"style",{},[715],{"type":24,"value":716},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":58,"searchDepth":151,"depth":151,"links":718},[],"markdown","content:blog:2009:dictionaryt-look-up-or-create-made-simpler.md","content","blog/2009/dictionaryt-look-up-or-create-made-simpler.md","blog/2009/dictionaryt-look-up-or-create-made-simpler","md","/blog/2009/dictionaryt-look-up-or-create-made-simpler/",234,[728,732,736],{"title":729,"date":730,"url":731},"HTML5 Video Cheatsheet: Optimizing videos for the web","2025-12-05T00:00:00Z","/blog/2025/html5-video-cheatsheet/",{"title":733,"date":734,"url":735},"Transactions in the MongoDB EF Core Provider","2025-10-25","/blog/2025/mongodb-explicit-transactions/",{"title":737,"date":738,"url":739},"Queryable Encryption with the MongoDB EF Core Provider","2025-09-22","/blog/2025/mongodb-queryable-encryption/",[741,762,783,814,856,882],{"_path":742,"_dir":743,"_draft":6,"_partial":6,"_locale":7,"title":744,"description":745,"id":746,"name":747,"email":748,"avatar":749,"date":750,"body":751,"_type":719,"_id":759,"_source":721,"_file":760,"_stem":761,"_extension":724},"/comments/dictionaryt-look-up-or-create-made-simpler/42317","dictionaryt-look-up-or-create-made-simpler","42317","Interesting that this became a function on the ConcurrentDictionary class in .NET 4 ;)",42317,"Mike Brown","mbrown@kharasoft.com","https://www.gravatar.com/avatar/c7674323cc6e35a0756f967befae11da?r=pg&d=retro","2010-08-27T23:03:00",{"type":16,"children":752,"toc":757},[753],{"type":19,"tag":20,"props":754,"children":755},{},[756],{"type":24,"value":745},{"title":58,"searchDepth":151,"depth":151,"links":758},[],"content:comments:dictionaryt-look-up-or-create-made-simpler:42317.md","comments/dictionaryt-look-up-or-create-made-simpler/42317.md","comments/dictionaryt-look-up-or-create-made-simpler/42317",{"_path":763,"_dir":743,"_draft":6,"_partial":6,"_locale":7,"title":764,"description":765,"id":766,"name":767,"email":768,"avatar":769,"url":770,"date":771,"body":772,"_type":719,"_id":780,"_source":721,"_file":781,"_stem":782,"_extension":724},"/comments/dictionaryt-look-up-or-create-made-simpler/22945","22945","Using double checked locking without knowing that the variable in question is marked \"volatile\" is a potential source of threading errors.",22945,"Brad Wilson","dotnetguy@gmail.com","https://www.gravatar.com/avatar/2560112a578efab82a5fddd7284ef4f2?r=pg&d=retro","https://bradwilson.typepad.com/","2009-08-07T22:54:54",{"type":16,"children":773,"toc":778},[774],{"type":19,"tag":20,"props":775,"children":776},{},[777],{"type":24,"value":765},{"title":58,"searchDepth":151,"depth":151,"links":779},[],"content:comments:dictionaryt-look-up-or-create-made-simpler:22945.md","comments/dictionaryt-look-up-or-create-made-simpler/22945.md","comments/dictionaryt-look-up-or-create-made-simpler/22945",{"_path":784,"_dir":743,"_draft":6,"_partial":6,"_locale":7,"title":785,"description":786,"id":787,"name":788,"email":789,"avatar":790,"url":791,"date":792,"body":793,"_type":719,"_id":811,"_source":721,"_file":812,"_stem":813,"_extension":724},"/comments/dictionaryt-look-up-or-create-made-simpler/22547","22547","Nice one",22547,"Will","willvv@gmail.com","https://www.gravatar.com/avatar/5fdb7ee5ddaa79e5715407c6512cd4a4?r=pg&d=retro","https://twitter.com/willvv","2009-08-05T06:27:22",{"type":16,"children":794,"toc":809},[795,799,804],{"type":19,"tag":20,"props":796,"children":797},{},[798],{"type":24,"value":786},{"type":19,"tag":20,"props":800,"children":801},{},[802],{"type":24,"value":803},"Definitely I have to get used to the use of extension methods, it seems really obvious after you've seen it, but if you haven't used extension methods it is hard for it to \"pop up\" ",{"type":19,"tag":20,"props":805,"children":806},{},[807],{"type":24,"value":808},"Cheers!",{"title":58,"searchDepth":151,"depth":151,"links":810},[],"content:comments:dictionaryt-look-up-or-create-made-simpler:22547.md","comments/dictionaryt-look-up-or-create-made-simpler/22547.md","comments/dictionaryt-look-up-or-create-made-simpler/22547",{"_path":815,"_dir":743,"_draft":6,"_partial":6,"_locale":7,"title":816,"description":817,"id":818,"name":819,"email":820,"avatar":821,"url":822,"date":823,"body":824,"_type":719,"_id":853,"_source":721,"_file":854,"_stem":855,"_extension":724},"/comments/dictionaryt-look-up-or-create-made-simpler/22511","22511","Why do you call invoke on the delegate instead of using () to execute?",22511,"David Fowler","david.fowler@microsoft.com","https://www.gravatar.com/avatar/9d6161f7a9eaf37fa9df33b656d870b7?r=pg&d=retro","https://weblogs.asp.net/davidfowler","2009-08-05T00:16:52",{"type":16,"children":825,"toc":851},[826,830,846],{"type":19,"tag":20,"props":827,"children":828},{},[829],{"type":24,"value":817},{"type":19,"tag":20,"props":831,"children":832},{},[833,835,840],{"type":24,"value":834},"Also checkout ",{"type":19,"tag":836,"props":837,"children":839},"a",{"href":838},"https://blogs.msdn.com/wesdyer/archive/2007/01/26/function-memoization.aspx",[],{"type":19,"tag":836,"props":841,"children":844},{"href":838,"rel":842},[843],"nofollow",[845],{"type":24,"value":838},{"type":19,"tag":20,"props":847,"children":848},{},[849],{"type":24,"value":850},"Functional programming for life!",{"title":58,"searchDepth":151,"depth":151,"links":852},[],"content:comments:dictionaryt-look-up-or-create-made-simpler:22511.md","comments/dictionaryt-look-up-or-create-made-simpler/22511.md","comments/dictionaryt-look-up-or-create-made-simpler/22511",{"_path":857,"_dir":743,"_draft":6,"_partial":6,"_locale":7,"title":858,"description":859,"id":860,"name":861,"email":862,"avatar":863,"url":864,"date":865,"body":866,"_type":719,"_id":879,"_source":721,"_file":880,"_stem":881,"_extension":724},"/comments/dictionaryt-look-up-or-create-made-simpler/22486","22486","Oops, the code was right on my VS box but going from code to HTML I'd missed a couple of those pesky \u003C bits :D",22486,"Damien Guard","damien@envytech.co.uk","https://www.gravatar.com/avatar/dc72963e7279d34c85ed4c0b731ce5a9?r=pg&d=retro","https://damieng.com/","2009-08-04T20:52:34",{"type":16,"children":867,"toc":877},[868,872],{"type":19,"tag":20,"props":869,"children":870},{},[871],{"type":24,"value":859},{"type":19,"tag":20,"props":873,"children":874},{},[875],{"type":24,"value":876},"Thanks for the heads-up.",{"title":58,"searchDepth":151,"depth":151,"links":878},[],"content:comments:dictionaryt-look-up-or-create-made-simpler:22486.md","comments/dictionaryt-look-up-or-create-made-simpler/22486.md","comments/dictionaryt-look-up-or-create-made-simpler/22486",{"_path":883,"_dir":743,"_draft":6,"_partial":6,"_locale":7,"title":884,"description":885,"id":886,"name":887,"email":888,"avatar":889,"url":890,"date":891,"body":892,"_type":719,"_id":900,"_source":721,"_file":901,"_stem":902,"_extension":724},"/comments/dictionaryt-look-up-or-create-made-simpler/22484","22484","Heya Damien, did you mean to use the non-generic IDictionary interface in your static method signatures?",22484,"Nick","niblumha@microsoft.com","https://www.gravatar.com/avatar/a51fcd71849b8176d34b37def0a68b99?r=pg&d=retro","https://blogs.msdn.com/nblumhardt","2009-08-04T20:47:56",{"type":16,"children":893,"toc":898},[894],{"type":19,"tag":20,"props":895,"children":896},{},[897],{"type":24,"value":885},{"title":58,"searchDepth":151,"depth":151,"links":899},[],"content:comments:dictionaryt-look-up-or-create-made-simpler:22484.md","comments/dictionaryt-look-up-or-create-made-simpler/22484.md","comments/dictionaryt-look-up-or-create-made-simpler/22484",1779264585121]