小编chr*_*hrr的帖子

排序通用列表

我想按升序日期顺序对通用列表进行排序.(框架v2)

有什么建议?

谢谢

.net c# generics

9
推荐指数
3
解决办法
1万
查看次数

从字符串匹配的英语词典单词

我试图弄清楚从字典文件到给定字符串中识别英语单词的最佳匹配问题.

例如("lines"是字典单词列表):

string testStr = "cakeday";

for (int x= 0; x<= testStr.Length; x++)
{
  string test = testStr.Substring(x);

   if (test.Length > 0)
   {
      string test2 = testStr.Remove(counter);
      int count = (from w in lines where w.Equals(test) || w.Equals(test2) select w).Count();
      Console.WriteLine("Test: {0} / {1} : {2}", test, test2, count);
    }
}
Run Code Online (Sandbox Code Playgroud)

给出输出:

Test: cakeday /   : 0
Test: akeday / c  : 1
Test: keday / ca  : 0
Test: eday / cak  : 0
Test: day / cake  : …
Run Code Online (Sandbox Code Playgroud)

.net c# linq

5
推荐指数
1
解决办法
1896
查看次数

C#正则表达式(替换)

假设我有字符串:

10,11,12,13,14,ABC,DEF,GHI,66

我希望运行一个正则表达式反对它只返回0-9和","字符,基本上剥离其他任何东西.

我看过Regex.Replace,但有些东西不太合适.我的代码如下:

Regex reg = new Regex(@"[0-9,]+");
string input = reg.Replace(input, delegate(Match m)
                {
                    return String.Empty;
                });
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

c# regex

3
推荐指数
1
解决办法
7024
查看次数

标签 统计

c# ×3

.net ×2

generics ×1

linq ×1

regex ×1