【发布时间】:2019-02-20 10:14:41
【问题描述】:
这段代码如何翻译成C#,具体来说sprintf如何在C#中实现?
string output = "The user %s logged in";
string loggedIn = "is";
string loggedOut = "isn't";
if (TheUser.CheckStatus())
{
output = sprintf(output, loggedIn);
}
else
{
output = sprintf(output, loggedOut);
}
return output;
如果TheUser.CheckStatus() 是false,我期待看到"The user isn't logged in"。
【问题讨论】: