Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 435
  • Last Modified:

C# enum

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
vivekj2004
Asked:
vivekj2004
1 Solution
 
wdosanjosCommented:
What's CrcliEligibilityResponseDTO.CLIAppDecPen's type?
0
 
morguloCommented:
You can't use this same name for property and inner type. Change name od property or enum.
0
 
Miguel OzSoftware EngineerCommented:
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
 
KiasChaos83Commented:
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
 
vivekj2004Author Commented:
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now