After getting some url parameters, I would like to use them later in my c# code, but in a slightly different format.
"http://example/myexample.aspx?attendees=john.sam&speakers=fred.will.tony.amy.al"
I am able to get the values as a string in their existing format using: c# code
public string myattendees()
{
string attendees;
attendees = Request.QueryString["attendees"];
return attendees;
}
public string myspeakers()
{
string speakers;
speakers = Request.QueryString["speakers"];
return speakers;
}
myattendees returns (separated with periods with no quotes)
john.sam
and myspeakers returns (separated with periods with no quotes)
fred.will.tony.amy.al
But I would like to convert it so it would return a string like these with comma separated and single quoted values.
'john' , 'sam'
and
'fred' , 'will' , 'tony' , 'amy' , 'al'
What would be the best way to do this in c#? Use a NameValueCollection?
*question edited for clarity on details. *edit - fixed spelling error.
This code will give you an array of strings acquired by splitting on dots:
string[] speakers;
if (Request.QueryString["speakers"] == null)
speakers = new string[0];
else
speakers = Request.QueryString["speakers"].Split('.');