In some certain scenario it appeared to be useful for me to have a short-spoken, readable way to get null instead of the KeyNotFoundException while accessing dictionary value by key, when there is no such key in the dictionary.  The first thing that came into my mind was an extension method:  public static U GetValueByKeyOrNull&lt;T, U&gt;(this Dictionary&lt;T, U&gt; dict, T key)         where U : class //it's acceptable for me to have this constraint {     if (dict.ContainsKey(key))         return dict[key];     else          //it could be default(U) to use without U class constraint         //however, I didn't need this.         return null;  }   But it's not very short-spoken actually, when you write something like this:  string.Format("{0}:{1};{2}:{3}",                                                                dict.GetValueByKeyOrNull("key1"),               dict.GetValueByKeyOrNull("key2"),               dict.GetValueByKeyOrNull("key3"),               dict.GetValueByKeyOrNull("key4"));   I'd say, it would be much better to havesomething close to base syntax: dict["key4"].  Then I came up with an idea to have a class with a private dictionary field, which exposed the functionality I need:  public class MyDictionary&lt;T, U&gt; //here I may add any of interfaces, implemented                                 //by dictionary itself to get an opportunity to,                                 //say, use foreach, etc. and implement them                                 // using the dictionary field.         where U : class {     private Dictionary&lt;T, U&gt; dict;      public MyDictionary()     {         dict = new Dictionary&lt;T, U&gt;();     }      public U this[T key]     {         get         {             if (dict.ContainsKey(key))                 return dict[key];             else                 return null;         }         set         {             dict[key] = value;         }     } }   But it seems a little overhead to get the slight change in the basic behaviour.  One more workaround could be to define a Func in the current context like this:  Func&lt;string, string&gt; GetDictValueByKeyOrNull = (key) =&gt; {     if (dict.ContainsKey(key))         return dict[key];     else         return null; };   so it could be utilized like GetDictValueByKeyOrNull("key1").  Could you, please, give me any more suggestions or help to choose a better one?
The indexer into Dictionary throws an exception if the key is missing.  Is there an implementation of IDictionary that instead will return default(T)? I know about the TryGetValue() method, but that's impossible to use with LINQ. Would this efficiently do what I need?: myDict.FirstOrDefault(a =&gt; a.Key == someKeyKalue);  I don't think it will as I think it will iterate the keys instead of using a Hash lookup.
Simulating the Windows key on an old keyboard I have recently started reading and watching Naruto. I was wondering in what aspect does the clones made by different techniques differ? They all have the same potential and capabilities. Evaluation of $\sin \frac{\pi}{7}\cdot \sin \frac{2\pi}{7}\cdot \sin \frac{3\pi}{7}$ Evaluation of $$\sin \frac{\pi}{7}\cdot \sin \frac{2\pi}{7}\cdot \sin \frac{3\pi}{7} = $$   $\bf{My\; Try::}$ I have solved Using Direct formula::  $$\sin \frac{\pi}{n}\cdot \sin \frac{2\pi}{n}\cdot......\sin \frac{(n-1)\pi}{n} = \frac{n}{2^{n-1}}$$  Now Put $n=7\;,$ We get   $$\sin \frac{\pi}{7}\cdot \sin \frac{2\pi}{7}\cdot \sin \frac{3\pi}{7}\cdot \sin \frac{4\pi}{7}\cdot \sin \frac{5\pi}{7}\cdot \sin \frac{6\pi}{7}=\frac{7}{2^{7-1}}$$  So $$\sin \frac{\pi}{7}\cdot \sin \frac{2\pi}{7}\cdot \sin \frac{3\pi}{7} =\frac{\sqrt{7}}{8}$$  Now my question is how can we solve it without using Direct Formula, Help me  Thanks I'm from the State of Kuwait and hold an Eritrean passport. I'm planning to visit UK in October but my visa will expire in November.    Is it OK to make a journey in the last month of my visa, provided that I make sure that I book my plane back before expiring date? What is the maximum texture size available on the iPad? I'm a web designer and I'd like to make a custom wordpress theme for my upcoming blog. The template is already made in photoshop but I need a good starting point. I don't have too much experience with Wordpress but I want something that is SEO friendly which I can edit without risking getting poor search results.  I Know about Starkers and that there are other blank themes out there, but are they good for SEO? For equal cost, why would you select the MacBook Air over the MacBook Pro? I can see that the 13" version of MacBook Pro and MacBook Air is same $1199, but the Pro is more feature-loaded than Macbook Air. Why would anyone buy MacBook Air? What's the catch in this?    I was thinking of buying a MacBook for development purposes, and worried if there's any problem in the Pro version, because it comes with more features (like more storage).  Edit:    Thanks for the answer guys, I bought a MacBook Pro a week ago and already loving it. Cost Distance Analyst In QGIS? Are there any tools, plugins or methods in QGIS which allows for an analysis of the best path between two points using least cost path method? As shown below ArcGIS has several distance tools. is a light side power that many Jedi, including  are capable of. In Episode I, Qui-Gon uses it twice (once to outrun droids and once on Jar Jar's tongue), Obi-Wan uses it once and Anakin uses high speed reflexes for the entire duration of the pod race with no formal training.  According to  the power has a high drain and requires a longer recovery period than other powers. And then of course there are hilarious drawbacks such as .  But why wasn't this power used in the following scenarios (and many, many others):   The Redshirt Jedi who accompanied Windu to arrest Palpatine, before they were summarily dispatched to the Nether. Qui-Gonn, to avoid a lightsaber through his gut. Yoda, to avoid flying senate seats. By Windu, who is supposedly a notable practitioner. I'd love your help with finding the sign of the following integral: $\int_{0}^{2 \pi}\frac{\sin x}{x} dx$,I know that computing it is impossible.  I tried to use integration by parts and maybe to learn about the sign of each part and conclude something but It didn't work for me.  Any suggestions? How best to determine if an argument is not sent to the JavaScript function I have now seen 2 methods for determining if an argument has been passed to a JavaScript function. I'm wondering if one method is better than the other or if one is just bad to use?   function Test(argument1, argument2) {       if (Test.arguments.length == 1) argument2 = 'blah';        alert(argument2);  }   Test('test');   Or   function Test(argument1, argument2) {       argument2 = argument2 || 'blah';        alert(argument2);  }   Test('test');   As far as I can tell, they both result in the same thing, but I've only used the first one before in production.  Another Option as mentioned by :  function Test(argument1, argument2) {     if(argument2 === null) {         argument2 = 'blah';     }      alert(argument2); }   As per Juan's comment, it would be better to change Tom's suggestion to:  function Test(argument1, argument2) {     if(argument2 === undefined) {         argument2 = 'blah';     }      alert(argument2); } Create WiFi hotspot on ubuntu Insert list of figures in the table of contents Is it possible to create a list of all the figures at the end of a document (this I can do) and make it appear in the table of contents?  So in the the table of content there will be a line saying List of figures ... 19 for example? I need to hide field 'B' when the value in field 'A' is NOT equal to 'Other'.  This is a custom list form.  Is jquery the way to go? 2 orderby in wp_query with 2 custom fields I'm triyng to display hotels (taxonomy which i have created) by two 'orderby' with wp_query but i'm not success.  Results looks likes:  Hotel 1 :       2 persons          5 stars Hotel 2 :       2 persons          4 stars Hotel 3 :       2 persons          3 stars Hotel 4 :       3 persons          5 stars Hotel 5 :       5 persons          5 stars Hotel 6:        10 persons         2 stars Hotel 7:        10 persons         1 star   The first 'order by' is on the number of persons(the biggest in first) and the second 'order by' is on the rating in stars (so, if several hotels have the same number of persons, the hotel with the biggest stars rating would be in first).  Below my code. I have tried to add an array inside an array with meta_query but it doesn't work.  $args=             array(                                     'post_type' =&gt; 'hotel',                                     'Services' =&gt; $Services,                                     'Town' =&gt; $Town,                                      'meta_key' =&gt; 'Number_persons',                                     'orderby' =&gt; 'meta_value_num',                                     'order' =&gt; 'ASC',                                        'meta_query' =&gt; array(                                                            array(                                                                'meta_key' =&gt; 'Rating',                                                                'orderby' =&gt; 'meta_value',                                                                'order' =&gt; 'DESC',                                                               )                                                        )                  );   $the_query = new WP_Query( $args );   Thanks a lot :) Emails Per Invocation Still Capped at 100? "With who" vs. "with whom" Is this correct?     The person with whom I'm doing the project should be here soon.   If it is, is with always a dative preposition (like mit in German)? Please see the following image, where you can find the inconsistency of SO reputation score among different flair themes (one with 7165, while all other three 7265).   I always thought that these four themes are based on the same data until now. Is this a bug? Are different flair themes really updated individually?    P.S.: The inconsistency only shows on my mobile, no problem from my desktop. Field that is a subfield of own of its subfields Let $K$ and $L$ be fields. We have homomorphisms $f: K \to L$ and $g: L \to K$. Are $K$ and $L$ necessarily isomorphic? Clipping LAS data using shapefile polygons and open source software? I am trying to clip or filter lidar files (.las, .xyz) using a shapefile that contains multiple polygons.  Is there open source software that can do this spatial operation?  My .las files are enormous, and I should say that I am very new to DEM data and analysis so any help would be very welcome.