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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:07:30+00:00 2026-05-10T22:07:30+00:00

Why is operator ‘&’ defined for bool?, and operator ‘&&’ is not? How exactly

  • 0
  1. Why is operator ‘&’ defined for bool?, and operator ‘&&’ is not?
  2. How exactly does this 1) bool? & bool? and 2) bool? and bool work?

Any other ‘interesting’ operator semantics on Nullable? Any overloaded operators for generic T?

  • 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. 2026-05-10T22:07:31+00:00Added an answer on May 10, 2026 at 10:07 pm

    Operators on Nullable<T> are ‘lifted’ operators. What this means is: if T has the operator, T? will have the ‘lifted’ counterpart.

    && and || aren’t really operators in the same sense as & and | – for example, they can’t be overloaded – from the ECMA spec 14.2.2 Operator overloading:

    The overloadable binary operators are: + – * / % & | ^ << >> == != > < >= <= Only the operators listed above can be overloaded. In particular, it is not possible to overload member access, method invocation, or the =, &&, ||, ??, ?:, checked, unchecked, new, typeof, as, and is operators.

    Likewise, from the ECMA spec, 14.2.7 Lifted operators, the lifted operators are:

    For the unary operators + ++ – — ! ~

    For the binary operators + – * / % & | ^ << >>

    For the equality operators == !=

    For the relational operators < > <= >=

    So basically, the short-circuiting operators aren’t defined as lifted operators.

    [edit: added crib sheet]

    • Lifted operator: a compiler provided operator on Nullable<T>, based on the operators of T – for example: the int ‘+’ operator gets ‘lifted’ onto int?, defined as:

      (int? x, int? y) => (x.HasValue && y.HasValue) ? (x.Value + y.Value) : (int?) null;

    • Operator overloading: the act of providing a custom operator implementation for a given type; for example decimal and DateTime provide various operator overloads

    • Short-circuiting: the normal behavior of && and || (in many languages, including C++ and C#) – i.e. the second operand might not be evaluated – i.e.

      (expression1, expression2) => expression1() ? expression2() : false;

    Or perhaps a simpler example:

    bool someFlag = Method1() && Method2(); 

    if Method1() returns false, then Method2() isn’t executed (since the compiler already knows that the overall answer is false). This is important if Method2() has side-effects, since as saving to the database…

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

Sidebar

Ask A Question

Stats

  • Questions 51k
  • Answers 51k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer ...and, further, if UserA installs the software, but UserB runs… May 11, 2026 at 6:22 am
  • added an answer Your question is not very clear. If what you want… May 11, 2026 at 6:22 am
  • added an answer You want the splice function on the native array object.… May 11, 2026 at 6:22 am

Top Members

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

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.