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

  • SEARCH
  • Home
  • 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 8567565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:54:43+00:00 2026-06-11T17:54:43+00:00

Currently I have 4 permissions in my website Edit Delete Add View Everyone gets

  • 0

Currently I have 4 permissions in my website

Edit
Delete
Add
View

Everyone gets view permissions when someone subscribes to someone else.

Currently in I store each as a column in my database as a bit value.

I am thinking maybe I should use enum with flags but I have some questions.

  1. The user will be able to choose the users permissions(eveyone gets view you cannot take that away). Right now it is easy as I use a checkbox and then save the bool value to the db.

My questions is what is the best way to convert checkboxes to the enum type? So if they choose add permission I can map that to the right enum type.

Wondering if there is a better way then

PermissionTypes t;
if(add == true)
{
   t = PermissionTypes.Add
}

if(edit == true)
{
   t += PermissionTypes.Edit // not sure if you even can do this.
}

I know with enum flags you can use the pipe and do something like this

PermissionTypes t = PermissionTypes.Add | PermissionTypes.Edit

I am wondering is it good practice to have another type in my enum like

AddEdit = Add | Edit

I am thinking that can result in many combinations(imagine if I had like 10 permissions or something like that).

  • 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-06-11T17:54:44+00:00Added an answer on June 11, 2026 at 5:54 pm

    Enums are simply integers values. By settings your enum values to different power of 2, you can easily have any combination you need:

    enum ePermissions
    {
    
       None = 0,
       View = 1,
       Edit = 2,
       Delete = 4,
       Add = 8,
       All = 15
    }
    
    ePermissions t;
    t = (ePermissions)((add?ePermissions.Add:ePermissions.None) | (delete?ePermissions.Delete:ePermissions.None) | ...);
    

    if you want to know if some user has the Add permission just do as follow:

    canAdd = (currentPermission & ePermissions.Add) != 0;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a Web Application which is using it's own Permissions table which
Currently have a drop down menu that is activated on a hover (from display:none
Currently have password protection on my main and sub directories, however I'd like to
I currently have a XSLT 2.0 Stylesheet that I am trying to remove empty
I currently have a table of concentrations, which are linked to a table of
I currently have one project that currently contains multiple packages. These packages make up
I currently have 4 tables. Product, Category, SubCategory, ProductSubCategory. Category has a OneToMany SubCategory
I currently have a form with inputs and name attributes. I'm able to get
I currently have a deployed app (fortworth.herokuapp.com) that I am attempting to sort movies
I currently have a MySQL table like: id | friend 1 | 2 1

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.