?
Solved

How to show days using enum

Posted on 2014-04-03
2
Medium Priority
?
303 Views
Last Modified: 2014-04-03
Hi

I have the following prop:

public int Day { get; set; }

the data in SQL will be an int as well, but what i want to do is show the string

Sat, Sun, Mon, Tue, Wed, Thu, Fri

Sat being 1

How does one do this using enums?

thanks
0
Comment
Question by:mousemat24
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 2000 total points
ID: 39974454
With a case statement.
String s;
            switch (yourday)
            {
                case Sat: s = "Sat"; break;
                case Sun: s = "Sun"; break;
and so on where Sat, Sun are the enumerated values and yourday is the variable containing the day you want displayed
            }
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 39974456
ps.  If you were doing this in multiple places you could build a function that takes the enum variable and returns a string.
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

771 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