異なるメソッドごとに毎回説明をインスタンス化する必要はありますか?または私は静的を使用する必要がありますか?私は今これをやっています:このような状況を処理する最良の方法は何ですか?私はこの行を繰り返すようです:Dim description As BLLDescription = New BLLDescription()
良いreasnなし。あなたは、静的クラスとしてBLLDescriptionを定義する場合異なるメソッドでクラスのインスタンスを作成する方法
Protected Sub Button8_Click(sender As Object, e As System.EventArgs) Handles Button8.Click
Dim description As BLLDescription = New BLLDescription()
List<String> = description.GetDescriptionWithoutNotes()
.....
End Sub
Protected Sub Button9_Click(sender As Object, e As System.EventArgs) Handles Button9.Click
Dim description As BLLDescription = New BLLDescription()
List<String> = description.GetDescriptionWithNotes()
.....
End Sub
Protected Sub Button10_Click(sender As Object, e As System.EventArgs) Handles Button10.Click
Dim description As BLLDescription = New BLLDescription()
List<String> = description.GetAllDescriptions()
.....
End Sub
わかりました。なぜ私はそのthoguhをしてはいけないのですか? – user194076
データはBLLDescriptionのインスタンスごとに異なるものではなく、データアクセスレイヤーとしてのみ使用されるため、静的として宣言することが最も理にかなっています。 – hspain