Suppose you are given some generic type TOperand. If the operand extends IUnaryNegationOperators the method should return -operand, else throw Error.

Below I’ve added a example of the Type check I’m trying to preform. I am unable to modify the abstract class Foo and I seem to be unable to preform the type check on line 12.

i

using System.Numerics;

public abstract class Foo
{
    public abstract TResult test<TOperand, TResult>(TOperand operand);
}

public class Bar : Foo
{
    public override TResult test<TOperand, TResult>(TOperand operand)
    {
        if (operand is IUnaryNegationOperators<TOperand, TResult>)
        {
            // execute some code
        }

        throw new Exception("Invalid Type");
    }
}

6