What's the difference between Uri.ToString() and Uri.AbsoluteUri?

前端 未结 5 916
情书的邮戳
情书的邮戳 2020-12-14 13:43

As a comment to an Azure question just now, @smarx noted

I think it\'s generally better to do blob.Uri.AbsoluteUri than blob.Uri.ToString().

5条回答
  •  情话喂你
    2020-12-14 14:21

    Why not check and use the correct one?

    string GetUrl(Uri uri) => uri?.IsAbsoluteUri == true ? uri?.AbsoluteUri : uri?.ToString();
    

提交回复
热议问题