472,950 Members | 2,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,950 software developers and data experts.

?? and Guid

Hello,

I am inserting an item on a XML file and I have something like this:

paper.ID ?? Guid.NewGuid()

Basically my idea was that if paper.ID is null then create a new Guid.

It says it is not possible to use ?? with Guid. Is there another
option to do this?

Thanks,
Miguel
Sep 8 '08 #1
9 1315
Hi Miguel,

can you show code please,...
Regards

Kerem

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.codeplex.com/restarts
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
"shapper" <md*****@gmail.comschrieb im Newsbeitrag
news:cb**********************************@d45g2000 hsc.googlegroups.com...
Hello,

I am inserting an item on a XML file and I have something like this:

paper.ID ?? Guid.NewGuid()

Basically my idea was that if paper.ID is null then create a new Guid.

It says it is not possible to use ?? with Guid. Is there another
option to do this?

Thanks,
Miguel
Sep 8 '08 #2
A Guid cannot be null, unless you declare it Guid?.

"shapper" <md*****@gmail.comwrote in message
news:cb**********************************@d45g2000 hsc.googlegroups.com...
Hello,

I am inserting an item on a XML file and I have something like this:

paper.ID ?? Guid.NewGuid()

Basically my idea was that if paper.ID is null then create a new Guid.

It says it is not possible to use ?? with Guid. Is there another
option to do this?

Thanks,
Miguel
Sep 8 '08 #3
On Sep 8, 3:42*am, Kerem Gümrükcü <kareem...@hotmail.comwrote:
Hi Miguel,

can you show code please,...

Regards

Kerem

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project:http://www.codeplex.com/restarts
Latest Open-Source Projects:http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
"shapper" <mdmo...@gmail.comschrieb im Newsbeitragnews:cb******************************** **@d45g2000hsc.googlegroups.com...
Hello,
I am inserting an item on a XML file and I have something like this:
paper.ID ?? Guid.NewGuid()
Basically my idea was that if paper.ID is null then create a new Guid.
It says it is not possible to use ?? with Guid. Is there another
option to do this?
Thanks,
Miguel
album.Add(new XElement("img",
new XAttribute("id", paper.Slide.SlideID ??
Guid.NewGuid())
));

paper.Slide is an object. So if it's SlideID, which is Guid, had no
value assigned then a new guid is used.

This seemed logic to me until I got the error :-)
Sep 8 '08 #4
On Sep 8, 4:07*am, "Family Tree Mike"
<FamilyTreeM...@ThisOldHouse.comwrote:
A Guid cannot be null, unless you declare it Guid?.

"shapper" <mdmo...@gmail.comwrote in message

news:cb**********************************@d45g2000 hsc.googlegroups.com...
Hello,
I am inserting an item on a XML file and I have something like this:
paper.ID ?? Guid.NewGuid()
Basically my idea was that if paper.ID is null then create a new Guid.
It says it is not possible to use ?? with Guid. Is there another
option to do this?
Thanks,
Miguel
Well, I can do this:

Guid id = new Guid();

And yet the Guid value is not defined.

Sep 8 '08 #5

"shapper" wrote:
On Sep 8, 3:42 am, Kerem Gümrükcü <kareem...@hotmail.comwrote:
Hi Miguel,

can you show code please,...

Regards

Kerem

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project:http://www.codeplex.com/restarts
Latest Open-Source Projects:http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
"shapper" <mdmo...@gmail.comschrieb im Newsbeitragnews:cb******************************** **@d45g2000hsc.googlegroups.com...
Hello,
I am inserting an item on a XML file and I have something like this:
paper.ID ?? Guid.NewGuid()
Basically my idea was that if paper.ID is null then create a new Guid.
It says it is not possible to use ?? with Guid. Is there another
option to do this?
Thanks,
Miguel

album.Add(new XElement("img",
new XAttribute("id", paper.Slide.SlideID ??
Guid.NewGuid())
));

paper.Slide is an object. So if it's SlideID, which is Guid, had no
value assigned then a new guid is used.

This seemed logic to me until I got the error :-)
Since SlideID is a Guid it cannot be null. Therefore SlideID ?? makes no
sense. Now, if you make SlideID a Guid? (nullable Guid) your code should
work.

--
Happy Coding!
Morten Wennevik [C# MVP]
Sep 8 '08 #6
Hi shapper,

Yes, but cant Guid id = null. Basicaly, ?? aplied for reference and nullable
types.
http://msdn.microsoft.com/en-us/libr...24(VS.80).aspx

Regards, Alex
blog: devkids.blogspot.com
Well, I can do this:

Guid id = new Guid();

And yet the Guid value is not defined.

Sep 8 '08 #7
shapper <md*****@gmail.comwrote:
Well, I can do this:

Guid id = new Guid();

And yet the Guid value is not defined.
Yes it is. That's a well-defined Guid of all zeroes. It's sort of like
the empty string of Guids.

--
Jon Skeet - <sk***@pobox.com>
Web site: http://www.pobox.com/~skeet
Blog: http://www.msmvps.com/jon.skeet
C# in Depth: http://csharpindepth.com
Sep 8 '08 #8
On Sep 8, 6:08*am, Morten Wennevik [C# MVP]
<MortenWenne...@hotmail.comwrote:
"shapper" wrote:
On Sep 8, 3:42 am, Kerem Gümrükcü <kareem...@hotmail.comwrote:
Hi Miguel,
can you show code please,...
Regards
Kerem
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project:http://www.codeplex.com/restarts
Latest Open-Source Projects:http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."
"shapper" <mdmo...@gmail.comschrieb im Newsbeitragnews:cb******************************** **@d45g2000hsc.googlegroups.com...
Hello,
I am inserting an item on a XML file and I have something like this:
paper.ID ?? Guid.NewGuid()
Basically my idea was that if paper.ID is null then create a new Guid.
It says it is not possible to use ?? with Guid. Is there another
option to do this?
Thanks,
Miguel
* * * album.Add(new XElement("img",
* * * * * * * * * new XAttribute("id", paper.Slide.SlideID ??
Guid.NewGuid())
* * * * * * * * ));
paper.Slide is an object. So if it's SlideID, which is Guid, had no
value assigned then a new guid is used.
This seemed logic to me until I got the error :-)

Since SlideID is a Guid it cannot be null. *Therefore SlideID ?? makes no
sense. *Now, if you make SlideID a Guid? (nullable Guid) your code should
work.

--
Happy Coding!
Morten Wennevik [C# MVP]
I see. I think I will let it this way because it is generated by Linq
To SQL dbml and I prefer to touch the least possible in the generated
code.
Sep 8 '08 #9
On Sep 8, 6:22*am, Jon Skeet [C# MVP] <sk...@pobox.comwrote:
shapper <mdmo...@gmail.comwrote:
Well, I can do this:
Guid id = new Guid();
And yet the Guid value is not defined.

Yes it is. That's a well-defined Guid of all zeroes. It's sort of like
the empty string of Guids.

--
Jon Skeet - <sk...@pobox.com>
Web site:http://www.pobox.com/~skeet*
Blog:http://www.msmvps.com/jon.skeet
C# in Depth:http://csharpindepth.com
You are completely right!

Thanks,
Miguel
Sep 8 '08 #10

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

Similar topics

4
by: Louis Frolio | last post by:
Greetings All, I have read many upon many articles here regarding GUID data types and uniqueness. There have been many opinions regarding the effectiveness of GUID's and when they should/should...
6
by: Jim Heavey | last post by:
When I use the new(Guid), the GUID which is generated is all zeros. Is there a technique for the system to assign a real Guid? Do I have to manually calculate a GUID?
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...
14
by: Nak | last post by:
Hi there, Does anyone know how I would get the value of the assembly GUID in code from within the same application? Thanks in advance. Nick. --...
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: 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...
5
by: Michael Primeaux | last post by:
I have a simple .NET 2.0 web service created with VS.NET 2005 with a single web method with the following signature: void HelloWorld(Guid parameter1); When calling this method I receive the...
2
by: Troll | last post by:
Windows XP Pro VS 2005 & C# (I'm fairly new to C# but have doing VB.Net going on 2yrs and VB6 for 5yrs.) I'm using C# to build a custom RSS generator. I'm having trouble building the guid...
4
by: Marc | last post by:
Hi, I don't get it I cannot get this to work, can somebody give me a hint Table1 contains a field Id which is a GUID as primary key and DATA a string, I want to insert a new row but it does not...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

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.