An object that handles Name=Value pairs?

  • Thread starter Thread starter Bill Todd
  • Start date Start date
B

Bill Todd

Is there an object in the .NET framework that has methods for working
with Name=Value pairs such as those in a connection string?

What I am looking for is something similar to an ArrayList but with an
IndexOfName method that will find the first occurance of the value on
the left of the = sign and that also has a way to change the Value on
the right side.
 
Look at the NameValueCollection



int loop1, loop2;

NameValueCollection coll=Request.QueryString;

// Get names of all keys into a string array.

String[] arr1 = coll.AllKeys;

for (loop1 = 0; loop1 < arr1.Length; loop1++)

{

Response.Write("Key: " + arr1[loop1] + "<br>");

String[] arr2 = coll.GetValues(arr1[loop1]);

for (loop2 = 0; loop2 < arr2.Length; loop2++)

{

Response.Write("Value " + loop2 + ": " + arr2[loop2] +
"<br>");

}

}
 
Empire City said:
Look at the NameValueCollection

And if you only need a single value per name, just HashMap or
StringDictionary, depending on the exact needs.
 
Back
Top