Results 1 to 5 of 5

Thread: [RESOLVED] XOR ^ operator not compiling...

Threaded View

  1. #1

    Thread Starter
    Frenzied Member Phill64's Avatar
    Join Date
    Jul 2005
    Location
    Queensland, Australia
    Posts
    1,201

    Resolved [RESOLVED] XOR ^ operator not compiling...

    Hi all,

    this tiny little problem is frustrating the hell out of me. I've done this sort of operation many times in VB.NET with XOR without a problem, I believe the ^ operator in C# is XOR so I can't see why this is a problem(except that ^ is also considered a logical operator), but check it out. I simply want to XOR 2 bytes, and the compiler tells me that I cannot convert byte to int and that im missing a cast... how is this possible when i'm dealing only with bytes and the result of a XOR'd byte should be a byte.

    code snippet
    Code:
    for(int i=0;i<bts.Length; i++)
      bts[i] = bts[i] ^ bts2[i];
    compiler error
    Code:
    Cannot implicitly convert type 'int' to 'byte'. An explicit conversion exists (are you missing a cast?) (CS0266) - .cs:80,14
    which points to the "= bts[i]" part
    Last edited by Phill64; Nov 26th, 2009 at 10:21 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width