Created
August 17, 2017 00:46
-
-
Save pdelvo/7c12773003a57b035c79842c46a762f2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace ConsoleApp2 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var t = new MyType() == true; | |
Foo(t); | |
} | |
static void Foo(bool b) | |
{ | |
Console.WriteLine("Boolean value: " + b); | |
} | |
static void Foo(MyType t) | |
{ | |
Console.WriteLine("MyType"); | |
} | |
class MyType | |
{ | |
public static implicit operator bool(MyType t) | |
{ | |
return true; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment