471,599 Members | 931 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,599 software developers and data experts.

IsValueType

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?
Jan 12 '06 #1
2 2944
if( o is ValueType)......

ok....

Jan 12 '06 #2
INeedADip <IN*******@gmail.com> wrote:
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 12 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Ole Andre Karlson | last post: by
14 posts views Thread by tshad | last post: by
2 posts views Thread by Brian Linden | last post: by
10 posts views Thread by Qwert | last post: by
3 posts views Thread by INeedADip | last post: by
10 posts views Thread by Pierre Arnaud | last post: by
6 posts views Thread by tommaso.gastaldi | last post: by
4 posts views Thread by Brette.Net | last post: by
2 posts views Thread by jon.rea | last post: by
2 posts views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.