13 lines
		
	
	
		
			304 B
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			13 lines
		
	
	
		
			304 B
		
	
	
	
		
			C#
		
	
	
	
|  | using System.Collections.Generic; | |||
|  | 
 | |||
|  | public static class DictionaryExtensions { | |||
|  | 
 | |||
|  |     public static U GetOrDefault<T, U>(this Dictionary<T, U> dict, T key, U defaultValue){ | |||
|  |         if(dict.ContainsKey(key)){ | |||
|  |             return dict[key]; | |||
|  |         }else{ | |||
|  |             return defaultValue; | |||
|  |         } | |||
|  |     } | |||
|  | } |