473,320 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 3023
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ole Andre Karlson | last post by:
hi Still struggeling with Gyro... :) how can this be correct? T t = null; gives a compile error because the compiler thinks T is a value type.
14
by: tshad | last post by:
I have people telling me that I should set up objects for my tables, but I am finding the Null problem makes that difficult. It isn't a big problem if you are not updating the table, but if you...
2
by: Brian Linden | last post by:
Apparently I don't understand the IsValueType property.... I am looping through the Cache and trying to determine if the object derives from System.ValueType: Dim CacheEnum As...
10
by: Qwert | last post by:
Hello, is it correct that if a type (System.Type) is a value (.IsValueType=True) and not primitive (.IsPrimitive=False), that type is a structure? Thanks.
3
by: INeedADip | last post by:
What I am trying to do is a sort of Recursion "search" or listing of all the properties of a type. If I have a class that looks like: public class MyClass { private string _name = "jeff";...
10
by: Pierre Arnaud | last post by:
I'd like to provide two generic methods with the same name and the same arguments, but with different constraints, such as: void Explore<T>(T a, T b) where T : struct { } void Explore<T>(T a, T...
6
by: tommaso.gastaldi | last post by:
Hi, does anybody know a speedy analog of IsNumeric() to check for strings/chars. I would like to check if an Object can be treated as a string before using a Cstr(), clearly avoiding the time...
4
by: Brette.Net | last post by:
Hello All, I was doing a little messing around with some type conversion they other day. Code is below. struct ValueStruct { int a; public ValueStruct(int inA)
2
by: jon.rea | last post by:
Please tell me there is a better way :-D .... public static bool IsNullableType(Type paramType) { return paramType.IsGenericType && paramType.GetGenericTypeDefinition() == typeof...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.