Solved

XML Enums

Posted on 2006-07-12
2
722 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
2 Comments
 
LVL 1

Accepted Solution

by:
jkievlan earned 50 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Edit a page at wix.com 8 67
manage footer size 4 72
Eloquent ORM manual paginator defaults to simple 2 31
Dreamweaver code color same as CS6 or CS2015 2 10
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

856 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