Skip to content

GuidGen ​

This page is about the GuidGen class available in PeyrSharp.Core. You can find here all of its methods and properties.

INFO

This class is static.

Compatibility ​

The GuidGen class is part of the PeyrSharp.Core module, which is compatible with all of these frameworks and platforms:

Package/PlatformWindowsmacOSLinux + others
Core✅✅✅
Framework.NET 6.NET 7.NET 8
Core✅✅✅

Methods ​

Generate() ​

Definition ​

The Generate() method generates a Guid and will return it as a string.

INFO

This method has different overloads.

Arguments ​

This method has no arguments.

Usage ​

c#
using PeyrSharp.Core;

string guid = GuidGen.Generate();
// guid = 7992acdd-1c9a-4985-92df-04599d560bbc (example)

Generate(length) ​

Definition ​

The Generate() method generates a Guid with a specific length and will return it as a string.

INFO

This method is an overload of Generate()

Arguments ​

This method has one argument:

TypeNameMeaning
intlengthThe length of the Guid.

WARNING

The length must be a number, otherwise, it will thrown a InvalidGuidLengthException.

Usage ​

c#
using PeyrSharp.Core;

string guid = GuidGen.Generate(15);
// guid = 5693ad99881e4f9 (example)

Generate(fromString) ​

Definition ​

The Generate() method generates a Guid from a specific string and will return it as a string.

INFO

This method is an overload of Generate()

Arguments ​

This method has one argument:

TypeNameMeaning
stringfromStringThe string which will be used to generate the Guid.

Usage ​

c#
using PeyrSharp.Core;

string guid = GuidGen.Generate("Hello");
// guid = 53991a8b-61c4-9612-a827-abf8c47804d7

Generate(guidOptions) ​

Definition ​

The Generate() method generates a Guid with specific GuidOptions and will return it as a string.

INFO

This method is an overload of Generate()

Arguments ​

This method has one argument:

TypeNameMeaning
GuidOptionsguidOptionsThe options of the Guid to generate.

Usage ​

c#
using PeyrSharp.Core;

string guid = Guid.Generate(new GuidOptions(32, true, true, false));
// guid = {35c3ab90-7636-4d34-a439-bc65eb3c} (example)

Released under the MIT License.