I have the following code:

```
class Foo<T> where T : struct
{
    private T t;
    [...]
    public bool Equals(T t) { return this.t == t; }
}

```

When I try to compile, it gives me the following error:

> 
> Operator '==' cannot be applied to operands of type 'T' and 'T'
> 
> 
> 

Why can't it be done? If the constraint was `where T : class` it would have worked. But I need it to be value type because in my implementation this generic will always be an enum.

What I am doing to circunvent the situation is using `Object.Equals()` method. Will it ensure the correct behavior all the time, since I am only comparing between T?