You can overload operator true and false i looked at examples and found this http://msdn.microsoft.com/en-us/library/aa691312%28v=vs.71%29.aspx
I completely dont understand how they work. I know if i write if(obj) and true returns true then the if is executed. It doesnt matter what false returns. However how does false work? in that doc it is suggected that the && operator uses it. I wrote the code below. I dont know how to get && to compile. || gives me a compile error too. How do i get false to be called? and how do i get the && and || to work?
var ts= new MyTimeSpan();// ts += ts;
if (ts){ Console.WriteLine("Is true"); }
else { Console.WriteLine("not true"); }
//Console.WriteLine(ts && ts ? "Y" : "N");
class MyTimeSpan
{
public static MyTimeSpan operator +(MyTimeSpan t, MyTimeSpan t2) { return new MyTimeSpan(); }
public static bool operator true(MyTimeSpan t) { return true; }
public static bool operator false(MyTimeSpan t) { return false; }
}