活代码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对象. 两者单独查询时都不会出现什么问题,不过 ...
随机推荐
- Oracle中的位图索引和函数索引
位图索引 同样的,先说是什么,再说为什么. 上篇我们说过BTREE索引是将数据表的索引列和行号排序后以树状形式存在磁盘中.那位图索引是什么样的呢? 现有如下日志表,有操作类型字段op_type,该字段 ...
- LGOJ P3834 【模板】可持久化线段树 1(主席树)
代码 #include <cstdio> #include <iostream> #include <algorithm> using namespace std; ...
- Android中粗字体
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页面里面有普通字体.中粗字体.加粗字体.对于IOS的小伙伴,分分钟搞定,但是对于Android开发的我,瞬间懵逼了.WTF! 安卓只有粗和不 ...
- Java基础学习-关键字的概述和特点以及常量的概述和分类
1.关键字概述 -被Java语言赋予特定含义的单词 2.关键字的特点 -组成关键字的字母全部小写 -常用的代码编辑器,针对关键字有特殊的颜色标记,非常直观,所以我们不需要死记硬 ...
- [系统相关]WPS Office 2016 专业增强版 10.8.0.6470 免序列号无限制
WPS Office (10.8.0.6470) 新增功能列表 ============================================= 改进功能列表 ------------ W ...
- 【.Net Core】Assets file project.assets.json not found. Run a NuGet package restore
问题起因 添加 .net core的Project build失败. 提示以下error: Assets file project.assets.json not found. Run a NuGet ...
- 目标指定法——S.M.A.R.T.
一个有效的目标一定要是 具体的(Specific), 可测量的(Measureable), 可实现的(Attainable), 有现实意义的(Realistic), 以及有明确期限的(Time-bas ...
- InvalidArgumentError: ConcatOp : Dimensions of inputs should match: shape[0] = [1,136,240,64] vs. shape[1] = [1,135,240,64]
初始输入图片大小为1600*1200,设置的输入网络的最大测试图片大小为1600*1200相当于scale =1 ,运行没有问题.之后输入图片大小为1920*1080,测试图片大小为1920*1080 ...
- java中Map集合的常用方法 (转)
原文地址:https://www.cnblogs.com/xiaostudy/p/9510763.html Map集合和Collection集合的区别 Map集合是有Key和Value的,Collec ...
- 微信小程序http连接访问解决方案
HTTP + 加密 + 认证 + 完整性保护 = HTTPS,小程序考虑到信息安全的问题,选用了更为稳定安全的https 来进行信息传递. HTTPS协议的主要作用可以分为两种:一种是建立一个信息安全 ...