Code: Select all
public int GetCount(char c)
{
return Items.Count(x => x.Contains(c));
}
Ich war jedoch neugierig, ob ein [ThreadStatic]-Feld und eine statische lokale Funktion verwendet werden könnten, um die Erstellung eines Abschlusses geschickt zu vermeiden:
Code: Select all
[ThreadStatic]
private static char _c;
public int GetCount(char c)
{
_c = c;
return Items.Count(func);
static bool func(string x) => x.Contains(_c);
}
Mobile version