?
Solved

XML Enums

Posted on 2006-07-12
2
Medium Priority
?
726 Views
Last Modified: 2008-01-09
i have a class which contains xml enums, I am not able to use integers or any special characters

Example :
I cannot use like <XmlEnum(Name:="CHG")> 1 ...i will get a error.... as end of enum expected ....I have to use ( _ ) Underscore infront of 1 inorder to use 1 but when i bind it to a dropdownlist the display text will be _1. How to avoid the _1 inside dropdownlist. I have avoided through the code but how to achieve this using only XMLEnum.

This class was created  using a xmlschema from xsdobjectgen.exe .

I have to use like the below code i have written  


Namespace Test.Web.Enums

    Public Module Declarations
        Public Const SchemaVersion As String = ""
    End Module
<Serializable()> _
    Public Enum PaymentType
        <XmlEnum(Name:="CHG")> _1  ---------------> (I want to avoid _1)
        <XmlEnum(Name:="COD")> COD
        <XmlEnum(Name:="PPD")> PPD
    End Enum
0
Comment
Question by:Chandan_Gowda
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
jkievlan earned 100 total points
ID: 17111047
Like this:

<Serializable()> _
Public Enum PaymentType
  <XmlEnum(Name:="CHG")> CHG = 1
  <XmlEnum(Name:="COD")> COD
  <XmlEnum(Name:="PPD")> PPD
End Enum

The expression you enter after <XmlEnum()> is the name of the enumeration member, so of course you can't use 1 as that's an illegal variable name.  _1 will work but that's not what you want.  So the solution, I would think, is to use the name of the XmlEnum as the member name, and set its value to 1.  Is there any reason this wouldn't work for you?
0

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question