Microsoft KB Archive/814902

= BUG: You receive a &quot;CS0030&quot; compilation error code while explicitly converting enum type to char type =

Article ID: 814902

Article Last Modified on 1/16/2006

-

APPLIES TO


 * Microsoft Visual C# .NET 2002 Standard Edition

-



SYMPTOMS
If you explicitly convert enum type to char type, you may receive the following compilation error message (CS0030):

Cannot convert type '' to 'char'



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



WORKAROUND
To work around this problem, first explicitly convert enum type to int, and then explicitly convert int type to char type. You can do this with the following code: char  ch = (char) (int) TestEnum.Val;



Steps to Reproduce the Behavior
 Click Start, point to All Programs, point to Microsoft Visual Studio .NET, point to Visual Studio .NET Tools, and then click Visual Studio .NET Command Prompt. This automatically sets the environment to use Visual Studio .NET.  Paste the following code in Notepad, or another text editor: using System; namespace TestApplication {   enum TestEnum {       Val };   class Class1 {       [STAThread] static void Main(string[] args) {           char   ch = (char) TestEnum.Val; }   } }  Save the file as TestApplication.cs .  At the command prompt, type the following command to compile the code. csc TestApplication.cs 

You may receive the compilation error message that is described in the &quot;Symptoms&quot; section of this article.



Keywords: kbbug kbprogramming kbcompiler KB814902

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.