Click here to Skip to main content
15,908,115 members
Home / Discussions / C#
   

C#

 
GeneralRe: Injection Pin
ALIJavany11-Oct-12 8:37
ALIJavany11-Oct-12 8:37 
AnswerRe: Injection Pin
Eddy Vluggen11-Oct-12 1:30
professionalEddy Vluggen11-Oct-12 1:30 
AnswerRe: Injection Pin
Abhinav S11-Oct-12 20:57
Abhinav S11-Oct-12 20:57 
AnswerRe: Injection Pin
KiranKumar Roy14-Oct-12 1:20
KiranKumar Roy14-Oct-12 1:20 
QuestionOpacity Pin
ALIJavany11-Oct-12 1:21
ALIJavany11-Oct-12 1:21 
AnswerRe: Opacity Pin
J4amieC11-Oct-12 1:30
J4amieC11-Oct-12 1:30 
AnswerRe: Opacity Pin
Eddy Vluggen11-Oct-12 1:31
professionalEddy Vluggen11-Oct-12 1:31 
GeneralRe: Opacity Pin
Sentenryu11-Oct-12 6:24
Sentenryu11-Oct-12 6:24 
GeneralRe: Opacity Pin
Eddy Vluggen11-Oct-12 10:02
professionalEddy Vluggen11-Oct-12 10:02 
GeneralRe: Opacity Pin
Sentenryu15-Oct-12 0:06
Sentenryu15-Oct-12 0:06 
GeneralRe: Opacity Pin
Pete O'Hanlon11-Oct-12 7:40
mvePete O'Hanlon11-Oct-12 7:40 
AnswerRe: Opacity Pin
Dave Kreskowiak11-Oct-12 6:37
mveDave Kreskowiak11-Oct-12 6:37 
QuestionFTP connection error 431 Pin
nitin_ion10-Oct-12 17:54
nitin_ion10-Oct-12 17:54 
SuggestionRe: FTP connection error 431 Pin
Shameel11-Oct-12 1:05
professionalShameel11-Oct-12 1:05 
QuestionC# progam call second C# program Pin
dcof10-Oct-12 16:04
dcof10-Oct-12 16:04 
AnswerRe: C# progam call second C# program Pin
Richard MacCutchan10-Oct-12 21:48
mveRichard MacCutchan10-Oct-12 21:48 
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 

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.