📅  最后修改于: 2022-03-11 14:48:57.331000             🧑  作者: Mango
var uri = new Uri(myString);
var noLastSegment = string.Format("{0}://{1}", uri.Scheme, uri.Authority);
for(int i = 0; i < uri.Segments.Length - 1; i++)
{
noLastSegment += uri.Segments[i];
}
noLastSegment = noLastSegment.Trim("/".ToCharArray()); // remove trailing `/`