Guid.Parse 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
오버로드
| Name | Description |
|---|---|
| Parse(String, IFormatProvider) |
문자열을 값으로 구문 분석합니다. |
| Parse(ReadOnlySpan<Char>, IFormatProvider) |
문자 범위를 값으로 구문 분석합니다. |
| Parse(ReadOnlySpan<Byte>, IFormatProvider) |
UTF-8 문자의 범위를 값으로 구문 분석합니다. |
| Parse(ReadOnlySpan<Char>) |
GUID를 나타내는 읽기 전용 문자 범위를 해당하는 Guid 구조체로 변환합니다. |
| Parse(ReadOnlySpan<Byte>) | |
| Parse(String) |
GUID의 문자열 표현을 해당하는 Guid 구조체로 변환합니다. |
Parse(String, IFormatProvider)
- Source:
- Guid.cs
- Source:
- Guid.cs
- Source:
- Guid.cs
- Source:
- Guid.cs
- Source:
- Guid.cs
문자열을 값으로 구문 분석합니다.
public:
static Guid Parse(System::String ^ s, IFormatProvider ^ provider) = IParsable<Guid>::Parse;
public static Guid Parse(string s, IFormatProvider? provider);
static member Parse : string * IFormatProvider -> Guid
Public Shared Function Parse (s As String, provider As IFormatProvider) As Guid
매개 변수
- s
- String
구문 분석할 문자열입니다.
- provider
- IFormatProvider
에 대한 문화권별 서식 정보를 제공하는 개체입니다 s.
반품
구문 분석의 결과입니다 s.
구현
적용 대상
Parse(ReadOnlySpan<Char>, IFormatProvider)
- Source:
- Guid.cs
- Source:
- Guid.cs
- Source:
- Guid.cs
- Source:
- Guid.cs
- Source:
- Guid.cs
문자 범위를 값으로 구문 분석합니다.
public:
static Guid Parse(ReadOnlySpan<char> s, IFormatProvider ^ provider) = ISpanParsable<Guid>::Parse;
public static Guid Parse(ReadOnlySpan<char> s, IFormatProvider? provider);
static member Parse : ReadOnlySpan<char> * IFormatProvider -> Guid
Public Shared Function Parse (s As ReadOnlySpan(Of Char), provider As IFormatProvider) As Guid
매개 변수
- s
- ReadOnlySpan<Char>
구문 분석할 문자의 범위입니다.
- provider
- IFormatProvider
에 대한 문화권별 서식 정보를 제공하는 개체입니다 s.
반품
구문 분석의 결과입니다 s.
구현
적용 대상
Parse(ReadOnlySpan<Byte>, IFormatProvider)
- Source:
- Guid.cs
- Source:
- Guid.cs
UTF-8 문자의 범위를 값으로 구문 분석합니다.
public:
static Guid Parse(ReadOnlySpan<System::Byte> utf8Text, IFormatProvider ^ provider) = IUtf8SpanParsable<Guid>::Parse;
public static Guid Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider);
static member Parse : ReadOnlySpan<byte> * IFormatProvider -> Guid
Public Shared Function Parse (utf8Text As ReadOnlySpan(Of Byte), provider As IFormatProvider) As Guid
매개 변수
- utf8Text
- ReadOnlySpan<Byte>
구문 분석할 UTF-8 문자의 범위입니다.
- provider
- IFormatProvider
에 대한 문화권별 서식 정보를 제공하는 개체입니다 utf8Text.
반품
구문 분석의 결과입니다 utf8Text.
구현
적용 대상
Parse(ReadOnlySpan<Char>)
- Source:
- Guid.cs
- Source:
- Guid.cs
- Source:
- Guid.cs
- Source:
- Guid.cs
- Source:
- Guid.cs
GUID를 나타내는 읽기 전용 문자 범위를 해당하는 Guid 구조체로 변환합니다.
public:
static Guid Parse(ReadOnlySpan<char> input);
public static Guid Parse(ReadOnlySpan<char> input);
static member Parse : ReadOnlySpan<char> -> Guid
Public Shared Function Parse (input As ReadOnlySpan(Of Char)) As Guid
매개 변수
- input
- ReadOnlySpan<Char>
GUID를 나타내는 바이트를 포함하는 읽기 전용 범위입니다.
반품
구문 분석된 값을 포함하는 구조체입니다.
예외
설명
이 메서드는 Parse 선행 또는 후행 공백 문자를 input 잘라내고 나머지 문자를 input 값으로 Guid 변환합니다. 이 메서드는 다음 표와 같이 메서드에서 생성된 ToString 5가지 형식 중 어느 것을 나타내는 문자 범위를 변환할 수 있습니다.
| 지정자 | Description | 포맷 |
|---|---|---|
N |
16진수 32자리 | 00000000000000000000000000000000 |
D |
하이픈으로 구분된 32자리 16진수 | 00000000-0000-0000-0000-000000000000 |
B |
하이픈으로 구분된 32개의 16진수 숫자(중괄호로 묶임) | {00000000-0000-0000-0000-000000000000} |
P |
하이픈으로 구분된 16진수 32자리, 괄호로 묶인 숫자 | (00000000-0000-0000-0000-000000000000) |
X |
중괄호로 묶인 4개의 16진수 값입니다. 여기서 네 번째 값은 중괄호로 묶인 8개의 16진수 값의 하위 집합입니다. | {0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} |
메서드는 문자열을 FormatException 성공적으로 구문 분석할 수 없는 경우 throw합니다. 이러한 상황이 발생할 수 있는 몇 가지 이유는 다음과 같습니다.
input에는 16진수 문자 집합에 속하지 않는 문자가 포함됩니다.input문자가 너무 많거나 너무 적습니다.input가 메서드에서 인식하고 ToString 이전 표에 나열된 형식 중 하나가 아닌 경우
예외를 TryParse 처리하지 않고도 실패한 구문 분석 작업을 catch하려면 이 메서드를 사용합니다.
적용 대상
Parse(ReadOnlySpan<Byte>)
- Source:
- Guid.cs
- Source:
- Guid.cs
public:
static Guid Parse(ReadOnlySpan<System::Byte> utf8Text);
public static Guid Parse(ReadOnlySpan<byte> utf8Text);
static member Parse : ReadOnlySpan<byte> -> Guid
Public Shared Function Parse (utf8Text As ReadOnlySpan(Of Byte)) As Guid
매개 변수
- utf8Text
- ReadOnlySpan<Byte>
반품
적용 대상
Parse(String)
- Source:
- Guid.cs
- Source:
- Guid.cs
- Source:
- Guid.cs
- Source:
- Guid.cs
- Source:
- Guid.cs
GUID의 문자열 표현을 해당하는 Guid 구조체로 변환합니다.
public:
static Guid Parse(System::String ^ input);
public static Guid Parse(string input);
static member Parse : string -> Guid
Public Shared Function Parse (input As String) As Guid
매개 변수
- input
- String
변환할 문자열입니다.
반품
구문 분석된 값을 포함하는 구조체입니다.
예외
input은 null입니다.
input 가 인식된 형식이 아닌 경우
예제
다음 예제에서는 새 GUID를 만들고, "B", "D" 및 "X" 형식 지정자를 사용하여 메서드를 호출 ToString(String) 하여 세 개의 별도 문자열 표현으로 변환한 다음, 메서드를 호출 Parse 하여 문자열을 다시 값으로 Guid 변환합니다.
var 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)
{
try
{
Guid newGuid = Guid.Parse(stringGuid);
Console.WriteLine($"Converted {stringGuid} to a Guid");
}
catch (ArgumentNullException)
{
Console.WriteLine("The string to be parsed is null.");
}
catch (FormatException)
{
Console.WriteLine($"Bad format: {stringGuid}");
}
}
// 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
try
let newGuid = Guid.Parse stringGuid
printfn $"Converted {stringGuid} to a Guid"
with
| :? ArgumentNullException ->
printfn "The string to be parsed is null."
| :? FormatException ->
printfn $"Bad format: {stringGuid}"
// 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.
For Each stringGuid In stringGuids
Try
Dim newGuid As Guid = Guid.Parse(stringGuid)
Console.WriteLine("Converted {0} to a Guid", stringGuid)
Catch e As ArgumentNullException
Console.WriteLine("The string to be parsed is null.")
Catch e As FormatException
Console.WriteLine("Bad format: {0}", stringGuid)
End Try
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
설명
메서드는 Parse 선행 또는 후행 공백 input 을 잘라내고 GUID의 문자열 표현을 값으로 Guid 변환합니다. 이 메서드는 다음 표와 같이 메서드 및 ToString(String) 메서드에서 생성된 ToString(String, IFormatProvider) 5가지 형식 중 하나로 문자열을 변환할 수 있습니다.
| 지정자 | Description | 포맷 |
|---|---|---|
N |
16진수 32자리 | 00000000000000000000000000000000 |
D |
하이픈으로 구분된 32자리 16진수 | 00000000-0000-0000-0000-000000000000 |
B |
하이픈으로 구분된 32개의 16진수 숫자(중괄호로 묶임) | {00000000-0000-0000-0000-000000000000} |
P |
하이픈으로 구분된 16진수 32자리, 괄호로 묶인 숫자 | (00000000-0000-0000-0000-000000000000) |
X |
중괄호로 묶인 4개의 16진수 값입니다. 여기서 네 번째 값은 중괄호로 묶인 8개의 16진수 값의 하위 집합입니다. | {0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} |
메서드는 문자열을 FormatException 성공적으로 구문 분석할 수 없는 경우 throw합니다. 이러한 상황이 발생할 수 있는 몇 가지 이유는 다음과 같습니다.
input에는 16진수 문자 집합에 속하지 않는 문자가 포함됩니다.input문자가 너무 많거나 너무 적습니다.input가 메서드에서 인식하고 ToString 이전 표에 나열된 형식 중 하나가 아닌 경우
예외를 TryParse 처리하지 않고도 실패한 구문 분석 작업을 catch하려면 이 메서드를 사용합니다.