Solved

How to show days using enum

Posted on 2014-04-03
2
278 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
  • 2
2 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 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

12 Experts available now in Live!

Get 1:1 Help Now