Using c# defined enum in

Results 1 to 3 of 3

Thread: Using c# defined enum in

  1. #1
    Join Date
    Dec 1969

    Default Using c# defined enum in

    I have a existing code written by someone else in C#. It contains numerous enums. I am writting a new program which calls code from this old project and needs to check the enum values.<BR><BR>In my code I have a reference set up for the c# project and can see the enums through intellisense, but as soon as I try to check a value against an enum, visual studio errors out by either not compiling the project or in debug mode, just skipping the lines of code which access the enum from the C# project.<BR><BR>Any ideas on how to do this? I could duplicate the enums in the vb project, but don&#039;t want to b/c of having to make changes in two places.<BR><BR>Code is like this:<BR><BR>C#<BR>public enum ReturnCodes { success =0, duplicate=-100 };<BR><BR>vb code<BR><BR>&#039;THis line is skipped somehow when it is run<BR>response.write (ReturnCodes.sucess)<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Using c# defined enum in

    I&#039;m haven&#039;t done any VB with .Net, but I know in c# you would need to cast the enum to get it&#039;s underlying value like this:<BR><BR>int underlyingValue = (int)ReturnCodes.sucess;<BR>Response.Write(underly ingValue.ToString());<BR><BR>I presume the same is true of VB.Net but am not sure of the syntax.

  3. #3
    Join Date
    Dec 1969

    Default Works perfectly for me...

    Did you forget to import the C# namespace, perhaps? And/or forget to add a reference to the C# project/DLL?<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts