Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hiding variables

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

I am primarily a C# programmer, and am currently helping out a friend with some VB.NET stuff. Anyway, I have a String called stateprovincename, and a Property called StateProvinceName. VS does not appear to like this naming convention, and declares that they are in fact one and the same. Ideas?

like image 845
user978122 Avatar asked Feb 18 '23 11:02

user978122


2 Answers

VB.Net is case-insensitve.

  • Try something like _stateProvinceName or mStateProvinceName (discussion of naming conventions here).
  • Or use an automatic property, which will implicitly declare a hidden backing variable, but you won't be able to write custom code in the Get and Set. Public Property StateProvinceName As String
like image 126
MarkJ Avatar answered Feb 23 '23 03:02

MarkJ


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

like image 24
Kevin DiTraglia Avatar answered Feb 23 '23 04:02

Kevin DiTraglia