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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:09:59+00:00 2026-06-13T11:09:59+00:00

Possible Duplicate: what is hashCode use for? is it unique? I am generating a

  • 0

Possible Duplicate:
what is hashCode use for? is it unique?

I am generating a lot of strings, then my question is:

Can 2 different string have the same hash code in C# ?

By hash code I mean:

string s = "Hello";
s.GetHashCode();

My question is more about of the algorithm that C# follow to geneate the strings, maybe the
collisions come when all the other hash code are generated already or maybe not.
Is possible that somebody have this answer.

  • 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-13T11:10:00+00:00Added an answer on June 13, 2026 at 11:10 am

    Yes. Hash codes are not unique. There are 2^32 (4,294,967,296) possible hash codes (one for each integer value in a 32 bit integer). There are effectively an infinite number of possible strings. Clearly it’s impossible for each of an infinite number of strings to have a different number of finite numbers.

    Two different strings (or any values for that matter) having the same hash code is called a “collision”. A good hashing algorithm will attempt to ensure that collisions are minimized to the greatest extent possible (although they can’t be eliminated). Often this will be dependent on the actual types of data in practice; in this case of strings this means that strings that are similar, or of a similar size, should (ideally) be less prone to collisions.

    I assume that you’re asking because you’re considering using a string’s hash code as a unique identifier for a string. Don’t do that.

    Here is a link that goes into more detail about hash codes in general, if you’re interested.

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

Sidebar

Related Questions

Possible Duplicate: Why does Java's hashCode() in String use 31 as a multiplier? Why
Possible Duplicate: Hibernate: different object with the same identifier value was already associated with
Possible Duplicate: Overriding equals and hashCode in Java If I have class A {
Possible Duplicate: regex for URL including query string I have a text or message.
Possible Duplicate: How do I create a HashCode in .net (c#) for a string
Possible Duplicate: Overriding equals and hashCode in Java All, I have defined my class
Possible Duplicate: Can JavaScript connect with MySQL? I have a database with names and
Possible Duplicate: How can I convert a list<> to a multi-dimensional array? I want
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: Can main function call itself in C++? I found this problem very

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.