Skip to content

Instantly share code, notes, and snippets.

@ForNeVeR
Created October 21, 2016 07:32
Show Gist options
  • Save ForNeVeR/d48a2c47306cdd644f899499bbaf79d7 to your computer and use it in GitHub Desktop.
Save ForNeVeR/d48a2c47306cdd644f899499bbaf79d7 to your computer and use it in GitHub Desktop.
Bool not equal to true neither to false.
using System;
using System.Runtime.InteropServices;
namespace ConsoleApplication2
{
[StructLayout(LayoutKind.Explicit)]
internal struct Barbeque
{
[FieldOffset(0)] public int Barbe;
[FieldOffset(0)] public bool Que;
}
class Program
{
static void Main(string[] args)
{
var barbeque = new Barbeque { Barbe = 1001 };
var t = true;
var f = false;
if (barbeque.Que == t) // nope
{
Console.WriteLine("Barbeque is true");
}
else if (barbeque.Que == f) // nope
{
Console.WriteLine("Barbeque aint true");
}
else
{
Console.WriteLine("WTF"); // => WTF
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment