CSharp/C# >> ?? and Guid
by shapper » Mon, 08 Sep 2008 10:29:14 GMT
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
CSharp/C# >> ?? and Guid
by Kerem Grc » Mon, 08 Sep 2008 10:42:12 GMT
Hi Miguel,
can you show code please,...
Regards
Kerem
--
-----------------------
Beste Gr黶se / Best regards / Votre bien devoue
Kerem G黰r黭c?
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" < XXXX@XXXXX.COM > schrieb im Newsbeitrag
CSharp/C# >> ?? and Guid
by Family Tree Mike » Mon, 08 Sep 2008 11:07:21 GMT
A Guid cannot be null, unless you declare it Guid?.
CSharp/C# >> ?? and Guid
by shapper » Mon, 08 Sep 2008 12:43:08 GMT
> Kerem G黰r黭c?
> Latest Project:
http://www.codeplex.com/restarts
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 :-)
CSharp/C# >> ?? and Guid
by shapper » Mon, 08 Sep 2008 12:44:31 GMT
On Sep 8, 4:07燼m, "Family Tree Mike"
Well, I can do this:
Guid id = new Guid();
And yet the Guid value is not defined.
CSharp/C# >> ?? and Guid
by Alex Meleta » Mon, 08 Sep 2008 13:06:53 GMT
Hi shapper,
Yes, but cant Guid id = null. Basicaly, ?? aplied for reference and nullable
types.
http://msdn.microsoft.com/en-us/library/ms173224 (VS.80).aspx
Regards, Alex
blog: devkids.blogspot.com
CSharp/C# >> ?? and Guid
by TW9ydGVuIFdlbm5ldmlrIFtDIyBNVlBd » Mon, 08 Sep 2008 13:08:01 GMT
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]
CSharp/C# >> ?? and Guid
by shapper » Mon, 08 Sep 2008 14:01:40 GMT
On Sep 8, 6:08燼m, Morten Wennevik [C# MVP]
> > > Kerem G黰r黭c?
> > > Latest Project:
http://www.codeplex.com/restarts
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.
Similar Threads
1. Managed GUID to unsafe win32 GUID struct - CSharp/C#
2. difference between assembly: Guid("") in assemblyinfo.cs and Guid("") in class
3. Why does Guid.GetHashcode() returns 0 when instantiated with Guid.Empty ? - CSharp/C#
4. String to GUID in C++ only
This seems to exist in .Net but I would like to do it in C++ only (no
MFC, .net, ATL...)
Do you have any snippet of code doing this ?
GUID StringToGUID(const String myGuidAsAString)
{
//???
}
Any help would be much appreciated,
Mathieu LEMAIRE
5. Network Adapter GUID - CSharp / C#
6. TLB registration isue - how to register TLB with GUID with regtlibv12 or C# solution
Hi all,
I have created .NET classes, compiled it as DLL and registered via
REGASM. Regasm created TLB file, saying that "TypeLib was
registered".. i also created REGfile with regasm and added it to the
registry manually, BUT - the TLB specification is in fact NOT
registered in the registry.
What is in the registry:
1] HKCR\CLSID\{GUID}\...
2] HKCR\ClassNamespace.CLassName\...
3] HKCR\Record\{GUID}\... (Enum declarations..)
with all above the COM interop functions fine. I can create instances
of my class from ASP, etc. Thats fine.
But when i try to use <!--- META type="Typelib" uuid="{GUID}" --> (or
something like this) - the asp ends up with 0223 error saying, that
the TypeLib is not registered.
Actually - after using RegAsm the registry HKCR\TypeLib\{...} contains
no typelib declarations specified by my DLL nor TLB.
So, what did I next was a little detective work - trying figure out
how to register TLB properly.
Finally i found regtlibv12 which resides in 2.0 framework directory
(%systemroot%\microsoft\framework\v2.0...\). However this "tool" is
not documented at all, even has no "help" message at the command line
(wtf?).
So - the only thing i am able to do now is to register the TLB file
from it's location, with no clue how to set up GUID and..i must even
correct the registry path, for it is incomplete.
So..my question is - is this a correct way to register TLB file? How
do I specify the GUID for the regtlibv12 tool?
Or - Am I completly wrong or missing something - than please correct
me or tell me, how to register these mysterious TLB sort of things...
7. GUID-info for: C++ dll1 calls c#-wrapper-dll calls C++ dll2
8. COM Visible Class GUID Assignment