活代码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对象. 两者单独查询时都不会出现什么问题,不过 ...
随机推荐
- mysql基操
创建数据表: create table tt1( id int, name varchar(20), age int,sex boolean ); insert into tt1 values(1,& ...
- 编码原则 之 Stable Dependencies
The Stable Dependencies Principle states that “The dependencies between software packages should be ...
- [转载]linux下网卡漂移导致网络不可用
转自:https://blog.csdn.net/hyatsz/article/details/47690993 linux下网卡漂移导致网络不可用 2015年08月16日 00:48:50 hyat ...
- subing用法
sql中substring截取,start位置索引由1开始 c#中substring截取,start位置索引由0开始
- Linux操作系统的VI命令
Linux操作系统的VI命令 VI是Linux系统的一个文本编辑器,该编辑器可以通过使用VI命令来操作,从而完成对文本的编辑.熟练掌握一些常用的VI命令,可以大大简化编辑操作并提高操作Linux文本的 ...
- Gradle 简记
不是 Gradle,就是 Maven吧.对比下: Maven: 推荐(?)了一个默认的项目结构和生命周期,但是太过死板 虽然暴露了 API 接口,但是插件定制太过复杂 和 Ant 一样,仍然无法表达复 ...
- http压测工具wrk使用
安装 wrk支持大多数类UNIX系统,不支持windows.需要操作系统支持LuaJIT和OpenSSL,不过不用担心,大多数类Unix系统都支持.安装wrk非常简单,只要从github上下载wrk源 ...
- Thinkphp5背景图片的引入~ 以及图片的引入
将图片信息从数据库查询 再渲染于前台页面
- Asp.net core Identity + identity server + angular 学习笔记 (第五篇)
ABAC (Attribute Based Access Control) 基于属性得权限管理. 属性就是 key and value 表达力非常得强. 我们可以用 key = role value ...
- Genymotion模拟器无法直接安装APP
使用Genymotion模拟器安装APP的过程中,将我们的apk拖进去模拟器报以下错误: Genymotion官网常见问题解决办法汇集地址:https://www.genymotion.com/#!/ ...