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 8100033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:37:33+00:00 2026-06-05T22:37:33+00:00

I am testing an example snippet that I found as an answer on another

  • 0

I am testing an example snippet that I found as an answer on another Question

However the compiler is spitting out this “Operator && cannot be applied to operands of type long and bool”.
Why does it do this? As I read the code, it says “If mask and permission are greater than 0 return success bool”

Am I reading this wrong?

(Also, no one called it out as a bad example so I expected it to work. Not that I am a copy-paste coder)

bool CheckMask( long Mask, long TestPermission ) {
    return Mask && TestPermission > 0;
}

long mask = 4611686844973976575;

const long MASK_ViewListItems = 0x0000000000000001;
bool HasPermission_ViewListItems = CheckMask(mask, MASK_ViewListItems);
// HasPermission_ViewListItems is true

const long MASK_UseClientIntegration = 0x0000001000000000;
bool HasPermission_UseClientIntegration = CheckMask(mask, MASK_UseClientIntegration);
// HasPermission_UseClientIntegration is false

There are an awful lot of similar questions on StackOverflow and I’ve clicked through most of them, there’s a big list to my right as I type. None have applied to my situation, at least I was able to see the relation between the answers and my problem.

  • 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-05T22:37:35+00:00Added an answer on June 5, 2026 at 10:37 pm

    You’re using && (conditional AND, only valid for bool operands) instead of & (bitwise AND, valid for bool operands or integer operands) – I suspect you want the latter, and you should also use brackets due to precedence rules. I’d change the parameter names to follow .NET naming conventions, too – and make it static as it doesn’t rely on any state:

    static bool CheckMask(long mask, long testPermission)
    {
        return (mask & testPermission) > 0;
    }
    

    You might also want to change to using an enum instead of long:

    [Flags]
    public enum Permissions
    {
        ViewListItems = 1 << 0,
        ...
        UseClientIntegration = 1 << 9
    }
    
    static bool CheckMask(Permissions mask, Permissions testPermission)
    {
        return (mask & testPermission) != 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am testing perl script using this example found on the forum. I took
I'm looking for a good example project/tutorial that show the Kiwi testing framework in
How can I display HTML text in textview? For example, string &lt;h1&gt;Krupal testing &lt;span
How would it be possible to find out if a string for example testing
( This question , though similar, didn't really answer my question.) I've had problems
I am using THIS article and example for testing my gps. And first of
I am testing example at this url : http://trirand.com/blog/jqgrid/jqgrid.html . Right now Detail Grid
I am testing a simple producer/ consumer example in android this is what i'm
I'm testing MongoDB and here is a bit of example that took me by
I have a webpage for example www.testing.example.com/home , now if someone manually add script

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.