[Last Call] Learn how to a build a cloud-first strategyRegister Now

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

How to show days using enum

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
mousemat24
Asked:
mousemat24
  • 2
1 Solution
 
AndyAinscowCommented:
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
 
AndyAinscowCommented:
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!

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