片段代码:

' 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的更多相关文章

  1. 活代码LINQ——09

    一.代码 ' Fig. 9.7: LINQWithListCollection.vb ' LINQ to Objects using a List(Of String). Module LINQWit ...

  2. 活代码LINQ——06

    一.模块代码 ' Fig. 9.4: LINQWithArrayOfObjects.vb ' LINQ to Objects using an array of Employee objects. M ...

  3. 活代码LINQ——01

    序言 此系列的所有代码都是运行在Win 7 64位 + Visual Basic 2008 Express Edition的环境中 之所以学习List集合类,是因为我们先前学习的数组自身的缺陷: 1. ...

  4. 活代码LINQ——08

    一.模块代码 ' Fig. 9.6: ListCollection.vb ' Generic List collection demonstration. Module ListCollection ...

  5. 活代码LINQ——07

    来源说明:https://blog.csdn.net/sha574810590/article/details/40738069 在LINQ中,数据源和查询结果实际上都是IEnumerable< ...

  6. 活代码LINQ——04

    一.主模块代码: 'Fig.4.16:GradeBookTest.vb 'Create and manipulate a GradeBook object;illustrate validation ...

  7. 活代码LINQ——03

    一.主模块代码: 'Fig.4.13:GradeBookTest.vb 'GradeBook constructor used to specify the course name at the 't ...

  8. 活代码LINQ——02

    一.复习基础——属性与实例变量 'Fig. 4.8:GradeBookTest.vb 'Create and manipulate a GradeBook object. Module GradeBo ...

  9. Linq to EF 与Linq to Object 使用心得

    大家都知道Linq既可以用来查询数据库对象(我这里指的是Entity FrameWork里的Model对象),也可以用来查询内存中的IEnumerable对象. 两者单独查询时都不会出现什么问题,不过 ...

随机推荐

  1. Android中获得网络状况的实现

    要得知网络状况就是要用networkinfo类这个类名还是把这个类的意思表达的很清晰的,network是网络,info是状况.判断是否有网用到了这个类的IsAvailable方法,这个方法返回的是这个 ...

  2. SQL中IN与EXISTS的区别

    1.IN子句中的子查询只能返回一个字段,不允许返回多个字段,而EXISTS可以返回多个字段 2.IN返回的是某字段的值,而EXISTS返回的则是True或False,EXISTS子句存在符合条件的结果 ...

  3. Unity3d外包—就找北京动点软件(长年承接Unity3d软件、游戏项目外包)

    承接Unity3d体感企业项目.游戏项目外包 北京公司.专业团队,成员为专业Unity3d产品公司一线开发人员,有大型产品开发经验: 提供优质的售后服务,保证产品质量,轻量级产品可以提供规范清晰的源代 ...

  4. Rancher2.0与DataDog集成部署

    目录 一.简要介绍 二.注意事项 三.部署过程 四.运行截图 五.参考链接 一.简要介绍: 看了Rancher中文官网上的一篇关于DataDog部署的文章,自己尝试了一下,没有成功,主要是自己对Dat ...

  5. 分页查询最好加排序(order by)

    昨天,与外部化系统对接时,发现有一个数据一直咩有集成到,双方各自排查了自己系统的代码,都觉得逻辑非常简单,无法就是一个分页查询而已. 问题就出在这个分页查询上. 为了说明当时问题发生的情景,我模拟了一 ...

  6. 合并K个排序链表(java实现)

    题目: 合并 k 个排序链表,返回合并后的排序链表.请分析和描述算法的复杂度. 示例: 输入: [   1->4->5,   1->3->4,   2->6 ] 输出: ...

  7. C#的Monitor.Enter和Monitor.Exit

    C#的lock 语句实际上是调用Monitor.Enter和Monitor.Exit,中间夹杂try-finally语句的简略版,下面是实际发生在之前例 子中的Go方法: 1 2 3 4 5 6 7 ...

  8. Petrozavodsk Winter Camp, Day 8, 2014, Second Trip

    给你一棵树,每次询问一个(a,b),问有多少有路径与a-b没有交集 找lca #include <bits/stdc++.h> using namespace std; #define r ...

  9. React文档(二十一)协调

    React提供了一个声明式地API因此你不用担心每一次更新什么东西改变了.这使得开发应用变得简单,但是这个东西在React中如何实现的并不是很明显.这篇文章会解释我们在React的算法中所做的选择以便 ...

  10. 序列化---Serializable与Externalizable源码

    Serializable接口总结: 1. java.io.Serializable接口是一个标识接口,它没有任何字段和方法,用来表示此类可序列化: 2. 父类声明该接口,则其与其所有子类均可序列化,都 ...