开发者

What does it mean to return the client?

开发者 https://www.devze.com 2022-12-13 14:06 出处:网络
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:

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.


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 ?


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


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);
   }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消