The example I am giving is not exactly what I’m working on, but its is an approximate representation and greatly simplified to the exact problem. I am willing to investigate all options.
I have an abstract class with a data value I want to override in a subsequent class.
The base abstract class
public abstract class Variable
{
public abstract long data;
}
I have a subclass
public class FloatVariable : Variable
{
public override float data;
}
However when using late dynamic binding I have trouble
Variable var = new FloatVariable();
var.data = 0.33f;
Causes an error that it “Cannot implicitly convert type ‘float’ to ‘long'”
Obviously I’m not doing it right, however if there is a way to override variables (and types) so that late dynamic binding will still allow it to compile, it would make my life infinity easier.
I found a solution that solves my problem that I could not resolve with generics/templates.
Create a new scalar class
Then create my base variable class
Then create your sub classes of your meta variables
Then using it works just fine with dynamic binding
Its not perfect with the lists, but it seems to work for how I intend to use it.