Created
October 21, 2016 07:32
-
-
Save ForNeVeR/d48a2c47306cdd644f899499bbaf79d7 to your computer and use it in GitHub Desktop.
Bool not equal to true neither to false.
This file contains 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; | |
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