完全披露:这是一项家庭作业.我不是在寻找讲义,只是指导,因为我被卡住了.
我试图将一个月和一天(都是int)转换为"月/日"的字符串表示.这就是我到目前为止所拥有的.
我无法弄清楚的是如何在月和日之间以"/"返回日期.
public string toString()
{
string month = myMonth.ToString();
string day = myDay.ToString();
string date = month "/" day; // I know this won't work. I just wanted to give a visual of what I want the final result to look like.
/// so today would be ' 11/11 ' tomorrow ' 11/12 '
return date;
}
Run Code Online (Sandbox Code Playgroud)
注意:此方法不会打印仅创建它的结果.
Mihai是正确的,但你也可以: -
string data = string.Format("{0}/{1}",month,day);
Run Code Online (Sandbox Code Playgroud)
在我看来哪个看起来更好
| 归档时间: |
|
| 查看次数: |
73 次 |
| 最近记录: |