c# - Specified cast is not valid. enum -



c# - Specified cast is not valid. enum -

whats wrong code, seek enum.parse didnt work.

public enum rolenames { administrator, [description("personnel security")] prsonalsecurity, } foreach (rolenames rolename in arroles) //<<<error { if (iscurrentuserinrole(rolename)) { homecoming true; } }

arroles arraylist of rolenames, passing parameters.

can post rest of code next illustration work fine:

public enum rolenames { administrator, [description("personnel security")] personalsecurity } rolenames[] testenumarray = { rolenames.administrator, rolenames.personalsecurity }; foreach (rolenames en in testenumarray) { // }

based on error message, arroles must not array of rolenames since cast failing.

if want iterate on enum definition can utilize next code:

foreach (rolenames type in enum.getvalues(typeof(rolenames)) { // }

post exact code.

c# asp.net

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -