【问题标题】:how to extract the required value from the url in C#如何从 C# 中的 url 中提取所需的值
【发布时间】:2012-07-26 06:09:31
【问题描述】:

我需要从当前 url 中提取值。 例如,如果我的网址是

http://stackoverflow.com/questions/ask

我需要将结果存储在相对于“/”拆分的数组中。

我的数组应该包含 [questions,ask]

【问题讨论】:

  • 你试过字符串Split方法吗?

标签: c# query-string


【解决方案1】:

您可以使用Uri 类:

var uri = new Uri("http://stackoverflow.com/questions/ask");

现在查看uri.Segments 属性,它表示包含您要查找的内容的字符串数组。

【讨论】:

    【解决方案2】:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多