活代码LINQ——09
一、代码
' 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的更多相关文章
- 活代码LINQ——06
一.模块代码 ' Fig. 9.4: LINQWithArrayOfObjects.vb ' LINQ to Objects using an array of Employee objects. M ...
- 活代码LINQ——01
序言 此系列的所有代码都是运行在Win 7 64位 + Visual Basic 2008 Express Edition的环境中 之所以学习List集合类,是因为我们先前学习的数组自身的缺陷: 1. ...
- 活代码LINQ——08
一.模块代码 ' Fig. 9.6: ListCollection.vb ' Generic List collection demonstration. Module ListCollection ...
- 活代码LINQ——07
来源说明:https://blog.csdn.net/sha574810590/article/details/40738069 在LINQ中,数据源和查询结果实际上都是IEnumerable< ...
- 活代码LINQ——05
片段代码: ' Exercise 9.3 Solution: Invoice.vb ' Invoice class. Public Class invoide ' declare variables ...
- 活代码LINQ——04
一.主模块代码: 'Fig.4.16:GradeBookTest.vb 'Create and manipulate a GradeBook object;illustrate validation ...
- 活代码LINQ——03
一.主模块代码: 'Fig.4.13:GradeBookTest.vb 'GradeBook constructor used to specify the course name at the 't ...
- 活代码LINQ——02
一.复习基础——属性与实例变量 'Fig. 4.8:GradeBookTest.vb 'Create and manipulate a GradeBook object. Module GradeBo ...
- Linq to EF 与Linq to Object 使用心得
大家都知道Linq既可以用来查询数据库对象(我这里指的是Entity FrameWork里的Model对象),也可以用来查询内存中的IEnumerable对象. 两者单独查询时都不会出现什么问题,不过 ...
随机推荐
- linux服务基础之DNS正反向解析、主从同步、子域授权及视图
关键词: 正向解析 反向解析 主从复制 自域授权 视图 一.DNS基本原理 1.1 什么是DNS?BIND又是什么? DNS:Domain Name Service,它是一个基于应用层的协议,是C/S ...
- Eclipse中Lombok的安装和注解说明
Lombok 可用来帮助开发人员消除 Java 的重复代码,尤其是对于简单的 Java 对象(POJO),比如说getter/setter/toString等方法的编写.它通过注解实现这一目的. 官网 ...
- P1659 [国家集训队]拉拉队排练
思路 求出cnt和len之后,直接乘起来即可 代码 #include <cstdio> #include <algorithm> #include <cstring> ...
- Qt Designer问题(挖坑)
同时用两个VS的Qt Designer打开.ui文件,关闭Qt Designer之后再打开发现Qt Designer不在打开方式了.要重启VS才行.
- 论文阅读: Siam FC
一.研究动机 一方面传统算法设计的跟踪模型过于简单,另一方面深度学习方法很难达到实时效果然而现实场景中的应用对速度要求较高. "shallow method"(HCFT)没有很好地 ...
- vue-cli 最强指南
今天在这篇文章里,会对 vue-cli 的功能做个详细的整理,把 vue-cli 所有的功能都列出来.注:这个是官网连接:https://cli.vuejs.org/zh/guide/ ,建议多看细看 ...
- C语言--第1次作业2.0版
1.本章学习总结 1.1思维导图 1.2本章学习体会及代码量学习体会 1.2.1学习体会 经过一周C语言的正式课堂学习,不同于暑期时扒视频囫囵吞枣式学习,林丽老师的讲解详细异常,尽管已经学习了一部分内 ...
- 区块链 编译android geth 填坑记录 ubuntu
下载geth 源码 直接 make android 下载android ndk sdk 配置环境变量cd 安装golang 设置环境变量 发现没有gomobile命令 按照wiki方法 执行安装g ...
- video 自动循环播放
video 只加autoplay并不能自动播放,需要再加上muted <video controls="controls" autoplay loop muted> ...
- .NET Core通过过滤器和中间件两种方式实现全局异常捕获和日志记录
1.一共有五类过滤器IAsyncAuthorizationFilter IAsyncResourceFilter IAsyncActonFilter IAsyncExceptionFilter ...