I have two classes xCustomer and xProduct
Case Tables.xCustomer
Dim Count As Integer = (From t In New XPQuery(Of xCustomer)(DefaultSession) Select t.CustomerID).Count
Return Count + 1
Case Tables.xProduct
Dim Count As Integer = (From t In New XPQuery(Of xProduct)(DefaultSession) Select t.ProductID).Count
Return Count + 1
How can i simplify the above statements, lets say by using a string to class conversion?
For example i would like to use something like
Dim Test as object
Test = ReturnClassOfString(“xCustomer”)
Perhaps using reflection? This should help you get started with reflection in general:
http://msdn.microsoft.com/en-us/magazine/cc163750.aspx
This should help you with your actual question: http://wiki.lessthandot.com/index.php/VB.Net:_Create_an_instance_of_class_from_a_string_using_reflection