Overloading bitwise operator while using interface-based development
<p>Using C# 3.0, .NET 3.5</p>

<p>I have a need for an enumeration that is a little smarter than a simple number.  I have worked around this with static classes and properties, but one thing I am missing is the ability to use the enumeration like a bit flag without accessing a specfic properity.</p>

<p>For example this works:</p>

<pre><code>public interface isomething
{
int value { get; }
}

public class something : isomething
{
public int value {get; private set;}

public somthing(int value)
{
this.value = value
}

public void DoSomething()
{
throw new NotImplementedException();
}
}

public static class SuperEnum
{
public static isomething first = new something(1);
public static isomething second= new something(2);
}
</code></pre>

<p>Then execute something like this:</p>

<pre><code>Assert.IsTrue((SuperEnum.first.value | SuperEnum.second.value) == 3);
</code></pre>

<p>And you get a true.  But if I add this to the something class:</p>

<pre><code>public static int operator | (something leftSide, isomething rightside)
{
return leftside.value | rightside.value
}
</code></pre>

<p>Then execute something like this:</p>

<pre><code>Assert.IsTrue((SuperEnum.first | SuperEnum.second) == 3);
</code></pre>

<p>I get a message that | operator can not used on the isomething type which sucks.  </p>

<p>If I go with concrete types, I am fine, but that is going to cause problems in the future.</p>

<p>Anyone got any ideas?</p>

<p>Thanks, mark </p>
