c # -Linq- extension methods

Code

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

namespace Linq2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            var names = new List<string> { "zhang shan", "zhang shan2", "wang wu" };
            var namesWithz = (from n in names where n.StartsWith("z") select n).ToList();
            foreach(string s in namesWithz)
            {
                Console.WriteLine(s);
            }
            Console.ReadLine();
        }
    }
}

operation result

Hello World!
zhang shan
zhang shan2

 

Published 476 original articles · won praise 38 · views 60000 +

Guess you like

Origin blog.csdn.net/xie__jin__cheng/article/details/104051737