Solved

XML Enums

Posted on 2006-07-12
2
717 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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:
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now