I'm trying to convert a HttpRequest.QueryString to object[] with this extension method:
public static object[] ToObjectArray(this NameValueCollection nvc)
{
var ret = new object[nvc.Count];
var count = 0;
foreach (string s in nvc)
{
var strings = nvc.GetValues(s);
if (strings != null)
{
foreach (string v in strings)
{
ret[count] = new { s = v };
}
}
count++;
}
return ret;
}
var args = request.QueryString.ToObjectArray();
I think that I'm pretty close, but I'm getting the following exception:
Object of type '<>f__AnonymousType0`1[System.String]'
cannot be converted to type 'System.Object[]'.
What did I miss?