views:

153

answers:

1

For example i got a class and its got its own properties and i am passing the name of the class and the name of the property to be called to a function

Say for example exp is the variable which i am passing which contains a value = "ClassA,Property1"

           Function Property2BCalled(byval exp as String)

            dim classname = split(exp,",")(0)
            dim propertyname=split(exp,",")(1)
            dim value= classname.propertyname

           End Function

I wanna do something like that,given above.

A: 

You could use reflection to perform this task. Bear in mind that reflection is Slow but it could be done. You would enumerate the classes available in your assembly, when you find a name match, then you enumerate the properties and then Invoke the method/properties etc.

But it might be better to define an Interface and then have a common signature that your project can communicate with, then all you need is a Factory pumping out the appropriate instance of the class that is coming in your Data.

Paul Farry
How do i get the type for the class for which i am sending the name of the class string? dim a as string= GetType(className).getProperty("").Getvalue("",Nothing).Tostring() would be gimme the type but im sending the name of the class as string as well
For Each t As Type In [Assembly].GetExecutingAssembly.GetTypes() If t.Name = "yourclassname" Thenend ifnext
Paul Farry