I'm trying make a library to iot core on c# based on arduino library (http://blog.electrodragon.com/rc522-write-a-card-demo-code/) but i don't understand what is:
if (!(temp & 0x03))
or
while ((i!=0) && !(n&0x01) && !(n&waitIRq))
It's required boolean values but those are bytes! How i can convert this?
If anyone know a library already made, please let me know. Thank you.
In C any non-zero expression is implicitly true, and zero is false. In C# you need to do an explicit comparison:
if ((temp & 0x03) == 0)
and
while ((i!=0) && (n&0x01)==0 && (n&waitIRq)==0)
Alternatively, you can use the .NET's Boolean structure:
bool isTempAppropriate = (temp & 0x03) == 0;
if(isTempAppropriate) { ... }
Note that bool is just syntactic sugar for System.Boolean, and that you could have used the var keyword instead of bool.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With