using System;
[Flags]
internal enum Bordes
{
Izquierdo = 1,
Derecho = 2,
Superior = 4,
Inferior = 8,
Todos = Derecho | Superior | Inferior | Izquierdo
}
public class Test
{
public static void Main()
{
for (int i = 0; i <= 16; ++i)
{
Bordes borde = (Bordes) i;
Console.WriteLine( "¿El valor `{0}` está definido?: {1}", i, ValorBanderaDefinido(borde));
}
}
static bool ValorBanderaDefinido(Bordes e)
{
return !(Bordes.Todos & e) != 0;
}
}
dXNpbmcgU3lzdGVtOwoKW0ZsYWdzXQppbnRlcm5hbCBlbnVtIEJvcmRlcwp7CglJenF1aWVyZG8gPSAxLAoJRGVyZWNobyA9IDIsCglTdXBlcmlvciA9IDQsCglJbmZlcmlvciA9IDgsCglUb2RvcyA9IERlcmVjaG8gfCBTdXBlcmlvciB8IEluZmVyaW9yIHwgSXpxdWllcmRvCn0KCnB1YmxpYyBjbGFzcyBUZXN0CnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBNYWluKCkKCXsKCQlmb3IgKGludCBpID0gMDsgaSA8PSAxNjsgKytpKQoJCXsKCQkJQm9yZGVzIGJvcmRlID0gKEJvcmRlcykgaTsKCQkJCgkJCUNvbnNvbGUuV3JpdGVMaW5lKCAiwr9FbCB2YWxvciBgezB9YCBlc3TDoSBkZWZpbmlkbz86IHsxfSIsIGksIFZhbG9yQmFuZGVyYURlZmluaWRvKGJvcmRlKSk7CgkJfQoJfQoJCglzdGF0aWMgYm9vbCBWYWxvckJhbmRlcmFEZWZpbmlkbyhCb3JkZXMgZSkKCXsKCQlyZXR1cm4gIShCb3JkZXMuVG9kb3MgJiBlKSAhPSAwOwoJfQp9
prog.cs(27,24): error CS0023: The `!' operator cannot be applied to operand of type `Bordes'
Compilation failed: 1 error(s), 0 warnings