Question

What does it mean to "return the client?"

My teacher asked in an assignment to write a method that will return the date and the client. Here is her exact wording:

" You should also override the ToString method, to return the date and the client. (DateTime has a reasonable ToString method defined. Use it.) I found using "\t" (the tab symbol) helpful in lining up columns. "

I'm not sure what she is asking when she says to return the client. I understand how to return the date. Thank you.

Was it helpful?

Solution

Maybe the client is the object you use ToString on. Like intSomeInteger.ToString

OTHER TIPS

Maybe you should ask her.

In the working world you'll want to get as much clarification from your customer on the deliverables as required.

maybe she meant to the client (the caller of the function ?)

if you have other data in your object, maybe she wants you to return it in a certain way (and not the default ToString() behaviour ?

Might be a typo -- maybe instead of "return the date and the client" she meant "return the date to the client"?

My guess is you have a class containing a DateTime and a Client, something like:

class MyClass
{
   public DateTime Date {get; set;}
   public Client MyClient {get; set;}
}

The task would be then to override MyClass.ToString() and probably Client.ToString() to something like:

class Client
{
   public string Name {get; set;}
   public override ToString()
   { 
    return Name;
   }
}

class MyClass
{
   public DateTime Date {get; set;}
   public Client MyClient {get; set;}
   public override ToString()
   { 
    return string.Format("Client: {0}; Date: {1}", MyClient, Date);
   }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top