I have a test CustomerService class that looks like
Now, nevermind the DAO class, let's go to Customer classCode:public class CustomerService : WebService { public CustomerService() { } [WebMethod] public string Status() { string s = string.Format("Time: {0}", DateTime.Now); return s; } [WebMethod] public List<Customer> ListCustomers() { return new CustomerDao().FindAll(); } }
Now, the Name isCode:public class Customer { int number; Name name = new Name(); public Name Name { get { return name; } set { name = value; } } public int Number { get { return number; } set { number = value; } } public Customer() { } }
Using wsdl.exe, I am able to get the CustomerService.cs but NO ToString() method on the Name class. I need this so that I can justCode:public class Name { string lastName; string firstName; string middleName; public string MiddleName { get { return middleName; } set { middleName = value; } } public string FirstName { get { return firstName; } set { firstName = value; } } public string LastName { get { return lastName; } set { lastName = value; } } public Name() { } public Name(string lastName, string firstName, string middleName) { this.lastName = lastName; this.firstName = firstName; this.middleName = middleName; } public override string ToString() { return string.Format("{0}, {1} {2}", lastName, firstName, middleName); } }
I know I'm missing something. Anyone has the kind heart to help me out? Thanks!Code:[Test] public void TestMethod() { foreach (Customer c in new CustomerService().ListCustomers()) { Console.WriteLine(c.Name.ToString()); } }




Reply With Quote