字符串中字符统计问题
有N个字符串(例如1000个),如何统计同时含有某几个字符的字符串个数?例如:有5个字符串:abcdefg,cdaflk,agfkpq,fdgackk,jlkart,统计含有a,c,d的个数为3个。
string[] strList = {"abcdefg","cdaflk","agfkpq","fdgackk","jlkart"}; var q = from t1 in strList where t1.Contains("a") && t1.Contains("c") && t1.Contains("d") select t1; Console.Write(q.Count().ToString());
string[] strList = {"abcdefg","cdaflk","agfkpq","fdgackk","jlkart"}; var q = from t1 in strList where t1.Contains("a") || t1.Contains("c") || t1.Contains("d") select t1; Console.Write(q.Count().ToString());