NewGuid vs System.Guid.NewGuid().ToString(“D”);

I realize that this question already has an accepted answer, but I thought it would be useful to share some information about formatting guids. The ToString() (no parameters) method formats a guid using this format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx The ToString(string format) method formats a guid in one of several ways: “N” – xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (32 digits) “D” – … Read more

Assigning a GUID in C#

If you already have a string representation of the Guid, you can do this: Guid g = new Guid(“11223344-5566-7788-99AA-BBCCDDEEFF00”); And if you want a brand new Guid then just do Guid g = Guid.NewGuid();

How to set null to a GUID property

Is there a way to set my property as null or string.empty in order to restablish the field in the database as null. No. Because it’s non-nullable. If you want it to be nullable, you have to use Nullable<Guid> – if you didn’t, there’d be no point in having Nullable<T> to start with. You’ve got … Read more

Strongly typed Guid as generic struct

First off, this is a really good idea. A brief aside: I wish C# made it easier to create cheap typed wrappers around integers, strings, ids, and so on. We are very “string happy” and “integer happy” as programmers; lots of things are represented as strings and integers which could have more information tracked in … Read more

Is there any point in specifying a Guid when using ComVisible(false)?

Having [assembly: ComVisible(false)] and [assembly: Guid(“…”)] at the same time makes perfect sense in certain cases. You start with an empty assembly and will perhaps want to expose something from it to COM. So you mark the assembly as not ComVisible and later mark the entities to expose as ComVisible. That is why the GUID … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)