Defining Local Variable const vs Class const

后端 未结 6 1202
时光说笑
时光说笑 2020-12-30 18:12

If I am using a constant that is needed only in a method, is it best to declare the const within the method scope, or in the class scope? Is there better pe

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-30 19:07

    Depends on if you want to use it throughout your class. The top declaration will be usable throughout your class whereas the other will only be available in MyMethod. You won't get any performance boost by doing it either way.

提交回复
热议问题