简体   繁体   English

VB.Net OOP / DLL从类列表?

[英]VB.Net OOP/DLL List from a class?

Is it possible in VB.Net Runtime 4.5 to make a DLL, named object, that can be used like this or do I have to use C#? 是否可以在VB.Net Runtime 4.5中创建一个可以称为DLL的命名对象,还是必须使用C#?

Object.UpdateType.Kind = Object.UpdateType.UpdateTypeOne
Dim x as New Field
x.Name = "Foo"
Object.UpdateType.Fields.Add(X)

The real problem I am having is getting the Fields to be a list inside of the UpdateType class. 我遇到的真正问题是让Fields成为UpdateType类中的列表。

Public Class Object
   Public Class UpdateType
      strFields As New List(Of Field)
      Public Class Field
         strName As String = String.Empty
         Public Property Name As String
            Get
               Return strName
            End Get
            Set (Value As String)
               strName = Value
            End Set
         End Property
      End Class
      Public Const UpdateTypeOne As Byte = 1
      Public Property Kind As Byte
         Get
            Return bytKind
         End Get
         Set (Value as Byte)
            bytKind = Value
         End Set
      End Property
      Public Function Fields As List(Of Field)
         ' This part is not making sense to me!
         Return strFields
      End Function
   End Class
End Class

Again as I type Object. 再次输入对象。 I want UpdateType to be a choice in Intellisense. 我希望UpdateType是Intellisense中的一个选择。 Once I choose UpdateType from Intellisense I want Kind to be a choice along with Fields. 从Intellisense中选择UpdateType后,我希望Kind与Fields一起成为一种选择。

The kind needs to accept the Object.UpdateType.UpdateTypeOne constant with that syntax and not by just putting the value 1 in its place. 这种类型需要使用该语法接受Object.UpdateType.UpdateTypeOne常量,而不是仅将值1放在其位置。

The fields need to be a list or collection of field objects that I can add and remove from in the EXE. 字段必须是我可以在EXE中添加和删除的字段对象的列表或集合。 I also want to be able to count the number of items in the fields list or collection. 我还希望能够计算字段列表或集合中的项目数。

Thank you in advance! 先感谢您! -Bill -法案

I would separate the nested Class and Enum and just place them all in a namespace. 我将嵌套的ClassEnum分开,然后将它们全部放在命名空间中。 Since Fields is a Public variable you can access it to add and remove a Field object. 由于FieldsPublic变量,因此您可以访问它以添加和删除Field对象。 An Enum is an OOP way to make choices. Enum是一种进行选择的OOP方法。 Then you can either use an If Statement or Select Case to find which choice was picked and run separate code for it. 然后,您可以使用If StatementSelect Case查找选择了哪个选项,并为其运行单独的代码。 See if this what you need. 看看这是否您需要的。

Namespace Utility
 Public Class UpdateObject
  Public Fields As New List(Of Field)
  Public Property _UpdateType As UpdateType = UpdateType.UpdateTypeOne
  Public Property Kind As Byte
 End Class

 Public Class Field
  Public Property Name As String
  '...others
 End Class

 Public Enum UpdateType 
  UpdateTypeOne 
  '...others
 End Enum
End Namespace

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM