Base de conocimientosCentro de exámenes
ESEspañol
Elegir idioma13

CKTIS / C#

System.Guid: referencia práctica

System.Guid: referencia práctica: Guid es un identificador de 128 bits con varias representaciones textuales definidas.

Versión: .NET API; verified on .NET 10.0.14

Sintaxis

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

Guid es un identificador de 128 bits con varias representaciones textuales definidas.

Úsalo como identificador prácticamente único cuando no se necesiten secreto ni orden cronológico natural.

Un Guid no es secreto y el orden de inserción aleatorio puede fragmentar índices de base de datos.

Parse lanza FormatException para texto inválido, TryParse devuelve false y Empty contiene todos los bits en cero.

El programa completo usa realmente System.Guid; su stdout esperado exacto es 00112233445566778899aabbccddeeff.

Ejemplos

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"));

Resultado

00112233445566778899aabbccddeeff

El programa completo usa realmente `System.Guid`; su stdout esperado exacto es `00112233445566778899aabbccddeeff`.

Fuentes