Question: I have some generic method

```
T SomeMethod(Func<T> func){
   T result = func();
     if (result != null)
       { //.....}
}

```

It works good if `T` is class. But what should I do if `T` is struct? How can I check if `result == default(T)` in case if `T` is `struct`? 

P.S. I don't want to use the constraint `where T: class` or `Nullable` types.

Answer: 
A more idiomatic way of doing this would be to follow the lead of things like `int.TryParse`.

```
public delegate bool TryFunction<T>(out T result);

T SomeMethod(TryFunction<T> func)
{
    T value;

    if(func(out value))
    {

    }
}

```
Consider using default(T):

```
private T SomeMethod<T>(Func<T> func)
{
  var result = func();
  if (result.Equals(default(T)))
  {
    // handling ...
    return default(T);
  }
  return result;
}

```