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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:07:15+00:00 2026-05-13T08:07:15+00:00

I have some questions in C# what are the differences between null comparisons null

  • 0

I have some questions in C#

  1. what are the differences between null comparisons null == value and value == null (value is a variable of any kind: int, string, float,…)

  2. I heard that using prefix increment ++i instead of i++ in some case will enhance the program performance. Why is it so?

  3. I have a snippet code as follow:

        private int _number;            
        public int Number
        {
           get { return _number}
           set { _number = value}
        }
    
        public double Test
        {
           get
           {
              if (null == Number)
                  return 1.1;
              else
                  return 2.2;
           }
        }
    

the question is why here we use null == Number but not null == _number or Number == null or _number == null

4. if I have a struct as follow:

    public struct Vector
    {
        public double X;
        public double Y;

        public Vector(double x, double y)
        {
            X = x;
            Y = y;
        }
    }

    public class Test
    {
        public Vector Position;
        public void StructLength(Test t2)
        {
            Vector v = this.Position - t2.Position;
            if (v.Length > 10)
                 return false;
        }
    }

if we subtract 2 struct likes above, what will be return? and the Length properties of struct will return what?

Is anyone willing to enlighten me?
Thank in advance

  • 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-13T08:07:15+00:00Added an answer on May 13, 2026 at 8:07 am
    1. In most cases it won’t make any difference. It shouldn’t make any difference. If someone overloads the == operator badly it might do. Personally I prefer if (x == null).

    2. You should ask for specifics when you hear this sort of thing. In some cases it could make a difference (at least in the past, in C), but when it’s used as a statement on its own it’s entirely irrelevant – use whichever you find more readable. When used in a side-effecting way (e.g. as a method argument) there may be a tiny, tiny difference – but it’s never likely to be significant.

    3. It makes no difference whether you use the property or the local variable in this case. In some other cases it may make a difference, depending on the code in the property. Comparing an int with null is always going to give a result of false though, so 2.2 will always be returned.

    4. Your code at the moment won’t compile – you’d need to overload the - operator in Vector for it to work, at which point the behavior will depend on the code in the - operator. The same is true for the Length property.

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

Sidebar

Related Questions

I have some questions about basic CSS that I was unable to understand or
I have some questions about customers about NF mode for DB2. Google had very
I have some questions about multi-threaded programming and multi-core usage. In particular I'm wondering
I have some questions about logging, more specifically about setting it up and making
I have some questions about Perl's map function. Specifically: How does %hash = map
I have some questions about partitioning and strategy, how and when to use it.
I've never used the Global Temporary Tables however I have some questions how they
I came across this class while reading a C# book and have some questions.
There have been some questions about whether or not JavaScript is an object-oriented language.
I have some thread-related questions, assuming the following code. Please ignore the possible inefficiency

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.