RadhaKrishnaKiJaya
asked on
Understand C# code
Hello Experts,
I am trying to understand the following line of code. Any idea what does it do? Thank you very much in advance.
Thank you
Request.QueryString.GetKey (0)
I am trying to understand the following line of code. Any idea what does it do? Thank you very much in advance.
Thank you
Request.QueryString.GetKey
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In your case, the GetKey returns the first key (which by the statement could be c, f, or z). From the posted code you only care about the key; e.g. -
http://www.somesite.com/somepage.aspx?c=4
Would cause the following in your logic:
http://www.somesite.com/somepage.aspx?c=4
Would cause the following in your logic:
switch(/* Request.QueryString.GetKey(0) gets replaced with*/ "c")
{
case "c":
// We end up here and perform any statements herein.
// In order to get the value associated with "c".
var value = Request.QueryString.Get("c")
// value = 4.
break;
case "f":
break;
case "z":
break;
default:
break;
}
-saige-
ASKER
I am trying to understand where those values "c", "f", "z" are coming from. Because I don't see anywhere any query is passed during the call. Also please tell me under what scenario it should be used. Sorry for the miscommunication. Thank you.
ASKER
Thank you it_saige. It worked.
ASKER
switch(Request.QueryString
{
case "c":
case "f":
case "z":
default:
}