Solved

Type.GetType problem

Posted on 2008-10-29
2
662 Views
Last Modified: 2013-11-07
Hi!

How do I get the type of partial class?

Namespace Test
   Public Partial Class c1
        Public Partial Class c2
              Public Sub Test
              End Sub
        End Class
   End Class
End Namespace

Dim classType as Type = Type.GetType(Test.c1.c2,false,false)

This will return null!
0
Comment
Question by:AWestEng
  • 2
2 Comments
 
LVL 38

Expert Comment

by:PaulHews
ID: 22835825
Just use the GetType operator:

Dim classType As Type = GetType(Test.c1.c2)
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 500 total points
ID: 22835914
Type.GetType acts on a string name, but you are passing a class type instead of an string.  You can also use:

Dim classType As Type = Type.GetType("WindowsApplication1.Test.c1+c2", False, False)

Note that WindowsApplication1 is the root namespace.  You would have to change it for your program.  The + precedes a nested class

http://msdn.microsoft.com/en-us/library/a87che9d.aspx
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that undeā€¦
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display

726 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