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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:31:13+00:00 2026-05-13T18:31:13+00:00

Can I put an object.property which hasn’t been instantiated on the right hand side

  • 0

Can I put an object.property which hasn’t been instantiated on the right hand side of an ‘AND’ operator if I know that the left hand side will fail but if the left side passes the right side will be instantiated?

In the example below the first if/else statement sets up the other if statement for the above question. Although I’ve tested that it doesn’t show errors, I was wondering what happens behind the scenes or is there a better way.(there are many if/else statements that use the results of the first if/else statement.

        if (_articleGuid.Equals(Guid.Empty))
        {
            isArticleGuid = false;
        }
        else
        {
            article = new Article(Guid.Empty, _articleGuid);
            bodyText = article.Text;
            articleDate = Convert.ToDateTime(article.DateActive);

            isArticleGuid = true;
        }

        if(isArticleGuid && article.Author != null)
        {
            divAuthor.InnerText = article.Author;                        
        }
  • 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-13T18:31:14+00:00Added an answer on May 13, 2026 at 6:31 pm

    Assuming I understand you correctly, this is safe. The article variable will need to be definitely assigned, but the language guarantees that if the LHS expression of an && operator evaluates to false, the RHS expression won’t be evaluated – so you’re not going to get a NullReferenceException.

    From the C# 3.0 language specification, section 7.11:

    The operation x && y corresponds to the operation x & y, except that y is evaluated only if x is not false.

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

Sidebar

Related Questions

I have a request that returns a JSON object with a single property which
hey, hi i want put limit on object creation means a class can have
I can put python doctests in the bodies of each function, which I sometimes
I know I can put escaped HTML tags in string resources. However, looking at
With VIM or Emacs I can put comments in the file that will be
I have a C++ object, Graph , which contains a property named cat of
I have an object which has a state property, for example state = 'state4'
EditorFor() can take an object additionalViewData parameter which the typical method to populate is
I need to get the host out of the Request object. Which property should
I know that in ASP.NET (talking about 2.0 here primarily) one can set a

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.