一、代码

' Fig. 9.7: LINQWithListCollection.vb
' LINQ to Objects using a List(Of String).
Module LINQWithListCollection
Sub Main()
' populate a List of Strings
Dim items As New List(Of String)
items.Add("aqua") ' add "aqua" to the end of the List
items.Add("rust") ' add "rust" to the end of the List
items.Add("yellow") ' add "yellow" to the end of the List
items.Add("red") ' add "red" to the end of the List ' select Strings starting with "r" and convert them to uppercase
Dim startsWithR = _
From item In items _
Where item.StartsWith("r") _
Order By item _
Select item.ToUpper() ' display query results
For Each item In startsWithR
Console.Write("{0} ", item)
Next Console.WriteLine() ' output end of line items.Add("ruby") ' add "ruby" to the end of the List
items.Add("saffron") ' add "saffron" to the end of the List ' print updated query results
For Each item In startsWithR
Console.Write("{0} ", item)
Next Console.WriteLine() ' output end of line
End Sub ' Main
End Module ' LINQWithListCollection ' **************************************************************************
' * (C) Copyright 1992-2009 by Deitel & Associates, Inc. and *
' * Pearson Education, Inc. All Rights Reserved. *
' * *
' * DISCLAIMER: The authors and publisher of this book have used their *
' * best efforts in preparing the book. These efforts include the *
' * development, research, and testing of the theories and programs *
' * to determine their effectiveness. The authors and publisher make *
' * no warranty of any kind, expressed or implied, with regard to these *
' * programs or to the documentation contained in these books. The authors *
' * and publisher shall not be liable in any event for incidental or *
' * consequential damages in connection with, or arising out of, the *
' * furnishing, performance, or use of these programs. *
' **************************************************************************

  二、运行结果:

来源:Visual Basic 2008 How to  Program           P305

活代码LINQ——09的更多相关文章

  1. 活代码LINQ——06

    一.模块代码 ' Fig. 9.4: LINQWithArrayOfObjects.vb ' LINQ to Objects using an array of Employee objects. M ...

  2. 活代码LINQ——01

    序言 此系列的所有代码都是运行在Win 7 64位 + Visual Basic 2008 Express Edition的环境中 之所以学习List集合类,是因为我们先前学习的数组自身的缺陷: 1. ...

  3. 活代码LINQ——08

    一.模块代码 ' Fig. 9.6: ListCollection.vb ' Generic List collection demonstration. Module ListCollection ...

  4. 活代码LINQ——07

    来源说明:https://blog.csdn.net/sha574810590/article/details/40738069 在LINQ中,数据源和查询结果实际上都是IEnumerable< ...

  5. 活代码LINQ——05

    片段代码: ' Exercise 9.3 Solution: Invoice.vb ' Invoice class. Public Class invoide ' declare variables ...

  6. 活代码LINQ——04

    一.主模块代码: 'Fig.4.16:GradeBookTest.vb 'Create and manipulate a GradeBook object;illustrate validation ...

  7. 活代码LINQ——03

    一.主模块代码: 'Fig.4.13:GradeBookTest.vb 'GradeBook constructor used to specify the course name at the 't ...

  8. 活代码LINQ——02

    一.复习基础——属性与实例变量 'Fig. 4.8:GradeBookTest.vb 'Create and manipulate a GradeBook object. Module GradeBo ...

  9. Linq to EF 与Linq to Object 使用心得

    大家都知道Linq既可以用来查询数据库对象(我这里指的是Entity FrameWork里的Model对象),也可以用来查询内存中的IEnumerable对象. 两者单独查询时都不会出现什么问题,不过 ...

随机推荐

  1. 浅谈装饰器(Python)

    先来了解函数和执行函数在python的区别   我再重新定义一个函数,在函数前面加上@set_func 执行结果如下:   函数前面没有加@set_fun 执行结果如下:   是不是可以不修改原来的函 ...

  2. Native App自动化测试及Appium框架介绍

    一  自动化工具简介 1 Appium : 开源,跨平台的自动化测试工具,用于测试Native(原生)和Hybrid(混合)应用,支持IOS/Android/FirefoxOS 平台. 2  环境 : ...

  3. IDEA调用其它模块module的类方法

    IDEA支持调用本project中其他模块的包里面的方法(需要配置该模块和src同级的.iml文件,配置完需要等一会才生效,尝试切换到桌面以...) 这样会使IDEA的project的模块间有依赖,该 ...

  4. Qt如何实现不规则弹窗

    1.无边框: 2.放图: 3.重写鼠标函数(问题是:怎么确定不规则弹窗的响应范围?挖坑待填)

  5. Linux常用命令——文本编辑器Vim

    Linux常用命令--文本编辑器Vim Linux  Vim常用操作 插入命令 a 在光标所在字符后插入 A 在光标所在行尾插入 i 在光标所在字符前插入 I 在光标所在行首插入 o 在光标下插入新行 ...

  6. js回调函数以及同步与异步

    1. 背景介绍javascript的单线程特性由于javascript语言是一门“单线程”的语言,所以,javascript就像一条流水线,仅仅是一条流水线而已,要么加工,要么包装,不能同时进行多个任 ...

  7. Linux之DHCP搭建命令集锦

    systemctl start dhcpd        //启动DHCP systemctl enable dhcpd                //配置服务开机启动 ps aux | grep ...

  8. day23

    ## 复习 4.类与对象的语法class 类名: 代码块(一堆属性与方法)对象名 = 类名() 变量 | 函数 => 属性 | 方法:前者直接使用,通过所属者.语法调用 类会随所属文件加载而加载 ...

  9. 分页查询最好加排序(order by)

    昨天,与外部化系统对接时,发现有一个数据一直咩有集成到,双方各自排查了自己系统的代码,都觉得逻辑非常简单,无法就是一个分页查询而已. 问题就出在这个分页查询上. 为了说明当时问题发生的情景,我模拟了一 ...

  10. asp.net 虹软 人脸识别 实现刷脸住宿、刷脸签到、刷脸进入等

    先看看效果图,我把demo改成自动运行了,暂时借用别人的图片: 最左侧的大图为选择上传的, 中间的小图是大图的脸, 右侧的大图是人脸文件夹中已经存在的,并且相似度较高的一张脸,也就是比对的结果. 先记 ...