[String] 在 VB.NET 中是什么意思? [英] What does [String] mean in VB.NET?

查看:32
本文介绍了[String] 在 VB.NET 中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道以下构造是什么意思吗:

Does anybody know what does the following construct mean:

    Dim s1 as [String]

方括号是什么意思?为什么下面的带有 Integer 的语句会失败,而上面带有 String 的语句会起作用?

What do the square brackets mean? And why does the following statement with Integer fail while the one above, with String works?

    Dim i1 as [Integer]

提前致谢.

推荐答案

使用方括号以便编译器将其解释为类型,即使它是关键字.想象一下,如果你有一个名为 As 的类:

THe square brackets is used so that the compiler interprets it as a type, even if it would be a keyword. Imagine for example if you had a class named As:

Dim a As [As]

这通常仅用于自动生成的代码,因此它适用于您抛出的任何类型.

This is usually only used in auto generated code, so that it works with any type that you throw at it.

不能使用 [Integer] 的原因是 Integer 不是数据类型,而是关键字.您必须使用相应的数据类型,即 [Int32].

The reason that you can't use [Integer] is that Integer is not a data type, it's a keyword. You would have to use the corresponding data type, i.e. [Int32].

这篇关于[String] 在 VB.NET 中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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