且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

修剪开始

更新时间:2023-11-18 08:35:34

1)我不认为你根本不需要TrimStart()。因为TrimStart()正在做的就是消除前导空格,但是使用Contains("A")你正在寻找大写字母A.因此,在你的单词前面有多少空白并不重要。
我会废弃TrimStart()。Conains()构造并使用StartsWith()代替。

1) I don't think you'll need TrimStart() at all. Because all that TrimStart() is doing is to eliminate leading whitespaces, but with Contains("A") you're looking for capital A. So, it doesn't matter how much whitespaces come in front of your word. I would scrap that TrimStart().Conains() construct and use StartsWith() instead.

2)在你的上一个查询中,你正在寻找"ostaleRijeci"。 ,根据G * - 翻译表示"其他"。所以,我会检查既不是A,B和C的一部分的单词(=不包含())。

2) In your last query, you're looking for "ostaleRijeci", that as per G*-Translate means "others". So, I would check for words that are neither part of A, B and C (= not Contains()).

也许,你可以做某事。像这样:

Maybe, you could do sth. like this:

List<string> names = new List<string>() { "Anton", "Alois", "Axel", "Bertold", "Bart", "Bernd", "Detlef", "Dagobert", "Donald", "Rudolf", "Herbert" };
var A = names.Where(x => x.StartsWith("A"))
    .Select(x => x).ToList();
var B = names.Where(x => x.StartsWith("B"))
    .Select(x => x).ToList();
var D = names.Where(x => x.StartsWith("D"))
    .Select(x => x).ToList();
var others = names.Where(x => !A.Contains(x))
    .Where(x => !B.Contains(x))
    .Where(x => !D.Contains(x))
    .Select(x => x).ToList();

A.ForEach(Console.WriteLine);
Console.WriteLine();
B.ForEach(Console.WriteLine);
Console.WriteLine();
D.ForEach(Console.WriteLine);
Console.WriteLine();
others.ForEach(Console.WriteLine);




wizend 

 


wizend