We could really use some help with a hashset output question. We have the HashSet web method working perfectly with HashSet except for one thing. The output is a webservice and looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://localhost/webservices">
<string>201210XXXX</string>
<string>201211XXXX</string>
</ArrayOfString>
That’s perfect except the customer requested the output of the lines of strings be lines of “TN” and “/TN” tags instead of the string tags. Figured this should be pretty easy and added my extra class but I cannot figure out how to do this
HashSet<TN>;
We built the webmethod
[WebMethod]
public HashSet<string> GetFoneLines()
{
HashSet<string> hs = new HashSet<string>();
DataTable dt = new dal().GetPhoneLines();
foreach (DataRow dr in dt.Rows)
{
hs.Add(dr[0].ToString());
}
return hs;
}
and tried to extend the string class. Learning String is sealed, we just attempted to create our own class
public class TN
{
public string tnumber;
}
This must be simple but after 48 hours of pounding out code I cant see how to create a Hash of TN’s instead of a Hash of strings.
Try to decorate your class with custom XML serialization attributes like so:
See MSDN.