【发布时间】:2013-07-07 04:30:27
【问题描述】:
我正在尝试使用条件字符串格式来显示找到或不这样的记录 “找到 10 行中的 5 行”
string msg = "{0:#;;} of {1:#;;} {2:rows;no rows;row} found";
return string.Format(msg, searchItems, totalItems, totalItems - 1);
在 totalItems 为 0 之前一切正常,因为我得到了这样的消息集。 “未找到行”(错误)
我想要这样的东西 “没有找到行”
searchItems = 0 ; totalItems = 0 ==> "no rows found"
searchItems = 1 ; totalItems = 1 ==> "1 row found"
searchItems = 2 ; totalItems = 5 ==> "2 of 5 rows found"
【问题讨论】:
标签: c# string conditional string.format