all groups > dotnet clr > august 2006 >
You're in the

dotnet clr

group:

Reflection, how to tell the complexity of the type???


Reflection, how to tell the complexity of the type??? Sam Carleton
8/8/2006 3:42:43 PM
dotnet clr:
I am writing a debugging class that will drill into a class and dump
all the fields in the class. How can I determine if a field is an
object that can have it's own fields or a simple type like an int or
double?

Sam
Re: Reflection, how to tell the complexity of the type??? Phill W.
8/9/2006 12:29:48 PM
[quoted text, click to view]

Use TypeOf to determine the Type of each thing you're looking at, then
act accordingly.

If these are your own classes that you're pulling apart, you might
consider defining an extra Interface that provides all of this for a
given class, something like (crudely)

Interface IDump
Sub DumpContent(ByVal tw as TextWriter)
End Interface

Class SomethingToInvestigate
Implements IDump

Private Sub Splurge(ByVal tw as TextWriter) _
Implements IDump.DumpContent
' This routine "knows" all about the class and can list
' out the important bits. Reflection can only given you
' everything, which might easily be overkill.
End Sub

End Class

HTH,
Re: Reflection, how to tell the complexity of the type??? Larry Lard
8/9/2006 3:43:38 PM
[quoted text, click to view]

'a simple type like' isn't enough for us to be sure what you mean, but
you *might* just want Type.IsValueType.

--
Larry Lard
larrylard@googlemail.com
The address is real, but unread - please reply to the group
Re: Reflection, how to tell the complexity of the type??? radical NO[at]SPAM gmail.com
8/18/2006 5:12:50 AM
Hi,

[quoted text, click to view]

Type.IsPrimitive

[quoted text, click to view]

A struct is also a valuetype, which can have its own fields etc, so it
won't help.

-Ankit
AddThis Social Bookmark Button