//是否存在相同
string a = "1,1,1";
string[] str = a.Split(',');
if (str.Distinct().Count() == 1)
{
Console.WriteLine("1");
}
else
{
Console.WriteLine("n");
}
string[] str = a.Split(',');
if (str.Distinct().Count() == 1)
{
Console.WriteLine("1");
}
else
{
Console.WriteLine("n");
}
//是否全部相同
static void Main(string[] args)
{
string str = "信息技术,信息技术,信息技术";
bool bl = Check(str);
Console.Write(bl);
}
static bool Check(string str) {
bool b=true;
List<string> temp = str.Split(',').ToList();
string tempStr = temp[0];
foreach (var item in temp)
{
if (item != tempStr) {
b = false;
break;
}
}
return b;
}