【发布时间】:2020-04-19 01:50:03
【问题描述】:
我目前有以下代码:
foreach (string s in lstSearchStrings.Items)
{
int cnt = CountSubStrings(fileText, s);
if (cnt > 0)
{
string cs = cnt.ToString().PadLeft(5);
lstCounts.Items.Add(cs);
counter++;
}
else break;
}
我需要暂时大写 s 以便在已经大写的 fileText 字符串中查找它,但我不能,因为当我尝试这个时它会出错:
foreach (string s in lstSearchStrings.Items)
{
if (chkExactCase.Checked == false)
{
string us = s.ToUpper();
s = us;
}
int cnt = CountSubStrings(fileText, s);
if (cnt > 0)
{
string cs = cnt.ToString().PadLeft(5);
lstCounts.Items.Add(cs);
counter++;
}
else break;
}
任何帮助将不胜感激!
【问题讨论】:
-
I can't because it gives an error when I try this:总是说错误是什么。
标签: c# string foreach uppercase