C#: Object having two constructors: how to limit which properties are set together?
- by Dr. Zim
Say you have a Price object that accepts either an (int quantity, decimal price) or a string containing "4/$3.99". Is there a way to limit which properties can be set together? Feel free to correct me in my logic below.
The Test: A and B are equal to each other, but the C example should not be allowed. Thus the question How to enforce that all…