string[] names = { "Hartono, Tommy", "Adams, Terry",
"Andersen, Henriette Thaulow",
"Hedlund, Magnus", "Ito, Shu" }; // Get the first string in the array that is longer
// than 20 characters, or the default value for type
// string (null) if none exists.
string firstLongName =
names.AsQueryable().FirstOrDefault(name => name.Length > 20); outputBlock.Text += String.Format("The first long name is '{0}'.", firstLongName) + "\n"; // Get the first string in the array that is longer
// than 30 characters, or the default value for type
// string (null) if none exists.
string firstVeryLongName =
names.AsQueryable().FirstOrDefault(name => name.Length > 30); outputBlock.Text += String.Format(
"There is {0} name that is longer than 30 characters.",
string.IsNullOrEmpty(firstVeryLongName) ? "NOT a" : "a") + "\n"; /*
This code produces the following output: The first long name is 'Andersen, Henriette Thaulow'.
There is NOT a name that is longer than 30 characters.
*/这个里面name => name.Length 是什么意思? 这种用法叫什么? 怎么搜都搜不到呢~~~
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货