Click to See Complete Forum and Search --> : problem related to System.Guid


RockStone
February 16th, 2005, 12:12 PM
Hi,

I am having a problem. I have stored a record in the database at run time and retirieved a System.Guid from the entry saved.. Now i have to make this entry connected to some other table..means this guid is to be used as foriegn key in some other table for this session. so i stored this guid in the session .. but when i get to the other page and try to get this saved guid it is returned as an "object" type .. more over i can convert this guid to the string and use this string to the Guid constructor to create a new guid..i want to know whehter this new guid would be same as the one i saved....or not ....... any other solution????

hayko_k
February 19th, 2005, 02:23 AM
Hi Usman,

From what I understood it seems that you are OK - if the string "looks" the same, the Guid constructor will in fact construct exactly the same guid object.
However, why do you really need to invoke the Guid constructor in the first place?
What happens to your Guid in the session is that it's "boxed" (since Guid is a value type) into an object. All you need to do is "unbox" it by casting it back to Guid - that way no constructor call is necessary. (in general in .Net, to be on the safe side when casting, you may use the "is" operator to test for type compatibility).

Good luck!
Hayk Khachikyan

~~ code, sex, and rock-n-roll ~~
Go Mozilla Firefox!!!