What's wrong with this expression? Cannot implicitly convert type 'int' to 'byte'

后端 未结 5 1213
后悔当初
后悔当初 2020-12-19 02:29

I am getting the error \"Cannot implicitly convert type \'int\' to \'byte\'. An explicit conversion exists (are you missing a cast?)\". Doesn\'t byte + byte = byte

5条回答
  •  情话喂你
    2020-12-19 02:33

    Doesn't byte + byte = byte?

    Nope, because it may overflow (> 255), that's why this operation returns an Int32. You could cast the result back to byte at your own risk.

提交回复
热议问题