c# - How to use Enum.Parse in windows phone 7 in a proper way? -
i want parse data enum i'm stumbling upon problem. namely, when try code:
languages lang = enum.parse(typeof(languages), languagechooser.selecteditem, true);
i info has invalid arguments. think there problem first 1 in every tutorial i've found first arg looks this.
or advice?
the issue second parameter, not first. languagechooser.selecteditem
more returns instance of object
rather string
. i'm not sure type you're using languagechooser
, it's hard proper fix is. of following:
// languagechooser bound ienumerable<string> var lang = enum.parse(typeof(languages), languagechooser.selecteditem string, true); // languagechooser bound proper tostring() implementation var lang = enum.parse(typeof(languages), languagechooser.selecteditem.tostring(), true); // languagechooser ienumerable<someothertype> someothertype has property // indicates language var obj = languagechooser.selecteditem someothertype; var lang = enum.parse(typeof(languages), obj.somelanguageproperty, true);
Comments
Post a Comment