c# how to request url parameters and change char

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.

Answers


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('.');

try this:

public class MyClassGetQueryString
{

    private const string Attendees = "attendees";
    private const string Speakers = "speakers";

    public string MyAttendees()
    {
        return Request.QueryString[MyClassGetQueryString.Attendees] ?? string.Empty;
    }

    public string MySpeakers()
    {
        return Request.QueryString[MyClassGetQueryString.Speakers] ?? string.Empty;
    }

    public string[] MyAttendeesParts()
    {
        return this.MyAttendees().Split('.');
    } 

    public string[] MySpeakersParts()
    {
        return this.MySpeakers().Split('.');
    } 
}

Need Your Help

svg / raphael: scale path + get resulting/computed path

svg raphael scaling

Let's say I have this svg path (some icon) as a string:

why does async call LiveConnectClient.GetAsync block executing thread?

c# windows-store-apps async-await monogame live-connect-sdk

I have Windows Store MonoGame (based on XAML MonoGame template in Visual Studio 2012) app.