Using ParamArray in a VB.NET Property
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) ...
精彩评论