Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1743
  • 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

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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