• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1746
  • Last Modified:

GetType Compare

How might I write this so that I can compare the GetType directly to the Type without converting to string?

If varNode.ChildNodes(0).GetType.ToString = "System.Xml.XmlText" then

0
codequest
Asked:
codequest
2 Solutions
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Try...

        If TypeOf varNode.ChildNodes(0) Is System.Xml.XmlText Then

        End If
0
 
iHadiCommented:
Hi  codequest
This is a reliable way to compare types:

        if varNode.ChildNodes(0).GetType.Equals(GetType(System.Xml.XmlText)) then

        ' ****OR***

        Dim Type1 As Type
        Dim Type2 As Type
        Type1 = varNode.ChildNodes(0).GetType
        Type2 = GetType(System.Xml.XmlText)

        If Type1.Equals(Type2) Then
0
 
codequestAuthor Commented:
Works.  Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now