我想要一個方便的方法將Phone對象添加到Phone集合中。是否有某種對象初始化程序語法可用於避免以下自定義例程?.NET對象初始值設定程序問題
我使用.NET 3.5
Private Function PhoneNumbersToCollection(ByVal ParamArray phoneNumberArray() As TelephoneNumberType) As TelephoneNumberCollection
Dim PhoneCollection As New TelephoneNumberCollection
For Each phoneNumber As TelephoneNumberType In phoneNumberArray
If phoneNumber IsNot Nothing Then
PhoneCollection.Add(phoneNumber)
End If
Next
Return PhoneCollection
End Function
編輯:
Public Class TelephoneNumberCollection
Inherits System.Collections.ObjectModel.Collection(Of TelephoneNumberType)
'TelephoneNumberCollection'是如何定義的? – 2011-04-04 13:15:11
公共類TelephoneNumberCollection 繼承System.Collections.ObjectModel.Collection(Of TelephoneNumberType) – ChadD 2011-04-04 13:25:21