今天學LINQ之二(1) 枚舉小練習

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LinQ001
{
    
class Program
    
{
        
static void Main(string[] args)
        
{
            List
<string> names = new List<string> "jason""simon""tom""white""smith""lus" };

            IEnumerable
<string> nameQuery =
                from name 
in names
                
where name.IndexOf('n')>=0
                select name;

            
foreach (string name in nameQuery)
            
{
                Console.WriteLine(name);
            }

            Console.ReadLine();
        }

    }

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章