Thanks for the reply. I should have explained it a bit better though.
I am trying to generalise how I do this so that the method for doing this
takes in 2 objects eg -
ApplyValues(object A, object B);
but the class containing this method does not care what the underlying type
of the objects are. So what I would really like to be able to do would be
to write something like:
Object.ApplyValues(object A, object B);
but I don't believe such a method exists.
If I wrote a method on each of my types that took another instance of that
type and set the values internally I'm not sure how I could cast the objects
to that type in order to call that method. Perhaps I need some kind of
interface which just contains an ApplyValues(method) implemented in my
custom types?
Thanks again,
Graham
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2***************@TK2MSFTNGP12.phx.gbl...
GM,
You don't have to use reflection. You should just have a method that
takes an instance of your type, and sets the values internally.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"GM" <ma*****@gaelquality.co.uk> wrote in message
news:Ok****************@tk2msftngp13.phx.gbl... Hi,
I have 2 objects A and B. I want to copy only the values of B across to
A without changing the reference of A. Is there a way to achieve this
without the use of reflection?
Cheers,
Graham