Solved

How to show days using enum

Posted on 2014-04-03
2
292 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 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

Technology Partners: 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

Suggested Solutions

Title # Comments Views Activity
disable data migrations in visual studio 2017 4 51
IDE for Python 5 74
Updating a single record in forEach using C#/Entity 7 26
asp.net repeater 2 18
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 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