There is a predefined implicit conversion from byte to short, ushort, int, uint, long, ulong, float, double, or decimal.
You cannot implicitly convert nonliteral numeric types of larger storage size to byte. Consider, for example, the following two byte variables x and y:
byte x = 10, y = 20;
The following assignment statement will produce a compilation error, because the arithmetic expression on the right-hand side of the assignment operator evaluates to int by default.
byte z = x + y; // Error: conversion from int to byte
To fix this problem, use a cast:
byte z = (byte)(x + y); // OK: explicit conversion
It is possible though to use the following statements, where the destination variable has the same storage size or a larger storage size:
int x = 10, y = 20;
int m = x + y;
long n = x + y;
Also, there is no implicit conversion from floating-point types to byte. For example, the following statement generates a compiler error unless an explicit cast is used:
byte x = 3.0; // Error: no implicit conversion from double
byte y = (byte)3.0; // OK: explicit conversion
When calling overloaded methods, a cast must be used. Consider, for example, the following overloaded methods that use byte and int parameters:
public static void MyMethod(int i) {}
public static void MyMethod(byte b) {}
Using the byte cast guarantees that the correct type is called, for example:
MyMethod(5); // Calling the method with the int parameter
MyMethod((byte)5); // Calling the method with the byte parameter