GetType Compare

Posted on 2006-06-01
Last Modified: 2008-01-16
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

Question by:codequest
    LVL 85

    Accepted Solution


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

            End If
    LVL 13

    Assisted Solution

    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
    LVL 2

    Author Comment

    Works.  Thanks!

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now