Guid.TryParse 메서드

정의

오버로드

Name Description
TryParse(ReadOnlySpan<Char>, IFormatProvider, Guid)

문자 범위를 값으로 구문 분석하려고 시도합니다.

TryParse(ReadOnlySpan<Byte>, Guid)
TryParse(ReadOnlySpan<Char>, Guid)

GUID의 표현을 포함하는 지정된 읽기 전용 문자 범위를 해당하는 Guid 구조체로 변환합니다.

TryParse(String, Guid)

GUID의 문자열 표현을 해당하는 Guid 구조체로 변환합니다.

TryParse(ReadOnlySpan<Byte>, IFormatProvider, Guid)

UTF-8 문자의 범위를 값으로 구문 분석하려고 시도합니다.

TryParse(String, IFormatProvider, Guid)

문자열을 값으로 구문 분석하려고 시도합니다.

TryParse(ReadOnlySpan<Char>, IFormatProvider, Guid)

Source:
Guid.cs
Source:
Guid.cs
Source:
Guid.cs
Source:
Guid.cs
Source:
Guid.cs

문자 범위를 값으로 구문 분석하려고 시도합니다.

public:
 static bool TryParse(ReadOnlySpan<char> s, IFormatProvider ^ provider, [Runtime::InteropServices::Out] Guid % result) = ISpanParsable<Guid>::TryParse;
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out Guid result);
static member TryParse : ReadOnlySpan<char> * IFormatProvider * Guid -> bool
Public Shared Function TryParse (s As ReadOnlySpan(Of Char), provider As IFormatProvider, ByRef result As Guid) As Boolean

매개 변수

s
ReadOnlySpan<Char>

구문 분석할 문자의 범위입니다.

provider
IFormatProvider

에 대한 문화권별 서식 정보를 제공하는 개체입니다 s.

result
Guid

이 메서드가 반환될 때 성공적으로 구문 분석 s한 결과 또는 실패 시 정의되지 않은 값이 포함됩니다.

반품

성공적으로 구문 분석되었으면 .

적용 대상

TryParse(ReadOnlySpan<Byte>, Guid)

Source:
Guid.cs
Source:
Guid.cs
public:
 static bool TryParse(ReadOnlySpan<System::Byte> utf8Text, [Runtime::InteropServices::Out] Guid % result);
public static bool TryParse(ReadOnlySpan<byte> utf8Text, out Guid result);
static member TryParse : ReadOnlySpan<byte> * Guid -> bool
Public Shared Function TryParse (utf8Text As ReadOnlySpan(Of Byte), ByRef result As Guid) As Boolean

매개 변수

utf8Text
ReadOnlySpan<Byte>
result
Guid

반품

적용 대상

TryParse(ReadOnlySpan<Char>, Guid)

Source:
Guid.cs
Source:
Guid.cs
Source:
Guid.cs
Source:
Guid.cs
Source:
Guid.cs

GUID의 표현을 포함하는 지정된 읽기 전용 문자 범위를 해당하는 Guid 구조체로 변환합니다.

public:
 static bool TryParse(ReadOnlySpan<char> input, [Runtime::InteropServices::Out] Guid % result);
public static bool TryParse(ReadOnlySpan<char> input, out Guid result);
static member TryParse : ReadOnlySpan<char> * Guid -> bool
Public Shared Function TryParse (input As ReadOnlySpan(Of Char), ByRef result As Guid) As Boolean

매개 변수

input
ReadOnlySpan<Char>

변환할 GUID를 나타내는 문자가 포함된 범위입니다.

result
Guid

이 메서드가 반환될 때 구문 분석된 값을 포함합니다. 메서드가 반환 trueresult 되면 유효한 Guid. 메서드가 반환 falseresult 되면 같아 줍니다.Empty

반품

true구문 분석 작업이 성공하면 이고, 그렇지 않으면 . false

적용 대상

TryParse(String, Guid)

Source:
Guid.cs
Source:
Guid.cs
Source:
Guid.cs
Source:
Guid.cs
Source:
Guid.cs

GUID의 문자열 표현을 해당하는 Guid 구조체로 변환합니다.

public:
 static bool TryParse(System::String ^ input, [Runtime::InteropServices::Out] Guid % result);
public static bool TryParse(string input, out Guid result);
public static bool TryParse(string? input, out Guid result);
static member TryParse : string * Guid -> bool
Public Shared Function TryParse (input As String, ByRef result As Guid) As Boolean

매개 변수

input
String

변환할 GUID가 포함된 문자열입니다.

result
Guid

이 메서드가 반환될 때 구문 분석된 값을 포함합니다. 메서드가 반환 trueresult 되면 유효한 Guid. 메서드가 반환 falseresult 되면 같아 줍니다.Empty

반품

true구문 분석 작업이 성공하면 이고, 그렇지 않으면 . false

예제

다음 예제에서는 새 GUID를 만들고, "B", "D" 및 "X" 형식 지정자를 사용하여 메서드를 호출 ToString(String) 하여 세 개의 별도 문자열 표현으로 변환한 다음, 메서드를 호출 TryParse 하여 문자열을 다시 값으로 Guid 변환합니다.

Guid originalGuid = Guid.NewGuid();
// Create an array of string representations of the GUID.
string[] stringGuids = { originalGuid.ToString("B"),
                         originalGuid.ToString("D"),
                         originalGuid.ToString("X") };

// Parse each string representation.
foreach (var stringGuid in stringGuids)
{
    if (Guid.TryParse(stringGuid, out var newGuid))
        Console.WriteLine($"Converted {stringGuid} to a Guid");
    else
        Console.WriteLine($"Unable to convert {stringGuid} to a Guid");
}

// The example displays output similar to the following:
//
//    Converted {81a130d2-502f-4cf1-a376-63edeb000e9f} to a Guid
//    Converted 81a130d2-502f-4cf1-a376-63edeb000e9f to a Guid
//    Converted {0x81a130d2,0x502f,0x4cf1,{0xa3,0x76,0x63,0xed,0xeb,0x00,0x0e,0x9f}} to a Guid
open System

let originalGuid = Guid.NewGuid()

// Create an array of string representations of the GUID.
let stringGuids =
    [| originalGuid.ToString "B"
       originalGuid.ToString "D"
       originalGuid.ToString "X" |]

// Parse each string representation.
for stringGuid in stringGuids do
    match Guid.TryParse stringGuid with
    | true, newGuid ->
        printfn $"Converted {stringGuid} to a Guid"
    | _ ->
        printfn $"Unable to convert {stringGuid} to a Guid"

// The example displays output similar to the following:
//
//    Converted {81a130d2-502f-4cf1-a376-63edeb000e9f} to a Guid
//    Converted 81a130d2-502f-4cf1-a376-63edeb000e9f to a Guid
//    Converted {0x81a130d2,0x502f,0x4cf1,{0xa3,0x76,0x63,0xed,0xeb,0x00,0x0e,0x9f}} to a Guid
Module Example
   Public Sub Main()
      Dim originalGuid As Guid = Guid.NewGuid()
      ' Create an array of string representations of the GUID.
      Dim stringGuids() As String = { originalGuid.ToString("B"),
                                      originalGuid.ToString("D"),
                                      originalGuid.ToString("X") }
      
      ' Parse each string representation.
      Dim newGuid As Guid
      For Each stringGuid In stringGuids
         If Guid.TryParse(stringGuid, newGuid) Then
            Console.WriteLine("Converted {0} to a Guid", stringGuid)
         Else
            Console.WriteLine("Unable to convert {0} to a Guid", 
                              stringGuid)
         End If     
      Next                                      
   End Sub
End Module
' The example displays the following output:
'    Converted {81a130d2-502f-4cf1-a376-63edeb000e9f} to a Guid
'    Converted 81a130d2-502f-4cf1-a376-63edeb000e9f to a Guid
'    Converted {0x81a130d2,0x502f,0x4cf1,{0xa3,0x76,0x63,0xed,0xeb,0x00,0x0e,0x9f}} to a Guid

설명

이 메서드는 구문 분석된 GUID를 반환하는 대신 인식된 형식인 경우 Parsefalse 를 반환 input 하고 예외를 throw하지 않는다는 점을 제외하고 메서드와 같습니다null. 다음 표와 같이 선행 또는 후행 공백 input 을 잘라내고, 다음 표와 같이 메서드에서 ToString(String) 인식되는 ToString(String, IFormatProvider) 5가지 형식 중 하나로 문자열을 변환합니다.

지정자 Description 포맷
N 32자리 숫자 00000000000000000000000000000000
D 하이픈으로 구분된 32자리 숫자 00000000-0000-0000-0000-000000000000
B 하이픈으로 구분된 32자리 숫자(중괄호로 묶임) {00000000-0000-0000-0000-000000000000}
P 하이픈으로 구분된 32자리 숫자( 괄호로 묶임) (00000000-0000-0000-0000-000000000000)
X 중괄호로 묶인 4개의 16진수 값입니다. 여기서 네 번째 값은 중괄호로 묶인 8개의 16진수 값의 하위 집합입니다. {0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}

추가 정보

적용 대상

TryParse(ReadOnlySpan<Byte>, IFormatProvider, Guid)

Source:
Guid.cs
Source:
Guid.cs

UTF-8 문자의 범위를 값으로 구문 분석하려고 시도합니다.

public:
 static bool TryParse(ReadOnlySpan<System::Byte> utf8Text, IFormatProvider ^ provider, [Runtime::InteropServices::Out] Guid % result) = IUtf8SpanParsable<Guid>::TryParse;
public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider, out Guid result);
static member TryParse : ReadOnlySpan<byte> * IFormatProvider * Guid -> bool
Public Shared Function TryParse (utf8Text As ReadOnlySpan(Of Byte), provider As IFormatProvider, ByRef result As Guid) As Boolean

매개 변수

utf8Text
ReadOnlySpan<Byte>

구문 분석할 UTF-8 문자의 범위입니다.

provider
IFormatProvider

에 대한 문화권별 서식 정보를 제공하는 개체입니다 utf8Text.

result
Guid

반환되는 경우 성공적으로 구문 분석 utf8Text 한 결과 또는 실패에 대한 정의되지 않은 값이 포함됩니다.

반품

성공적으로 구문 분석되었으면 .

적용 대상

TryParse(String, IFormatProvider, Guid)

Source:
Guid.cs
Source:
Guid.cs
Source:
Guid.cs
Source:
Guid.cs
Source:
Guid.cs

문자열을 값으로 구문 분석하려고 시도합니다.

public:
 static bool TryParse(System::String ^ s, IFormatProvider ^ provider, [Runtime::InteropServices::Out] Guid % result) = IParsable<Guid>::TryParse;
public static bool TryParse(string? s, IFormatProvider? provider, out Guid result);
static member TryParse : string * IFormatProvider * Guid -> bool
Public Shared Function TryParse (s As String, provider As IFormatProvider, ByRef result As Guid) As Boolean

매개 변수

s
String

구문 분석할 문자열입니다.

provider
IFormatProvider

에 대한 문화권별 서식 정보를 제공하는 개체입니다 s.

result
Guid

이 메서드가 반환될 때 성공적으로 구문 분석 s 한 결과 또는 실패 시 정의되지 않은 값이 포함됩니다.

반품

성공적으로 구문 분석되었으면 .

적용 대상