473,378 Members | 1,438 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 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 1337
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.