434,984 Members | 2,615 Online
Need help? Post your question and get tips & solutions from a community of 434,984 IT Pros & Developers. It's quick & easy.

# 128-bit GUID

 P: n/a Hi all, I've got this math problem... I feel a little bit silly but here it is, because it seems first year CS, but my memory fails me. Sample Code: Guid myGuid = new Guid("fccf281d-47bd-45c7-8f2b-a48d462d171b"); Int64 myGuidInt = BitConverter.ToInt64(myGuid.ToByteArray(),0); this.textBox1.Text = myGuid.ToString(); this.textBox2.Text = myGuidInt.ToString(); Byte[] me = myGuid.ToByteArray(); this.textBox3.Text = ""; for (int ow = 0; ow < 16; ow++) { this.textBox3.Text += me[ow].ToString() + "-"; } /* This generates: Int64: 5028066390298273821 ByteArray: 29-40-207-252-189-71-199-69-143-43-164-141-70-45-23-27 */ Questions: The math-by-hand way of doing this is how??? 1. From the guid string "fccf281d-47bd-45c7-8f2b-a48d462d171b" to byte array? (Basically the internal working of ToByteArray()) 2. From the byte array to Int64? (Something like (n1 * 16^0) + (n2 * 16^2) + ... maybe??) 3. Or from the guid string "fccf281d-47bd-45c7-8f2b-a48d462d171b" to it's bit representation? (01010101... all 128 of them). Thank you much for any help you can give. ~Js. Nov 22 '05 #1