开发者

Using ParamArray in a VB.NET Property

开发者 https://www.devze.com 2023-02-05 18:42 出处:网络
Is it possible to do someth开发者_运维百科ing like this (don\'t know how to form correct syntax):

Is it possible to do someth开发者_运维百科ing like this (don't know how to form correct syntax):

Public Property MyProperty as ParamArray Date
   Get
      ...
   End Get
   Set(ParamArray p as Date)
      ...
   End Set
End Property 


No; that is not possible.

Instead, you should make a readonly Collection(Of DateTime) property.


No, this is not possible. You'll have to define the property as Date() and create the array explicitly in order to assign it, though you should consider using a more appropriate collection type or interface rather than a simple array.


I guess if it is not possible to make a property will just make 2 methods:

Private itsDateLst As New List(Of Date)

Public Sub SetDateList(ByVal ParamArray p As Date) ...
Public Function GetDateList() As IList(Of Date) ...
0

精彩评论

暂无评论...
验证码 换一张
取 消