I have a function that returns Class1Model
Class1Model model = GetClass1Model();
I also have a Class1ViewModel
that inherits from Class1Model
to which I have added some get only properties for formatting in a view.
public class Class1ViewModel : Class1Model
{
public string MyFormattedProperty => $"{base.Height:###.00} x {base.Width:###.00}"
}
So I was hoping that I could do this:
Class1Model model = GetClass1Model();
var viewModel = model as Class1ViewModel;
But this doesn't work
So how would this usually be done?