This really is basically what I wish to do:

public abstract class Uniform<T>
{
    public readonly int Location;
    private T _variable;

    public virtual T Variable
    {
        get { return _variable; }
    }
}

public class UniformMatrix4 : Uniform<Matrix4>
{
    public override Matrix4 Variable
    {
        set
        {
            _variable = value;
            GL.UniformMatrix4(Location, false, ref _variable);
        }
    }
}

The getter for Variable would be the same across all derived classes, however the setter must be different.

Actually... I'd prefer not have derived classes whatsoever (it's just one function call which will differ for every type) however i can't think about how else to get it done.


Edit: Whether it wasn't obvious exactly what the problem I am getting is, I am obtaining a syntax error:

'UniformMatrix4.Variable.set': cannot override because 'Uniform.Variable' doesn't have an overridable set accessor

And I am unsure how you can create an "overridable set accessor"... virtual and abstract don't appear to become permitted around the setter.

You cannot do that in C#, but like a workaround you could do this this. It might involve calling an abstract setter function that could be overridden by derived classes, while departing the conventional get intact. Would the work?

public abstract class Uniform<T>
{
    public readonly int Location;
    protected T _variable;

    public T Variable
    {
        get { return _variable; }
        set { SetVariable(value); } 
    }

    protected abstract void SetVariable(T value);
}

public class UniformMatrix4 : Uniform<Matrix4>
{
    public override void SetVariable(Matrix4x4 value)
    {
        _variable = value;
        GL.UniformMatrix4(Location, false, ref _variable);
    }
}

It's not possible to get this done in C#. You need to give a setter towards the base class, making it throw an "Invalid Operation" exception.

You will have to do that:

public abstract class Uniform<T>
{
    public readonly int Location;

    public virtual T Variable
    {
        get; set;
    }
}

public class UniformMatrix4 : Uniform<Matrix4>
{
    public override Matrix4 Variable
    {
        get
        {
            return base.Variable;
        }
        set
        {
            base.Variable = value;
            GL.UniformMatrix4(Location, false, ref value);
        }
    }
}

When I understand, the behavior would be the expected.

Hope it will help.