Solved

C# enum

Posted on 2011-03-17
5
387 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 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

20 Experts available now in Live!

Get 1:1 Help Now