Getting a - "Cannot implicitly convert type 'int' to 'byte'" error - Help!
-
Hi everybody, this is my first post so please bear with me. Ok here's what I am trying to do, and for the love of me I can't 'see' an implicit conversion happenning, so why the hell is the compiler whining??? here is a class skeleton, similar to what I have public class X { protected void ThisIsKillingMe(byte[] oldABC) { byte[] newABC = new byte[100]; // line below reports an implicit complier error newABC[i] = oldABC[p] ^ xyz[q]; } private static readonly byte[] xyz = {0x12, 0x5F, ....}; } Thanks for any and all help.
-
Hi everybody, this is my first post so please bear with me. Ok here's what I am trying to do, and for the love of me I can't 'see' an implicit conversion happenning, so why the hell is the compiler whining??? here is a class skeleton, similar to what I have public class X { protected void ThisIsKillingMe(byte[] oldABC) { byte[] newABC = new byte[100]; // line below reports an implicit complier error newABC[i] = oldABC[p] ^ xyz[q]; } private static readonly byte[] xyz = {0x12, 0x5F, ....}; } Thanks for any and all help.
I'm presuming that when you perform the ^ on the two byte data types (which are Integers, btw), the compiler performs an implicit conversion to Integer. You are then trying to assign the resultant integer value to the newly declared byte array. You probably need to cast the result back to byte. Or I could be totally full of it :-O
-
I'm presuming that when you perform the ^ on the two byte data types (which are Integers, btw), the compiler performs an implicit conversion to Integer. You are then trying to assign the resultant integer value to the newly declared byte array. You probably need to cast the result back to byte. Or I could be totally full of it :-O
-
Hi everybody, this is my first post so please bear with me. Ok here's what I am trying to do, and for the love of me I can't 'see' an implicit conversion happenning, so why the hell is the compiler whining??? here is a class skeleton, similar to what I have public class X { protected void ThisIsKillingMe(byte[] oldABC) { byte[] newABC = new byte[100]; // line below reports an implicit complier error newABC[i] = oldABC[p] ^ xyz[q]; } private static readonly byte[] xyz = {0x12, 0x5F, ....}; } Thanks for any and all help.
newABC[i] = (byte)(oldABC[p] ^ xyz[q]);
top secret xacc-ide 0.0.1