[英]Class property should be offered from another class (vb.net)
I am using vb.net for creating web based applications. 我正在使用vb.net创建基于Web的应用程序。 I try to create clean and easy to use code. 我尝试创建干净且易于使用的代码。
My problem is: I am going to create a class with a property, which can has constaint values only (maybe from another class) and I want the designer to offer aceptable values. 我的问题是:我将创建一个具有属性的类,该属性只能具有约束值(也许来自另一个类),并且我希望设计师提供可接受的值。
I want to see like in the picture 我想看图片
example: What should I change in the code below? 示例:我应该在下面的代码中更改什么?
Public Class users
private _gender as byte
public writeonly property Gender as byte
set(value as byte)
_gender = value
End set
End property
End Class
Public Class genders
Public ReadOnly Property Female As Byte
Get
Return 0
End Get
End Property
Public ReadOnly Property Male As Byte
Get
Return 1
End Get
End Property
End Class
Use Enum
使用Enum
Public Enum Genders As Byte
Female = 0
Male = 1
End Enum
Or Const
or Shared
properties of class if you need some other type then Integer 或类的Const
或Shared
属性(如果需要其他类型,则为Integer)
Public Class SomeTypes
Public Const TypeOne As String = "One"
Public Const TypeTwo As String = "Two"
Public Shared ReadOnly Property TypeThree As String = "Three"
End Class
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.