This might be a bit of an anti-pattern, but it is possible for a property on a C# class to accept multiple values?
For example, say I have an Public int property and I always want it to return an int, but I would like to be able to have the property set by assigning a decimal, an integer or some other data type. So my question is if it possible for properties to accept multiple values?
I think what you mean to ask is: How does implicit and explicit casting work for
intanddecimal?You are asking about implicit casting which automatically coverts one object to another defined type. You will not be able to do this for an
intanddecimalbecause they are already defined in the framework and you are not able to reduce the scope of thedecimalby casting it to anint. But if you were using that as an example for actual objects that you created you can use the implicit link above, to learn more about how this works and how to implement it.But you can always use the convert method to convert them to the right type;