public class Example_of_From_In_Let_Select { public static void Main(string[] args) { string names = "Mr.Adam,Mrs.Eva,Mr.Henry,MS.May"; var array = names.Split(','); var result = ( from name in array where (name.Substring(0, name.IndexOf('.')) == "Mr" ) let new_name = name + "<Male>" select new_name ); foreach(string x in result) Console.WriteLine(x); } }
/////// Output ///////
Mr.Adam<Male>
Mr.Henry<Male>
沒有留言:
張貼留言