c# - Error 1 Cannot implicitly convert type 'int' to 'uint'. An explicit conversion exists (are you missing a cast?) -


i'm kinda new c# coding , have dealed lately problem , want ask help. have piece of code link below.

http://pastebin.com/5jqe5tqs

my problem @ finish line:

uint num = ((string_0[0] | (string_0[1] << 8)) |             (string_0[2] << 0x10)) | (string_0[3] << 0x18); 

where got error:

cannot implicitly convert type 'int' 'uint'. explicit conversion exists (are missing cast?)

from know , read see problem came value asigned int big int values. little experience not know variable value not in right format. more advised expert can me please fix code?

the result of expression

((string_0[0] | (string_0[1] << 8)) | (string_0[2] << 0x10)) | (string_0[3] << 0x18) 

is int. putting uint. make num int, or cast expression uint.

what happens is, when derefence part of string using [] operator, fetch char. because shift operators char do not exist, value upgraded implicitly int (upgrading no problem, because there no risk of loss of accuracy). part (as others well):

(string_0[1] << 8) 

returns int.


Comments