title: C# Return Results of Dictionary Lookup or if NULL return something else
body: <p>Here is my current function (it works but wondering if there is a cleaner way to do it).</p>
  
  <pre><code>public static Dictionary&lt;int, double&gt; profileNetworkLowCostPriorityList;
  
  public static double DetermineNetworkSortOrderValue(int network, double fee)
  {
      if (profileNetworkLowCostPriorityList == null) return fee;
      if (profileNetworkLowCostPriorityList[network] != null) return profileNetworkLowCostPriorityList[network];
      return fee;
  }
  </code></pre>
  
  <p>Basically, if the <code>Dictonary</code> object is not null and there was something found in the dictonary, return that something. If not, return something else. My concern is in referencing a null dictionary object and that throwing an error. I can of course catch the error and return something but not sure if that is the best approach.</p>
  
  <p>This code will run up to hundreds of millions of times for each "widget" we process so looking for an "efficient way" to do this.</p>