title: How to create extension method on enumeration (c#)
body: <p>I want to create an extension method that will return an enum value by its key. 
  The usage will be </p>
  
  <pre><code>LifeCycle.GetLifeCycle(1) 
  </code></pre>
  
  <p>or 
      LifeCycle.GetLifeCycleByValue("") </p>
  
  <p>Here is what I thought of - Let's say I have the following enum : </p>
  
  <pre><code>public enum LifeCycle
  {
      Pending = 0,
      Approved = 1,
      Rejected = 2,
  }
  </code></pre>
  
  <p>And I wrote the following extension for the getByint case</p>
  
  <pre><code>public static class EnumerationExtensions
  {
      private static Dictionary&lt;int, LifeCycle&gt; _lifeCycleMap = Enum.GetValues(typeof(LifeCycle)).Cast&lt;int&gt;().ToDictionary(Key =&gt; Key, value =&gt; ((LifeCycle)value));
  
      public static LifeCycle GetLifeCycle(this LifeCycle lifeCycle, int lifeCycleKey)
      {
          return _lifeCycleMap[lifeCycleKey];
      }
  }
  </code></pre>
  
  <p>So far </p>
  
  <pre><code> LifeCycle.GetLifeCycle(1) 
  </code></pre>
  
  <p>doenst compile.  </p>
  
  <p>Is that even possible ? </p>