VB.Net中"[]"对类型做什么. [英] What do the '[ ]' do in VB.Net for types.

查看:86
本文介绍了VB.Net中"[]"对类型做什么.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每隔一段时间,您会看到一行代码,例如:

Every once in a while you see a line of code like:

Dim _byte As [byte]



它有什么作用?我只是在网络上找不到对此的任何引用.谢谢



What does it do? I just can''t find any references to this on the web. Thanks

推荐答案

通常,使用"["和]"可以让您使用保留字("next","while"等)作为变量名.
Normally, ''['' and '']'' are used let you use reserved words ("next", "while" and so forth) as variable names.
Dim [while] As string


但是,在最佳情况下,这是一种皱着眉头的做法.似乎您也可以使用它们来引用数据类型,并且如果未在其周围用"["和]"''声明数据类型,则将忽略它们.

它们被称为转义名称,MSDN在此处简要讨论它们: http://msdn.microsoft.com/en-us/library/81ed9a62(v=vs.80).aspx [


However this is a frowned-upon practice at the best of times. It would appear that you can also use them to reference a datatype and that they are ignored if a datatype has not been declared with ''['' and '']'' around them.

They are called Escaped Names, and MSDN discusses them briefly here: http://msdn.microsoft.com/en-us/library/81ed9a62(v=vs.80).aspx[^]

I would recommend that you ignore this usage - it may be considered as a bug, and as such it could be fixed at any time.


这篇关于VB.Net中"[]"对类型做什么.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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