Hiding variables

Quick silly question: is it possible to hide the variable name used by a property in VB.NET?

I am primarily a C # programmer, and currently I am helping a friend with some VB.NET stuff. Anyway, I have a string called stateprovincename and a property called stateprovincename . It seems that VS is not like this naming convention and states that they are actually the same thing. Ideas?

+4
source share
2 answers

VB.Net case-insensitve .

  • Try something like _stateProvinceName or mStateProvinceName (discussion of naming conventions here ).
  • Or use the auto property , which implicitly declares a hidden backup variable, but you cannot write your own code in Get and Set . Public Property StateProvinceName As String
+7
source

VB.Net, unlike most other languages, is not case sensitive with variable names, so the standard convention will add some kind of prefix for the local one to distinguish it from a property.

+1
source

Source: https://habr.com/ru/post/1446510/


All Articles