Solved

C# enum

Posted on 2011-03-17
5
413 Views
Last Modified: 2012-05-11
I want to use enums like this here, but cannot. Can somebody tell me what to do?

 CrcliEligibilityResponseDTO cliresp = new CrcliEligibilityResponseDTO();
if (a=1)
cliresp.CLIAppDecPen = cliresp.CLIAppDecPen.A;
if (a=2)
cliresp.CLIAppDecPen = cliresp.CLIAppDecPen.D;
if (a=3)
cliresp.CLIAppDecPen = cliresp.CLIAppDecPen.P;
0
Comment
Question by:vivekj2004
5 Comments
 
LVL 23

Expert Comment

by:wdosanjos
ID: 35160943
What's CrcliEligibilityResponseDTO.CLIAppDecPen's type?
0
 
LVL 5

Expert Comment

by:morgulo
ID: 35160993
You can't use this same name for property and inner type. Change name od property or enum.
0
 
LVL 35

Accepted Solution

by:
Miguel Oz earned 500 total points
ID: 35161114
Check:
http://www.csharp-station.com/Tutorials/lesson17.aspx

Can you post the code that defines your enum? (In order to use the integer values you need to set the values in your enum , e.g:
public enum Volume
{
   Low = 1,
   Medium = 2,
   High = 3
}
usage:
int a= 2;//or whatever value
Volume test = (Volume)a;

0
 
LVL 5

Expert Comment

by:KiasChaos83
ID: 35162241
You're almost there, this should work (assumping the enum name is CLIAppDecPen):


CrcliEligibilityResponseDTO cliresp = new CrcliEligibilityResponseDTO();
if (a=1)
cliresp.CLIAppDecPen = CLIAppDecPen.A;
if (a=2)
cliresp.CLIAppDecPen = CLIAppDecPen.D;
if (a=3)
cliresp.CLIAppDecPen = CLIAppDecPen.P;

Open in new window

0
 

Author Closing Comment

by:vivekj2004
ID: 35301255
I was forced to select a solution, that's why I selected this. Otherwose I don't want to give points to any solution. None of the solution was complete.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
application restarter  - for an exe that hangs 9 31
transaction in asp.net, sql server 6 43
Sort GridView by ID Descending 1 18
RegEx with optional part 4 42
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

820 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