<?xml version=\"1.0\" encoding=\"utf-16\"?> <ArrayOfContact xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"> <Contact> <Name>Fred</Name> <Age>33</Age> </Contact> <Contact> <Name>Joe</Name> <Age>66</Age> </Contact> </ArrayOfContact>Bear in mind this was only a suggestion. VFP Cursors and .NET Datatables would also work - but my approach would be more lightweight...
public static class Helper >> { >> public static List<T> RetrieveList<T>(string s) >> { >> XmlSerializer xs = new XmlSerializer(typeof(List<T>)); >> System.Xml.XmlReader v = System.Xml.XmlReader.Create(new StringReader(s)); >> return (List<T>)xs.Deserialize(v); >> } >> >> public static string ConvertToXML<T>(List<T> list) >> { >> XmlSerializer xs = new XmlSerializer(typeof(List<T>)); >> StringWriter sw = new StringWriter(); >> xs.Serialize(sw, list); >> return sw.ToString(); >> } >> }Example use:
List<Contact> list = new List<Contact>(); >> list.Add(new Contact { Name = "Fred", Age = 33 }); >> list.Add(new Contact { Name = "Joe", Age = 66 }); >> >> string xmlString = Helper.ConvertToXML<Contact>(list); >> //(Examine this string to determine what VFP should create) >> >> List<Contact> retrievedList = Helper.RetrieveList<Contact>(xmlString);>>>Thanks for the tip. In the meantime, I've decided to switch to sending XML and convert that to a DataTable that I can iterate through. That seems to do the trick for now.
>>>>>public void AddClientsToList(Contact[] contacts, string listName) >>>>>>>>>>
public class MyDll >>>> { >>>> Dictionary<string, List<Contact>> lists = new Dictionary<string, List<Contact>>(); >>>> public Contact GetNewContact() { return new Contact();} >>>> >>>> public void AddClientToList(Contact contact,string listName) >>>> { >>>> if (!lists.Keys.Contains(listName)) >>>> lists.Add(listName, new List<Contact>()); >>>> lists[listName].Add(contact); >>>> } >>>> }