Get an objects value as a string



I am looking for a generic way to see if an object supports the ToString
method, then invoke that method to return the results of that generic
objects ToString method.

I have a generic exception class and one of the arguments I pass in is a
generic object type.

In this exception class I would like to be able to provide a ToString method
where this value is shown, but the exception class cannot know anything
about the object that is getting passed in. I want to keep it as generic as
possible that way.

I have been poking around with InvokeMember and just can't seem to get it
right.

Can anyone point me in the right direction?

--
Raymond R Cassick
CEO / CSA
Enterprocity Inc.
www.enterprocity.com
3380 Sheridan Drive, #143
Amherst, NY 14227
V: 716-316-7537
Blog: http://spaces.msn.com/members/rcassick/


.



Relevant Pages

  • Re: Making static class ToString() not possible, why?
    ... I don't want to inherit anything. ... invoked when you append "it" to a string, but with a static class there ... ToString() to easily print out all of its data. ... how can object.ToString be invoke on a static class? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: weird runtime error
    ... System.out.printlnis to invoke the .toString() method on any objects ... The conceptually simplest fix would be to not pass an instance of ... Thakns a lot for the replies! ...
    (comp.lang.java.help)