Base di conoscenzaCentro esami
ITItaliano
Scegli la lingua13

CKTIS / C#

System.Guid: riferimento pratico

System.Guid: riferimento pratico: Guid è un identificatore a 128 bit con varie rappresentazioni testuali definite.

Versione: .NET API; verified on .NET 10.0.14

Sintassi

System.Guid /* select a documented member or constructor */

Guid è un identificatore a 128 bit con varie rappresentazioni testuali definite.

Usalo come identificatore praticamente univoco quando non servono segretezza o ordine cronologico naturale.

Un Guid non è un segreto e l’inserimento casuale può frammentare gli indici del database.

Parse genera FormatException per testo non valido, TryParse restituisce false ed Empty contiene solo bit zero.

Il programma completo usa realmente System.Guid; lo stdout esatto atteso è 00112233445566778899aabbccddeeff.

Esempi

using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;

var id = Guid.Parse("00112233-4455-6677-8899-aabbccddeeff");
Console.WriteLine(id.ToString("N"));

Risultato

00112233445566778899aabbccddeeff

Il programma completo usa realmente `System.Guid`; lo stdout esatto atteso è `00112233445566778899aabbccddeeff`.

Fonti