Lambda表达式where过滤数据


使用Lambda的表达式来过滤符合条件的数据。下面的代码实现,是把字符阵列中,把名字长度等于3元素找出来。

 

class Bv
    {
        public void LambdaExpression()
        {
            string[] names = new string[] { "insus", "leo", "yang", "Joe", "Michael" };

            var result = names.Where(x => x.Length == 3);

            foreach (string s in result)
            {
                Console.WriteLine(s);
            }
        }

    }
Source Code

 

运行结果:

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM