獲取一些url參數後,我想稍後在我的c#代碼中使用它們,但格式略有不同。c#如何請求URL參數並更改字符
的「http://example/myexample.aspx與會者= john.sam &音箱= fred.will.tony.amy.al」
我能夠得到的值作爲一個字符串在其現有的使用格式: C#代碼
public string myattendees()
{
string attendees;
attendees = Request.QueryString["attendees"];
return attendees;
}
public string myspeakers()
{
string speakers;
speakers = Request.QueryString["speakers"];
return speakers;
}
myattendees返回
john.sam
和(與沒有引號週期分隔) myspeakers回報(分離與沒有引號週期)
fred.will.tony.amy.al
但我想將其轉換所以它會返回一個字符串,像這樣用逗號分隔和單引號值。
'約翰', 'SAM'
和
'弗雷德', '將', '託尼', '艾米', '人'
什麼將是最好的方式在C#中做到這一點?使用NameValueCollection?
*爲清晰起見編輯問題的細節。 *編輯 - 修正了拼寫錯誤。
如果你知道他們總是點分隔的,只是'split'他們成陣列。 – 2012-07-15 14:06:48