需要把一个arrayList传到session变量,如果session里已经有了一个arrayList,就需要把arrayList中的数据尾+到session里就可以,这就需要有一条判断SESSION变量是否为空的IF语句。如果用 if session("value") = null 的话,系统会提示Compiler Error Message: BC30822: 'null' is not declared. 'Null' constant is no longer supported; use 'System.DBNull' instead.Line 24:  if session("order_item") = null then如果用 if session("value") = system.dbnull 的话,系统会提示Compiler Error Message: BC30691: 'DBNull' is a type in 'System' and cannot be used as an expression.Line 24:  if session("order_item") = System.DBNull then 如果用 if session("value") = nothing 或者 if session("value") = "" 的话,系统会提示Exception Details: System.InvalidCastException: Operator is not valid for type 'ArrayList' and 'Nothing'.Line 24:  if session("order_item") = nothing then 如果用 if isdbnull(session("value")) then 的话,无论session变量里有没有值,返回结构都为false请问高手如何解决?

解决方案 »

  1.   

    if session("order_item") = nothing then '此行为判断条件,此处假设为=nothing
    arr = new arraylist
    else
    arr = session("order_item")
    end if
    arr.add(objOr)
    session("order_item") = arr这个是代码段
      

  2.   

    if session("order_item") is nothing then
    Response.write("空")
    else
    Response.write("session为"+session("order_item"))
    end if
      

  3.   

    if session("order_item") is nothing then
      

  4.   

    if session("order_item") is nothing then
      

  5.   

    vb的话是is nothing
    c#的话就是 ==null
      

  6.   

    vb: if session("order_item") is nothing then
    c# : if (session["order_item"]==null)
      

  7.   

    If Not Session("order_item") Is Nothing Then
                Dim value() As String = Session("order_item")
                Dim value1() As String            Dim i As Integer
                For i = 0 To arrayList.Length - 1
                    ReDim Preserve value(value.Length)
                    value(value.Length) = arrayList(i)
                Next        End If