C# 两个字符串的比较
时间:2011-05-06 来源:shizhi57
string StrA = "ABCDE";
string StrB = "AE";
char[] ArryA = StrA.ToCharArray();
char[] ArryB = StrB.ToCharArray();
int number = 0;
for (int j = 0; j < ArryA.Length; j++)
{
for (int i = 0; i < ArryB.Length; i++)
{
if (ArryA[j].Equals(ArryB[i]))
{
number++;
}
}
}
if (number == StrB.Length)
{
Console.WriteLine("true");
}
else
{
Console.WriteLine("false");
}
Console.ReadKey();
string StrB = "AE";
char[] ArryA = StrA.ToCharArray();
char[] ArryB = StrB.ToCharArray();
int number = 0;
for (int j = 0; j < ArryA.Length; j++)
{
for (int i = 0; i < ArryB.Length; i++)
{
if (ArryA[j].Equals(ArryB[i]))
{
number++;
}
}
}
if (number == StrB.Length)
{
Console.WriteLine("true");
}
else
{
Console.WriteLine("false");
}
Console.ReadKey();
相关阅读 更多 +