views:

184

answers:

1

I have implemented a ToString() override method for my class in my Webservice and I return a List<myObject>() in a function in a consumer. If I do a .ToString() it returns object Type. How do I tackle this in C#?

Thanks.

+2  A: 

When passing objects back & forth in a webservice, it's just passing an XML representations of the public properties of that object. Any methods, overridden or not, do not come with it.

I would recommend making a StringRepresentation property that calls ToString()

public string StringRepresentation
{
    get { return this.ToString(); }
    set { /* Do Nothing, but there has to be a set */ }
}
Matt Grande
May I knwo why this happens.
Greens
Basically, you can only pass strings over a webservice. So, it compiles your object into XML and passes the XML instead of the actual object.
Matt Grande
Thanks.Makes sense
Greens