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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:56:25+00:00 2026-05-21T11:56:25+00:00

This should be an easy question hopefully but as a rookie I don’t know

  • 0

This should be an easy question hopefully but as a rookie I don’t know the answer.

In the code below if ignorePath is true I don’t want to enter the if statement even if tempPath is not null and tempPath length is not 0. I thought a single | would do this but it appears not to.

if (((tempPath != null) && (tempPath.Length != 0)) | ignorePath == false)
{

}

Thanks

  • 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-21T11:56:26+00:00Added an answer on May 21, 2026 at 11:56 am

    I’d say the following code would be clearer:

    if ((!ignorePath) && (tempPath != null) && (tempPath.Length != 0))
    {
        // do something here
    }
    

    First you verify that ignorePath is false (because you don’t want the code to execute when it is true), then you check that tempPath is not null and that its length is non-zero.

    The advantage here is that you’ve moved the check of the ignorePath variable to be first. Since it is apparently the most important thing to you (it overrides the other two conditions), it ought to come first for clarity and readability (and performance, I suppose, but that hardly matters here).


    Remember that there’s no reason to check Boolean types against the literal values true or false. An if statement already evaluates whether the value of the statement inside the ( ) is true or false. Specifying it explicitly is just redundant.

    The only problem I see with the above code is that !ignorePath is a little difficult to read. It creates a double negative, as you’re “not-ignoring” something. What exactly does that mean? That’s why most coding standards (including Microsoft’s recommended standards for .NET) encourage you to name Boolean variables with positive grammar. I’d call that variable something like checkPath, instead.

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

Sidebar

Related Questions

This question should hopefully be easy to answer. I created a few buttons in
I think this should be a pretty easy question to answer but I can't
This should be an easy question - but I'm having a hard time figuring
So this should be a real easy question but I can't seem to find
This should be an easy question I figure, but I hadn't found this answered
I feel like this should be an easy question, but I can't get it
This should probably be a super easy question but I can't figure out what
Okay, this should be a fairly easy question I think, but haven't been able
Hopefully this should be an easy question. In Java I think it's compareTo() .
I feel like this should be an easy question but I can't seem to

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.