-
Aug 20th, 2020, 12:33 AM
#1
Thread Starter
Member
How to Covert List<string> values to Enum?
How can i convert this??
List lstDays = new List { "Monday", "Tuesday ", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
Need Enum like
enum lstDays
{
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
Sunday
}
-
Aug 20th, 2020, 02:09 AM
#2
Re: How to Covert List<string> values to Enum?
I'm fairly certain that you have asked this question before and been told that it's nonsensical. If not, someone else asked the exact same question, which seems fairly suspicious. If you want an enumeration then declare an enumeration. There is no "conversion" to be done.
As I also think you were told on that other occasion, there seems no good reason to want either of those code snippets, given that the System.DayOfWeek enumeration already exists.
-
Aug 20th, 2020, 10:16 AM
#3
Re: How to Covert List<string> values to Enum?
Well, it wasn't asked here by the same person, but it certainly doesn't make sense.
An enum isn't a list, so there's no automatic conversion. It's seven items, though, at worst, so just create an enum by hand. You'll have to do so anyways, and you've already done so, which means you've basically answered your own question as a part of the question. Therefore, I assume you want something other than what you actually asked for.
My usual boring signature: Nothing
-
Aug 20th, 2020, 10:57 AM
#4
Re: How to Covert List<string> values to Enum?
Originally Posted by Shaggy Hiker
Well, it wasn't asked here by the same person
No, it was at a different forum and the user name was different but the wording was almost identical:
I try to Covert the List<> value to Enum but i'm Failed.
List<string> lstDays = new List<string> { "Monday", "Tuesday ", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
Need Enum like
Code:
enum lstDays
{
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
Sunday
}
Please can help?
so it's either the same person who is completely disregarding the advice already provided or it's someone else doing the same assignment and failing to provide a proper explanation of their requirements in the same way. Even if you think you need something like that, that need doesn't exist in a vacuum. You must think you need it for a reason but there was no explanation before and there's no explanation here now either.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|