活代码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对象. 两者单独查询时都不会出现什么问题,不过 ...
随机推荐
- JsTree 最详细教程及完整实例
JsTree是一个jquery的插件,它提交一个非常友好并且强大的交互性的树,并且是完全免费或开源的(MIT 许可).Jstree技持Html 或 json格式的的数据, 或者是ajax方式的动态请求 ...
- Java 基础知识点小结
小知识点 所有的程序,都要定义在类里面: 异常 定义方法时,使用 throws 可以用来捕获方法体内没有捕获的异常,然后以 SomeException 抛出异常 java是解释型语言.java虚拟机能 ...
- 十个经典的Python面试题
1.Python下多线程的限制以及多进程中传递参数的方式 Python多线程有个全局解释器锁,这个锁的意思是任一时间只能有一个线程运用解释器.并发不是并行. 多进程间同享数据,能够运用multipro ...
- Visual Studio 2019 double clicking project(custom behavior)
Issue
- Moqui 代码解释
Service: entity-find 和 entity-find-one 的区别: <entity-find entity-name="" list="&quo ...
- CocoaPods 中删除不需要的第三方
1...打开Podfile 找到不需要的类库,直接删除 2...打开终端cd到当前项目的根目录下重新执行pod install --verbose --no-repo-update命令(更新一下) ...
- ArcGIS Pro开发Web3D应用(1)——环境搭建与初始实例
1.搭建环境 1.1 ArcGIS Web3D软件环境 ArcGIS Pro 2.0(必须) ArcGIS for Enterprise 10.5.1 (从10.5开始称呼为Enterprise)包括 ...
- git与github工具使用
这篇文章主要的目标是用较少的时间学习Git和GitHub的基本使用.在足够一般使用的前提下,尽量减少命令.如果需要其他命令,到时候再去其他地方了解就行了. 总概:所有命令前都要加 git,如下的ini ...
- 容器虚拟网卡与网桥docker0虚拟网卡的veth pair的配对
一)基本知识: Docker 安装时会自动在 host 上创建三个网络:none,host,和bridge:详细说明可参考其它文档.我们可用 docker network ls 命令查看: 基于DRI ...
- CentOS7服务管理
1.在/usr/lib/systemd/system目录下建立服务启动文件,文件格式:[root@Centos7 ]# cat /usr/lib/systemd/system/nginx.servic ...