首页 > 代码库 > OfType<string>()

OfType<string>()

 

object[] vals = { 1, "Hello", true, "World", 9.1 };
IEnumerable<double> justStrings = vals.OfType<double>( );
foreach(var str in justStrings)
{
Console.WriteLine(str);
}

 

string[] names = { "Allen", "Arthur", "Bennett" };
string[] ayes = names.Where(s => s[0] == ‘A‘).ToArray();

OfType<string>()