Call a Method with parameters got from generic Method?

Sorry, I should have added that if I just do this: object Params = { Convert. ChangeType(call. ParValue, call.

ParType)} it works fine, but the whole point of the generic method in call object is to avoid the casting when being used.

Sorry, I should have added that if I just do this: object Params = { Convert. ChangeType(call. ParValue, call.

ParType)}; it works fine, but the whole point of the generic method in call object is to avoid the casting when being used.

You can't just cast a string ("1") to a decimal, and even if you could I doubt that the generic version would know about it... it would try to do a reference-preserving cast, where-as you'd need an operator conversion (they share syntax in C#, but are very different). So basically, I think Convert. ChangeType is your only sensible option here.

I do have some code that will allow you to use operator conversion via generics, but there is no operator conversion between string and decimal, so it wouldn't help.

If you're calling the method with reflection, that's going to effectively end up casting anyway. You don't have either the speed benefits or compile-time type safety benefits of generics here - I don't really think you're doing yourself any favours by using it. Generics are useful when you do know the type statically at compile-time, at least somewhere.

The fact that you've got a ParType property really goes against the point of generics.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions