In some cases, I need to cast right hand side expression to left hand side. While it looks/feels simple for basic data types, it requires long lines with duplication when flexible code is desired to be written.

Example:

int a = 7;
byte b;

b = cast( byte )a;


When I want to create a system where data types should match each other automatically, my code turns into this.

b = cast( typeof( b ) )a;


Alright, in my use cases, variable names "a" and "b" are long with module names mostly.

Is there any way to cast to type of left hand side variable the right side?

Reply via email to