Попробуйте GroupBy
( Linq ), например:
using System.Linq;
...
var SPFK_List = new List<string>() {
"one", "one", "one",
"two", "two",
"three", "three", "three"
};
// {3, 2, 3}
int[] counts = SPFK_List
.GroupBy(item => item)
.Select(group => group.Count())
.ToArray();
Или (добавьте Where
, если хотите считать только некоторые элементы)
// {{"one", 3}, {"two", 2}, {"three", 3}}
Dictionary<string, int> counts = SPFK_List
//.Where(item => item == "one" || item == "two")
.GroupBy(item => item)
.ToDictionary(group => group.Key, group => group.Count());
Inputs.ones.Value = counts.TryGetValue("one", out int count) ? count : 0;