Skip to content

Instantly share code, notes, and snippets.

@pdelvo
Created August 17, 2017 00:46
Show Gist options
  • Save pdelvo/7c12773003a57b035c79842c46a762f2 to your computer and use it in GitHub Desktop.
Save pdelvo/7c12773003a57b035c79842c46a762f2 to your computer and use it in GitHub Desktop.
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