473,390 Members | 1,295 Online

# Why does Guid.GetHashcode() returns 0 when instantiated with Guid.Empty ?

Why does Guid.GetHashcode() returns 0 when instantiated with Guid.Empty
?

Nov 30 '05 #1
2 4207
What would you expect it to return?

Guid.Empty is a 128 bit number with a value of 0. The hash code
generator for the Guid generates an integer based on the values in the 128
bit number, without offsetting the values by a constant number. This is why
it results in 0.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"csharper" <am*********@gmail.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.com...
Why does Guid.GetHashcode() returns 0 when instantiated with Guid.Empty
?

Nov 30 '05 #2
Thanks Nicholas!

Nov 30 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

### Similar topics

 3 by: Fredrik Wahlgren | last post by: Hi I found an interesting piece of code which shows how to makee an Excel automation add-in at http://www.codeproject.com/dotnet/excelnetauto.asp. I decide to experiment with it and i made a few... 9 by: Rene | last post by: I am using the Guid.Empty value ("00000000-0000-0000-0000-000000000000") to represent a special meaning. The problem is that I don't know if there is a chance that a command like... 8 by: Dan | last post by: Hi, I did a test in C# double x1 = 1.0; double x2 = 5.29980882362664E-315; int h1 = x1.GetHashCode(); int h2 = x2.GetHashCode(); It turned out that both h1 and h2 = 1072693248 5 by: rcolby | last post by: Evening, Wondering if someone can point me in the right direction, on how I would compare a system.guid with a system.byte. system.guid (pulled from sql server table with a data type of... 5 by: George | last post by: I want to create a unique id for each of a set of objects. These ids may be generated on multiple machines simultaneously and must all be different to each other. There are an undefined number... 1 by: Scott M. Lyon | last post by: I've got a stored procedure that takes a few parameters as input parameters, and one output parameter (a uniqueidentifier). After the stored procedure call, I need to return that output parameter... 1 by: Scott M. Lyon | last post by: I've got a stored procedure that takes a few parameters as input parameters, and one output parameter (a uniqueidentifier). After the stored procedure call, I need to return that output parameter... 1 by: Wolf | last post by: Hi I am trying to set a property(PartyHomeAddressID) = to a guid in a ini file. But everytime when the ini file has an empty guid it breaks with an error tellin me a guid is 32 char long with 4... 16 by: Mark S. | last post by: I'm a fan of the GUID, but the current project is looking to use a genuinely unique integer. Does the following do that? Math.Abs(System.Guid.NewGuid().GetHashCode()) TIA 0 by: taylorcarr | last post by: A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,... 0 by: Charles Arthur | last post by: How do i turn on java script on a villaon, callus and itel keypad mobile phone 0 by: ryjfgjl | last post by: In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files... 0 by: emmanuelkatto | last post by: Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel 0 by: Hystou | last post by: There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2... 0 by: marktang | last post by: ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,... 0 by: Hystou | last post by: Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can... 0 by: Oralloy | last post by: Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,... 0 by: Hystou | last post by: Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.