Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1103847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:23:57+00:00 2026-05-17T01:23:57+00:00

whats wrong with this code, i try also Enum.Parse but didnt work. public enum

  • 0

whats wrong with this code, i try also Enum.Parse but didnt work.

public enum RoleNames  
{
    Administrator,
    [Description("Personnel Security")]
    PrsonalSecurity,
}

foreach (RoleNames roleName in arRoles) //<<<error
{
        if (IsCurrentUserInRole(roleName)) { return true; }
}

arRoles is ArrayList of RoleNames, which is passing as a parameters.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:23:57+00:00Added an answer on May 17, 2026 at 1:23 am

    Can you post the rest of your code as the following example would work just fine:

    public enum RoleNames   
    { 
        Administrator, 
        [Description("Personnel Security")] 
        PersonalSecurity
    } 
    
    RoleNames[] testEnumArray =
        { RoleNames.Administrator, RoleNames.PersonalSecurity };
    foreach (RoleNames en in testEnumArray)
    {
        // do something
    }
    

    Based on your error message, arRoles must not be an array of RoleNames since the cast is failing.

    If you want to iterate over your enum definition you can use the following code:

    foreach (RoleNames type in Enum.GetValues(typeof(RoleNames)) 
    {   
        // do something
    } 
    

    Post your exact code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is small code. But I couldn't find whats wrong with it. In my
Whats wrong with this code? -(void) drawRect:(CGRect) rect { CGContextRef c = UIGraphicsGetCurrentContext(); if
Can someone please tell me whats wrong with this code. I'm not getting complete
Can anyone help me figure out whats wrong with this piece of xaml code?
What's wrong with this code... I am trying to parse pdf files and extract
what's wrong with this code in Google Chrome r = webkitIndexedDB.open(db_name,1); r.onsuccess = success_callback;
What's wrong with this code?: SolverContext sc = SolverContext.GetContext(); Model m = sc.CreateModel(); m.AddDecision(new
Can anyone tell me what's wrong with this code? class Dataset < ActiveRecord::Base has_many
Can anyone tell me what's wrong with this code? It's giving me an error
I have no idea what's wrong with this code: onupgradeneeded = function(){ z =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.