如何使用.net将查询字符串值存储在数组中

时间:2012-08-09 12:52:12

标签: arrays string vb.net-2010 querystringparameter

使用当前页面aspx作为url.am在我的页面中传递查询字符串url.my代码用于拆分查询字符串并在屏幕上写入。我在页面加载方法中编写代码。

my code
------
 Dim strarr() As String
    Dim key
    For Each key In Request.QueryString
        Response.Write(key & ": " & Request.QueryString(key) & "<BR>")

    Next

output
------
http://localhost:54592/vicidial_project/Default.aspx?a=1&b=2(in run time am passing query string to that url)

a:1
b:2

the query string values are displayed in the screen like above.

my question
-----------
i want to store that query string value into an array . am using the code like this

code
-----
 Dim strarr() As String
    Dim key
    For Each key In Request.QueryString
        Response.Write(key & ": " & Request.QueryString(key) & "<BR>")
       strarr = key & ": " & Request.QueryString(key)

    Next

error
-----
 am getting error in this line
 strarr = key & ": " & Request.QueryString(key)

1 个答案:

答案 0 :(得分:0)

为什么不将密钥声明为字符串?你可以这样做:

For Each key as String in Request.QueryString
   ...
Next