I have a method with this signature:
protected bool MyMethod (ref IMyInterface model) {
// stuff and things
}
I have a model that I'm passing in from this class:
public class MyClass: IMyInterface {
// class stuff and things
}
I'm trying to pass my model into the method like so:
var model = new MyClass():
MyMethod(ref model);
However, I get an error about the type not matching the parameter type. If I don't pass by reference, it works fine. Or, if I cast it and pass it like so, it works fine.
var tempModel = (IMyInterface)model;
MyMethod(ref tempModel);
I'd rather avoid a cast if it's not necessary, but I can't pass without it. I thought if the class implemented the interface, I could pass the model. Is it just not a thing I can do by reference or am I missing something?