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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:23:56+00:00 2026-06-14T23:23:56+00:00

I have code where I get a string as input, and I compare it

  • 0

I have code where I get a string as input, and I compare it with an integer.

I saw that integer variable also has an Equals function that accepts a string parameter.

I have used it directly thinking it will typecast it.

It did not give any compile time or runtime error, but it always gives a false result.

For example,

int sessionId = 1;

string requestId="1"

return sessionId.Equals(requestId);

sessionId.Equals(requestId) always gives false.

Why is the reason for such behavior? If there is a reason, why are they allowing it run without error?

  • 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-14T23:23:57+00:00Added an answer on June 14, 2026 at 11:23 pm

    Integers and strings are always different, and thus "1".Equals(1) returns false.

    It compiles because object.Equals(object other) takes an object as the right side, and thus accepts any type.

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

Sidebar

Related Questions

I have the following code : std::string Utils::get() { std::string result; result.append(1, 'x'); result.append(1,
I have the following code: String website = http://www.somewebsite.com/; Document doc = Jsoup.connect(website).get(); Elements
I have this code to get the default constructor: Public Function f(ByVal t As
I have the following code: string input = ç; string normalized = input.Normalize(NormalizationForm.FormD); char[]
I have some inherited code for FlexLM that is converting an integer to a
How to get cyrillic string from document? I have fallowing code: import urllib from
I'm using Grails 1.3.7. I have some code that uses the built-in base64Encode function
I have got this code that reads an integer using scanf and checks if
I have the following code function generate_pdf() { $fdf_data_strings = $this->get_hash_for_pdf(); #$fdf_data_names = array('49a'
If I have code like this: string s = MyClass.GetString(); // Returns string containing

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.