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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:35:30+00:00 2026-05-12T08:35:30+00:00

Okay, this is probably very simple but, I have the below checks (not at

  • 0

Okay, this is probably very simple but, I have the below “checks” (not at the same time) and the First ALWAYS evaluates to TRUE while the Second SEEMS to work. This actually happens in each place that the row value is a number or bool(Date seems fine...).

If I walk through the code in Debug it shows the value of row["PersonID"] as 162434, the same as tbxPersonID.EditValue. Is this just a basic and beginner truth about programming that I missed in my hodge-podge-self-education?

It seems, if I cast everything in question to a string first, I will be fine I would just like to know if I am correct and if there is a general rule as to what Types I would need to do this for?

Doesn’t Work

if (row["PersonID"] != tbxPersonID.EditValue)
{
    row["PersonID"] = tbxPersonID.EditValue;
}
if (row["CitizenFlag"] != chkCitizen.EditValue)
{
    row["CitizenFlag"] = chkCitizen.EditValue;
    _whatChanged.Add("CitizenFlag");
}

Works

 if (row["PersonID"].ToString() != tbxPersonID.EditValue.ToString())
 {
     row["PersonID"] = tbxPersonID.EditValue;
 }

 if (row["CitizenFlag"].ToString() != chkCitizen.EditValue.ToString())
 {
     row["CitizenFlag"] = chkCitizen.EditValue;
     _whatChanged.Add("CitizenFlag");
 }
  • 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-12T08:35:30+00:00Added an answer on May 12, 2026 at 8:35 am

    row["PersonID"] is of type object, which means that != and == will use reference identity. Basically you’re comparing boxed values.

    If you use:

    if (!object.Equals(row["PersonID"], tbxPersonID.EditValue))
    

    then you’ll get value equality semantics, and I suspect you’ll be okay – assuming that tbxPersonID really is an int, either boxed or not.

    Just to make things concrete, here’s a short but complete example to show what I’m talking about:

    using System;
    
    class Test
    {
        static void Main()
        {
            object first = 2;
            object second = 2;
    
            // Compares reference equality: false
            Console.WriteLine(first == second);
    
            // Compares value equality: true
            Console.WriteLine(object.Equals(first, second));
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, this is (probably) a very simple question, but I am afraid I know
Okay, this is probably a very basic question; but, I'm just getting back in
Okay this question is very simple: I have a facebook page, and a website.
Okay this may be a simple question but I have yet to come with
This is probably a very simple question. I am new to Rails and have
Okay my question is probably very simple for some of you but I can
Okay, this is probably a very newbie question, but how can I get to
Okay. This is propably very basic and noobie, but I have about 20+ stores
Okay this is probably a rookie question, but I have never done GUI programming
Okay, I know this is probably dead simple, but I can't seem to find

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.