This error is "normal". The debugger does not seem to get the value that you enter as T = int , but simply as int (it is written on the debugger that it expects an int ), and then tries to convert your int to T Even if T is of type int , it cannot perform the conversion implicitly (usually you just need to specify your value to eliminate such errors), it can recompile your value on the fly with the same configuration to compile the code. And in this configuration, value is of type T = unknown , not T = int .
I think that changing values โโon the fly is not very similar to runtime. Because at runtime, T = int
(Someone who knows the compiler / debugger behavior better than I could explain in detail what is going on here.)
But, as in this method:
public void Try(int value) {
As a result, you will receive the same error message (and you will not be able to compile it).
Error CS0029 Unable to implicitly convert type 'int' to 'T'
But if you print this in your debugger as a value (for your method):
(T)(object)10
Or for the test method above (which you really should avoid) :
_value = (T)(object)value;
It works, the value changes. (If your value is not of type T )
You explicitly converted your int to T
Nothing is bad, it's just a standard error, not related to the general conversion error.
source share