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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:27:44+00:00 2026-06-17T19:27:44+00:00

I have a conditional I’m writing that’s checking three things. if(LoggedInMembershipUser == null ||

  • 0

I have a conditional I’m writing that’s checking three things.

if(LoggedInMembershipUser == null || obj == null || boolVal)

In this case, "LoggedInMembershipUser" is just the Membership.GetUser(), "obj" is some random business object, and "boolVal" is obviously a boolean. When I write the statement as above, ReSharper tells me that the boolVal portion of the statement is always false. But when I put boolVal at the beginning as below, I don’t get that notice.

if(boolVal|| LoggedInMembershipUser == null || obj == null)

Why would the first one always be false but the second one not?

EDIT: This is in the row data bind of a grid view. The grid is displaying results from two objects with the same base class, so "obj" will have a value if it’s one of the object types but not the other. boolVal is an indicator for which type of object it is, so now that I think about it, I guess if obj is null then boolVal will always be true. Was ReSharper realizing that somehow? Oh I bet it was because looking at my code above the line I have:

if (!uploaded){
    var obj = GetObjectLogic();
}

Ok thanks for the help comments. I guess this can be voted to be deleted or whatever.

  • 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-17T19:27:45+00:00Added an answer on June 17, 2026 at 7:27 pm

    Without more of the method it is hard to know for sure, but it sure looks ike the following:

    ReSharper has determined that the only way that boolVal can be true is if at least one of LoggedInMembershipUser or obj is null. That first if never reaches the boolval portion unless both are not null. Thus at the point where boolVal is evaluated it must be false.

    If you reorder the conditions, then that logic no longer holds. ReSharper could potentially analyze that expression, determine that all parts are fast and side effect free, and notice that boolVal is not necessary in the second case too, but that analysis is somewhat harder and apparently has not been written.

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

Sidebar

Related Questions

I have a conditional statement that does this if a condition is met. My
So I have a conditional that currently looks like this... if (input.Contains(,) || input.Contains(/)
I have this conditional in a perl script: if ($lnFea =~ m/^(\d+) qid\:([^\s]+).*?\#docid =
I have this: As you can see I currently have a conditional to include
Is it possible for me to have a conditional in XSLT such that I
I have a basic conditional statement that has a chaining function. After the else
I have to make a conditional in ash, that depends on result of two
I have this conditional select, which does what it's supposed to. See fiddle here
I have this conditional select which generally works fine, but I would like to
C and many other languages have a conditional (AKA ternary) operator. This allows you

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.