Are static local variables bad practice?
问题 Related C++ question: Static local variables in methods a bad practice? In VB.NET, when I want a simple counter or something that increments each time a method is called, I often find myself writing code like: Private Sub tmrRefresh_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrRefresh.Tick Static a As Integer = 0 a += 1 '...rest of method depends on a End Sub Is this recommended in VB.NET and OOP in general? 回答1: Are static local variables bad practice? No .