gpt4 book ai didi

c# - 在 Uri TryCreate 完美运行时使用 Uri IsWellFormedUriString

转载 作者:太空狗 更新时间:2023-10-29 23:15:41 25 4
gpt4 key购买 nike

我正在使用代码:

Uri.TryCreate(sURL, UriKind.Absolute, out URI)

效果很好。

我需要调用 Uri.IsWellFormedUriString(sURL, UriKind.Absolute) 吗?我的意思是我想知道当 Uri.TryCreate 完美运行时 Uri.IsWellFormedUriString 有什么用?

最佳答案

Uri.IsWellFormedUriString 在内部调用 TryCreate 以及调用 Uri.IsWellFormedOriginalString因此结果可能与简单地调用 TryCreate 不同。

来自 ILSpy

public static bool IsWellFormedUriString(string uriString, UriKind uriKind)
{
Uri uri;
return Uri.TryCreate(uriString, uriKind, out uri) && uri.IsWellFormedOriginalString();
}

来自 MSDN

[Uri.IsWellFormedOriginalString] indicates whether the string used to construct this Uri was well-formed and is not required to be further escaped.

关于c# - 在 Uri TryCreate 完美运行时使用 Uri IsWellFormedUriString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17277413/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com