Solved

C# enum

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
New to SOAP and need some direction 10 77
System.Speech 2 26
User Authentication using Digital Certificate 2 44
Call windows 10 virtual keyboard from windows forms app 2 32
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

786 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