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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:53:06+00:00 2026-05-14T08:53:06+00:00

Quick question here about short-circuiting statements in C#. With an if statement like this:

  • 0

Quick question here about short-circuiting statements in C#. With an if statement like this:

if (MyObject.MyArray.Count == 0 || MyObject.MyArray[0].SomeValue == 0)
{

//....
}

Is it guaranteed that evaluation will stop after the “MyArray.Count” portion, provided that portion is true? Otherwise I’ll get a null exception in the second part.

  • 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-14T08:53:06+00:00Added an answer on May 14, 2026 at 8:53 am

    Yes, this is guaranteed.

    C# Language Specification – 7.11 Conditional logical operators:

    The && and || operators are called the conditional logical operators. They are also called the “short-circuiting” logical operators.

    Therefore they will support logical short-circuiting by definition – you can rely on this behavior.

    Now it is important to make a distinction between a conditional operator and a logical operator:

    • Only conditional operators support short-circuiting, logical operators do not.
    • C#’s logical operators look just like their conditional counterparts but with one less character so a logical OR is | and a logical AND is &.
    • Logical operators can be overloaded but conditional operators cannot (this is a bit of an technicality as conditional operator evaluation does involve overload resolution and this overload resolution can resolve to a custom overload of the type’s logical operator, so you can work around this limitation to a certain extent).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First time poster here. A quick question about setting up a loop here. I
A quick question here about the new WCF Ria services beta: If I do
Just a quick question about my Domain Layer/ Domain Service... Should I allow this
Here's a quick question I've been banging my head against today. I'm trying to
So this question is a sort of follow on from here ( how to
quick question here. Is there any Wordpress 3.0 documentation available? Some kind of list
A quick question here: is it faster to load a large XML file (just
Quick question about Ruby forking - I ran across a bit of forking code
I am not starting an argumentative discussion here and this post is not about
Here's a quicky question. Which method name makes the most sense for an Objective-C

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.