IsValueType

  • Thread starter Thread starter INeedADip
  • Start date Start date
I

INeedADip

What I am trying to do is loop through all my session variables and log them
if there is an exception.
I want to loop through and, if they're a value type, I want to add them to a
NamedValueCollection and log them.

How can I loop through and say

for(int x=0; x<Session.Keys.Count;x++)
{
if(Session.Item[Session.Keys.Item[x]] "is a value type (int, bool, or
even string)")
{ nv.add(Session.Keys.Item[x], Session.Item[Session.Keys.Item[x]]) }
}

I tried to shorten it up...but I think you'll get the jist of it.
Any suggestions?
 
INeedADip said:
What I am trying to do is loop through all my session variables and log them
if there is an exception.
I want to loop through and, if they're a value type, I want to add them to a
NamedValueCollection and log them.

How can I loop through and say

for(int x=0; x<Session.Keys.Count;x++)
{
if(Session.Item[Session.Keys.Item[x]] "is a value type (int, bool, or
even string)")
{ nv.add(Session.Keys.Item[x], Session.Item[Session.Keys.Item[x]]) }
}

I tried to shorten it up...but I think you'll get the jist of it.
Any suggestions?

I see you've got your solution, but another thing you could do is call
GetType() and then IsValueType.

Note that string *isnt'* a value type, by the way.
 
Back
Top