//
string 的查找
string [] names = new string [ 5 ];
names[ 0 ] = " Zhang " ;
names[ 1 ] = " Li " ;
names[ 2 ] = " Wang " ;
bool r = Array.Exists(names, delegate ( string i) { return i == " Ldi " ; });
if (r)
{
Console.WriteLine( " find.. " );
}
else
{
Console.WriteLine( " Not find.. " );
}
Console.ReadLine();
// List的查找
List < string > names2 = new List < string > ();
names2.Add( " Li1 " );
names2.Add( " Li2 " );
names2.Add( " Li3 " );
bool r2 = names2.Exists( delegate ( string i) { return i == " Li2 " ; });
if (r2)
{
Console.WriteLine( " find.. " );
}
else
{
Console.WriteLine( " Not find.. " );
}
Console.ReadLine();
// names2.CopyTo(); List的拷贝方法和转[]数据方法,copyto可以选择其中一部分
// names2.ToArray();
string [] names = new string [ 5 ];
names[ 0 ] = " Zhang " ;
names[ 1 ] = " Li " ;
names[ 2 ] = " Wang " ;
bool r = Array.Exists(names, delegate ( string i) { return i == " Ldi " ; });
if (r)
{
Console.WriteLine( " find.. " );
}
else
{
Console.WriteLine( " Not find.. " );
}
Console.ReadLine();
// List的查找
List < string > names2 = new List < string > ();
names2.Add( " Li1 " );
names2.Add( " Li2 " );
names2.Add( " Li3 " );
bool r2 = names2.Exists( delegate ( string i) { return i == " Li2 " ; });
if (r2)
{
Console.WriteLine( " find.. " );
}
else
{
Console.WriteLine( " Not find.. " );
}
Console.ReadLine();
// names2.CopyTo(); List的拷贝方法和转[]数据方法,copyto可以选择其中一部分
// names2.ToArray();