views:

340

answers:

1

To me they are very similar structures. I was hoping there was a way to cast or convert one to the other easily.

I'm using reflection to do some magic. I've chosen the path to use parametrized constructors to create some user selected objects which they fill in values for the parameters using a UI.

The problem is one of the objects takes in a structure as a param and I can't get at the structures properties as parameter infos just property infos.

But I don't want to just reproduce the parameter info code I have now for property infos. It be nice if I could pass in a property info as a parameter info. Everything is really similar except for some names of some properties; ParameterType as opposed to PropertyType and what not.

I may have to do my own conversion or write my own class that houses the properties that I need and just use that custom object instead. Cheers.

+1  A: 

No, there is not.

Those two classes represent two very different concepts.

A property is an attribute on an Type. The PropertyInfo class will allow you to set or get the value and will tell you additional information about the Property.

A parameter is an attribute of a method signature (an accessor on a type can have a parameter as well). The ParameterInfo class represents this concept and can tell you the Type of the parameter, the position in the method signature, whether it is an out or ref parameter, etc. See: MSDN doc. A ParameterInfo is not directly associated to a Type.

siz