I’m trying to create a substitute for kind of property, that accepts multiple types as inputs/outputs.
Here is some pseudo code of one ugly solution:
Basically i have piece of data and i need to be able assign multiple types to it, and react accordingly. I have pieces of data that i operate with, and i need efficient way to manage loading them from file names when needed, while maintaining the same code, if I’m manipulating with data, that’s already loaded.
This would be awesome:
SomeDataClass data1 = new SomeDataClass();
SomeDataClass data2 = new SomeDataClass();
data1.Data = "somefile.dat";
data2.Data = data1.Data;
while SomeDataClass.Data is not type of string.
You can do much of that with an implicit conversion operator, i.e.
However! Frankly, I would consider it more desirable to just make the operation explicit: