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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:05:43+00:00 2026-06-14T00:05:43+00:00

Having even more than two options to choose from, leads me to question, which

  • 0

Having even more than two options to choose from, leads me to question, which one to choose, if the result / outcome is same.

in .NET C# the following conditions are asking same question using different operators, so the question is , what experienced developers use, i tend to assume that ready made operators like Equals would go through more processing actions.

When and why would you choose ! over Equals, and both over ‘traditional’ == ?

//bool
if (!Page.IsPostBack) 
{
    //bool
    if (NotAuthorized().Equals(false)) 
    {            
        AppsCtrls.DDLs_Init();

        //bool
        if (CurrSeSn.Raised(Flag.MainDataSet_IsPopulated) == false)
        {
            initALLDataSet(AllDataStColsSelectionMod.doneViaSP);
        }

        custid = RConv.Str2int(Request.QueryString["custid"]);
        username = GetTableData.AsString("name", "tblCustomers", "custid", custid);
    }
}
  • 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-14T00:05:44+00:00Added an answer on June 14, 2026 at 12:05 am

    This question is somewhat subjective…

    “i tend to assume that ready made operators like Equals would go
    through more processing actions.”

    ” when and why would you choose ! over Equals , And both over
    ‘traditional’ == “

    the Equals method as part of an instance of an object is used to check for equality of that instance against another, whilst the == and != operators are static and are therefore unbound from any object instance. Instead these are like a special static method that accepts two arguments (of usually the same type) and compares them.

    Consider the following example:

    public class CustomObject
    {
        int someValue, anotherValue;    
    
        public bool Equals(CustomObject obj)
        {
            return (this.someValue == obj.someValue && this.anotherValue == obj.anotherValue);
        }
    
        public static bool operator ==(CustomObject a, CustomObject b)
        {
            return a.Equals(b);
        }
    
        public static bool operator !=(CustomObject a, CustomObject b)
        {
            return !(a == b);
        }
    }
    

    In this example, the Equals method is used to produce a result of the comparison of values in the CustomObject against another instance of the same type. The == operator for CustomObject simply calls Equals on one of the parameter objects and performs an equality check against the other. The != operator simply negates the == and produces the opposite result. Therefore, == and != do not have much performance overhead over Equals, because they both call that method anyway.

    Best practices:

    if a condition is boolean by nature there is no need to use Equals, != or ==, but you should use ! to negate a boolean condition.

    For example:

    if(IsPostBack) // this is good
    
    if(IsPostBack == true) // this is unnecessary
    
    if(!IsPostBack) // this is good
    
    if(IsPostBack == false) // this is unnecessary
    

    If a condition is not boolean by nature, or you are comparing two boolean values, or you are comparing an enumeration, or other value type then use of != or == is acceptable.

    For example:

    if(a == b) // this is good
    
    if(a != b) // this is good
    

    If a condition is not boolean by nature and the objects you are comparing do not have the == or != operators implemented, then using Equals is acceptable. Note, using != and == are prohibited with generics since it is not known at compile time that != or == are implemented on the objects represented by the generic objects type parameters.

    For example:

    if(a.Equals(b)) //this is good
    
    if(!a.Equals(b)) // this is good
    
    if(a.Equals(b) == true) // this is unnecessary
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables, both having more than 20 million records; table1 is a
This is a process question, so there may be more than one right answer.
I am having the hardest time figuring this out, even though it is one
I am having a div, which should be centre of the window, even after
I have implemented UILocalNotifications in two different apps now. One uses Location Services, which
Edit: ST does not allow to post more than two links for newbies. Sorry
I'm having problems uploading and even viewing files in the File section of MODX
I am having problems understanding how to make complex queries (or even simple ones)
the problem I'm having is that cyrillic text looks bold ( Example ) even
Even after studying the examples , I'm having trouble figuring out how to extract

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.