Could you send me an example of your Size that behaves this way. It may be implementing an interface that I'm not familiary with. What you describe sounds like implicit conversion. Update the Licence class to the following:
Then try it out with someting like:Code:namespace WindowsFormsTest { public class Licence { private bool driving = false; private bool aviation = false; public bool Driving { get { return this.driving; } } public bool Aviation { get { return this.aviation; } } public static implicit operator bool(Licence rhs) { //Return true only if both licences are held return rhs.Aviation && rhs.Driving; } } }
However, be very careful with implicit conversion, it's better to do explicit conversion because it leads to fewer bugs especially runtime errors that can be a bit of a nightmare to solve.Code:Licence lic = new Licence(); bool result = lic; bool result2 = lic.Aviation;




Reply With Quote
