I have the following code:
bool a = false;
string b = "Anything";
string c = a + b;
The variable “a” type could vary. It could be an int, decimal, datetime or bool. This code is generated, compiled and run later on.
My issue is that C# is able to convert any type to string without explicit conversion.
I would like to throw a conversion exception on the 3rd line but for any type like:
“Cannot convert from Boolean to String”
Or if there is a way to stop C# from automatically converting types to string.