我从来没有主动学习正确的职业修饰语,因为它一直是“很高兴拥有”而不是“需要拥有”。
我能做的事让我很恼火Dim F as New Person.FavoriteFoodsList
。
我应该使用哪个类修饰符,以便我的 Person 类可以使用 FavoriteFoodsList,但 Person 之外的任何内容都不能实例化 FavoriteFoodsList?
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim P As New Person
P.FavoriteFoods.Add("Pizza")
Dim F As New Person.FavoriteFoodsList 'How do I prevent this
End Sub
Public Class Person
Public FavoriteFoods As New FavoriteFoodsList
Public Class FavoriteFoodsList
Inherits Collections.Generic.List(Of String)
End Class
End Class