CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2006
    Posts
    8

    [RESOLVED] Uri.GetHashCode Unique?

    Hi,

    Is the hashcode produced by the function Uri.GetHashCode unique? Can two different URIs produce the same hashcode?

    A quote from Object.GetHashCode:
    The default implementation of GetHashCode does not guarantee uniqueness or consistency
    I would like to use the value of Uri.GetHashCode as a unique key in my DB and i have to be sure it is unique.

    If you have a link to an article claiming it is unique, please refer me to it.

    Thanks,
    Chen.

  2. #2
    Join Date
    Apr 2004
    Location
    England, Europe
    Posts
    2,492

    Re: Uri.GetHashCode Unique?

    Hash codes are generally not guaranteed to be unique.

    To see why, have a look at:
    http://blogs.msdn.com/tomarcher/arch...10/594204.aspx

    The number of possible URLs if far bigger than the number of possible hash codes returned by the .net method.
    Last edited by Zaccheus; March 14th, 2007 at 08:24 AM.
    My hobby projects:
    www.rclsoftware.org.uk

  3. #3
    Join Date
    Feb 2006
    Posts
    8

    Thumbs up Re: [RESOLVED] Uri.GetHashCode Unique?

    Thanks, Zaccheus.

    That was a good article.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured