Click here to Skip to main content
15,881,812 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# progam call second C# program Pin
Pete O'Hanlon10-Oct-12 22:21
mvePete O'Hanlon10-Oct-12 22:21 
QuestionCitrix Session Pin
Arun Philip Reynolds10-Oct-12 8:30
Arun Philip Reynolds10-Oct-12 8:30 
AnswerRe: Citrix Session Pin
Eddy Vluggen10-Oct-12 23:57
professionalEddy Vluggen10-Oct-12 23:57 
QuestionEnumerate through the values of a enum Pin
Sentenryu10-Oct-12 7:38
Sentenryu10-Oct-12 7:38 
AnswerRe: Enumerate through the values of a enum Pin
Dave Kreskowiak10-Oct-12 8:01
mveDave Kreskowiak10-Oct-12 8:01 
GeneralRe: Enumerate through the values of a enum Pin
Sentenryu10-Oct-12 8:18
Sentenryu10-Oct-12 8:18 
GeneralRe: Enumerate through the values of a enum Pin
Dave Kreskowiak10-Oct-12 8:29
mveDave Kreskowiak10-Oct-12 8:29 
GeneralRe: Enumerate through the values of a enum Pin
Sentenryu10-Oct-12 8:55
Sentenryu10-Oct-12 8:55 
First of all, i forgot to say thanks for your answer, so Thanks!

In the case i'm just getting a IEnumerable<SelectListItem> with the values of a enum to display as radiobuttons, the actual code (with the excuse of having names in portuguese) is this:

C#
ViewBag.ApetiteOptions = ((IEnumerable<int>)Enum.GetValues(typeof(Apetite))).Select(x => new SelectListItem() {
 Text = ((Apetite)x).ToString(), 
 Value = x.ToString()
});


Visual Studio (2012) gives me an error when I try to use the select method directly on the return type of the
Enum.GetValues(), I guess it's because this method returns a instace of Array(the base class), and not a instance of int[].

int[] implements IEnumerable<int>, while Array implements IEnumerable, the Select method Expects IEnumerable<TSource>...

while writting this post, i updated this bit of code to this:

C#
ViewBag.ApetiteOptions = Enum.GetValues(typeof(Apetite)).OfType<int>().Select(x => new SelectListItem() {
     Text = ((Apetite)x).ToString(),
     Value = x.ToString()
 });


I'm a little bit more happy now Smile | :)
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)

GeneralRe: Enumerate through the values of a enum Pin
Mr. Tapan Kumar10-Oct-12 9:47
Mr. Tapan Kumar10-Oct-12 9:47 
GeneralRe: Enumerate through the values of a enum Pin
J4amieC10-Oct-12 21:26
J4amieC10-Oct-12 21:26 
GeneralRe: Enumerate through the values of a enum Pin
J4amieC10-Oct-12 21:25
J4amieC10-Oct-12 21:25 
GeneralRe: Enumerate through the values of a enum Pin
Dave Kreskowiak10-Oct-12 23:52
mveDave Kreskowiak10-Oct-12 23:52 
AnswerRe: Enumerate through the values of a enum Pin
J4amieC10-Oct-12 21:20
J4amieC10-Oct-12 21:20 
GeneralRe: Enumerate through the values of a enum Pin
Sentenryu11-Oct-12 0:07
Sentenryu11-Oct-12 0:07 
QuestionProviderUserKey error Pin
saiprakash031510-Oct-12 6:15
saiprakash031510-Oct-12 6:15 
AnswerRe: ProviderUserKey error Pin
OriginalGriff10-Oct-12 8:36
mveOriginalGriff10-Oct-12 8:36 
GeneralRe: ProviderUserKey error Pin
saiprakash031510-Oct-12 14:14
saiprakash031510-Oct-12 14:14 
QuestionC# Pin
Jaleel Ahmed10-Oct-12 6:11
Jaleel Ahmed10-Oct-12 6:11 
AnswerRe: C# Pin
Paul Conrad10-Oct-12 7:31
professionalPaul Conrad10-Oct-12 7:31 
AnswerRe: C# Pin
Abhinav S10-Oct-12 16:08
Abhinav S10-Oct-12 16:08 
AnswerRe: C# Pin
KiranKumar Roy14-Oct-12 1:36
KiranKumar Roy14-Oct-12 1:36 
QuestionProgressive tax calculator in C# Pin
cyberhopper10-Oct-12 2:26
professionalcyberhopper10-Oct-12 2:26 
AnswerRe: Progressive tax calculator in C# Pin
Pete O'Hanlon10-Oct-12 3:05
mvePete O'Hanlon10-Oct-12 3:05 
GeneralRe: Progressive tax calculator in C# Pin
Paul Conrad10-Oct-12 7:33
professionalPaul Conrad10-Oct-12 7:33 
QuestionC# obtain return code from a proxy Pin
dcof10-Oct-12 2:23
dcof10-Oct-12 2:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.