Main Site Documentation

0.11 Bug: String conversion of enum type


#1

I ran into another issue today… The framework seems unable to to convert an Enum type to a string. I tried several variations, including:

var output = value.ToString();

compressorState = value;
var output = compressorState.ToString();

compressorState = value;
var output = ((CState)compressorState).ToString();

All threw the same error seen in the screenshot.


#2

That’s a deliberate known issue (sixth paragraph) in the current and previous two releases. The workaround is to cast to an int (or whatever the underlying type is).

var output = ((int)compressorState).ToString();

ToString never supported returning the name of the enum member as a string as it should anyway, so casting to an int doesn’t currently lose any functionality.


#3

Thanks John!