あなたはシングルトンパターンを使用することができます
Namespace MyLibrary
Public Class MyObject
Public Shared Function Sum(ByVal a As Integer, ByVal b As Integer) As Integer
Return a + b
End Function
End Class
End Namespace
または、VB.NETであなたはModule
を使用することができます。
Public Class MyLibrary
Private _MyObject As MyLibrary
Public ReadOnly Property MyObject As MyLibrary
Get
If _MyObject Is Nothing Then
_MyObject = New MyLibrary()
End If
Return _MyObject
End Get
End Property
Public Function Sum(ByVal a As Integer, ByVal b As Integer) As Integer
Return a + b
End Function
End Class
をそれとも、キーワードShared
を使用する(C#で、それはstatic
です)クラスの代わりに
Namespace MyLibrary
Public Module MyObject
Public Function Sum(ByVal a As Integer, ByVal b As Integer) As Integer
Return a + b
End Function
End Module
End Namespace
'New'キーワードの何が問題になっていますか? – SLaks
あなたはシングルトンを探しています。それが何と呼ばれているかを知ったので、あなたはそれをGoogleにすることができます。おそらく、既に質問されている、答えられた多くの質問が出てくるでしょう。 –