简体   繁体   中英

ToString() in a Webservice Class

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.

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 */ }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM