Can I create or generate an invalid System.Guid in .Net?

.net, c#, guid, vb.net

Solution

Can a Guid be created with invalid symbols or spaces or being too short or longer than an valid one etc?

No - a Guid is just a 128-bit number that can be represented in 5 groups of hexadecimal numbers. There's no way for the string representation of a `Guid` to contain anything other than 32 hex characters (and possibly 4 hyphens or a few other formatting characters).

You can create a string that does not represent a valid `Guid`, but there's no way to put that into a `Guid` object.

Problem

Can somehow an invalid System.Guid object be created in .Net (Visual Basic or C#). I know about Guid.Empty method but it is not what I am searching for. For example with invalid symbols or spaces or being too short or longer than an valid one etc. Thanks!

Original source