_下划线作为VB.net中变量前缀的含义 [英] Meaning of _ underscore as a variable prefix in VB.net

查看:305
本文介绍了_下划线作为VB.net中变量前缀的含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Visual Basic中的下划线是什么意思?我有以下代码:

What is the meaning of underscore in visual basic? I have this code:

Private _isAuthenticated As Boolean

与做这件事一样吗?

Private isAuthenticated As Boolean

还是在名称前面加下划线有什么特别之处?

Or does adding the underscore to the front of the name do something special?

推荐答案

这是一个约定.前导_经常表示该变量是该类专用的.此约定通常用于许多不同的语言,而不仅仅是VB.

It's a convention. A leading _ often indicates that the variable is private to the class. This convention is commonly used in many different languages, not just VB.

类似地,它也表明该变量是属性后面的局部变量.

In a similar sense, it also indicates that the variable is the local variable behind a property.

但是它对编译器没有重要意义.

However it has no significant meaning to the compiler.

这篇关于_下划线作为VB.net中变量前缀的含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆