title: C# Implicit operator with generic
body: <p>I'm writing an abstract wrapper for enum in C # (I want something like enum in Vala). My code is:</p>
  
  <pre><code>    public abstract class Wraper&lt;T, TE&gt;
          where T : Wraper&lt;T, TE&gt;, new()
      {
          public TE Value;
  
          public static implicit operator T(TE value)
          {
              return new T() { Value = value };
          }
  
          public static implicit operator TE(T value)
          {
              return value.Value;
          }
      }
  </code></pre>
  
  <p>I want to do with something like this:</p>
  
  <pre><code>    public enum EFoo { A, B, C, D, E};
      public class Foo : Wraper&lt;Foo, EFoo&gt;
      {
          public bool IsBla
          {
              get { return Value == EFoo.A || Value == EFoo.E; }
          }
      }
  
      ...
  
      Foo foo = EFoo.A;
      bool bla = foo.IsBla;
  </code></pre>
  
  <p>But the code does not compile because C # does not allow both generic parameter,. When compile reports an error:</p>
  
  <pre><code>User-defined conversion must convert to or from the enclosing type
  </code></pre>
  
  <p>On line</p>
  
  <pre><code>public static implicit operator T(TE value)
  </code></pre>
  
  <p>Is there any work around or in C# is not so simple?</p>