活代码LINQ——05
片段代码:
' Exercise 9.3 Solution: Invoice.vb
' Invoice class.
Public Class invoide ' declare variables for Invoice object
Private partNumberValue As Integer
Private partDescriptionValue As String
Private quantityValue As Integer
Private priceValue As Decimal ' four-argument constructor Public Sub New(ByVal part As Integer, ByVal description As String, ByVal count As Integer, ByVal pricePerItem As Decimal)
PartNumber = part
PartDescription = description
Quantity = count
Price = pricePerItem
End Sub ' New ' property for partNumberValue; no validation necessary
Public Property PartNumber() As Integer
Get
Return partNumberValue
End Get Set(ByVal value As Integer)
partNumberValue = value
End Set
End Property ' PartNumber ' property for partDescriptionValue; no validation necessary
Public Property PartDescription() As String
Get
Return partDescriptionValue
End Get Set(ByVal value As String)
partDescriptionValue = value
End Set
End Property ' PartDescription ' property for quantityValue; ensures value is positive
Public Property Quantity() As Integer
Get
Return quantityValue
End Get Set(ByVal value As Integer)
If value > 0 Then ' determine whether quantity is positive
quantityValue = value ' valid quantity assigned
End If
End Set
End Property ' Quantity ' property for pricePerItemValue; ensures value is positive
Public Property Price() As Decimal
Get
Return priceValue
End Get Set(ByVal value As Decimal)
If value > 0 Then ' determine whether price is positive
priceValue = value ' valid price assigned
End If
End Set
End Property ' Price ' return String containing the fields in the Invoice in a nice format
Public Overrides Function ToString() As String
' left justify each field, and give large enough spaces so all the columns line up
Return String.Format("{0,-5} {1,-20} {2,-5} {3,6:C}", PartNumber, PartDescription, Quantity, Price)
End Function ' ToString
End Class ' Invoice ' **************************************************************************
' * (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
活代码LINQ——05的更多相关文章
- 活代码LINQ——09
一.代码 ' Fig. 9.7: LINQWithListCollection.vb ' LINQ to Objects using a List(Of String). Module LINQWit ...
- 活代码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——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对象. 两者单独查询时都不会出现什么问题,不过 ...
随机推荐
- IDEA修改显示星号*和热部署
IDEA修改显示*星号: IDEA热部署: 两步: 1. 2. Ctrl+Alt+Shift+/ 打开下面界面,选Registry 对于Springboot应用,可能无法启动,在上述两步不起作用的情况 ...
- hibernate HQL添加语句
1.Hibernate HQL添加语句 save();方法使用HQL语句来完成插入操作是不能实现的,不管你使用insert into....values...还是insert into.....sel ...
- 信息安全之路-web-xss学习(1)
关于xss反射性漏洞 1.未加任何过滤的 (1).在dvwa平台上可以看到源代码,如下 low级别 为了便于理解,代码如下: <?php // Is there any input? if( a ...
- C# 封装SDK 获取摄像头的水平角度和垂直角度
最近需要做一个C#版本的控制终端,控制摄像头,获取摄像头的水平角度和垂直角度 获取当前摄像头的角度,需要调用一个名为NET_DVR_GetDVRConfig的bool类型的函数 在C++中,函数定义: ...
- MySQL存储过程 游标
MySQL存储过程 游标 如何在存储过程中使用MySQL游标来遍历SELECT语句返回的结果集 MySQL游标简介 要处理存储过程中的结果集,请使用游标.游标允许您迭代查询返回的一组行,并相应地处理 ...
- @RequestMapping的Ant风格URL
Ant风格资源地址支持3中匹配符 ? 匹配文件名中一个字符. * 匹配 文件名中任意字符 ** 匹配多层路径 例如 /hello/*/myspring 匹配 /hello/abc/mysprin ...
- Windows下安装和卸载MangoDB服务 --MangoDB
1.创建存放的数据文件夹和日志文件 2.安装MangoDB服务:(如数据文件夹路径是:d:/MongoDB/db/,日志文件路径:d:/MongoDB/log.txt) mongod --dbpath ...
- 记录一下小程序canvas
小程序canvas学习 效果图: .wxml <canvas style="width: 100vw; height: 100vh;" canvas-id="fir ...
- iphone上mitmproxy证书设置
PC端安装mitmproxy并添加证书后,基本问题不大,都能正常运行起来 手机端iphone上下载安装mitmproxy证书: 1.手机和PC在同一个局域网中,设置wifi代理为PC端的ip,端口为m ...
- Python —— 函数高级特性(切片、迭代、列表生成式、生成器、迭代器)
一.切片(Slice) 在很多编程语言中,针对字符串提供了很多截取函数(i.e. substring),目的就是对字符串切片.python中没有针对字符串的截取函数,需要通过“切片”来完成. 取一个 ...