> What is the difference between String and string in C#?
So far, my impression is that the same is true for VB.NET. The language specification even says (emphasis mine):
The primitive types are identified through keywords, which are aliases for predefined types in the System namespace. A primitive type is completely indistinguishable from the type it aliases : writing the reserved word Byte is exactly the same as writing System.Byte.
So, I was very surprised to see that Visual Studio 2015 is different: Visual Studio allows you Specify the frame name (Int32 / Int64 / DateTime / …) preferences (tools/options/text editor/basic/code style) native VB keywords (integer/long/day/…).
The problem is: once you tell Visual Studio that you prefer the Framework name, the automatically generated code uses [String] (using [] VB keyword escape, similar to C#’s @) instead of String (object, single and all the same) VB key Word matches other types with the Framework type name). I think this is wrong (and have submitted a Connect issue) because the brackets make the code messy, and as shown above, whether you use [String] (due to VB’s automatic system import Effectively refer to System.String), it will not produce semantic differences) or String (VB keyword alias System.String).
However, since the Visual Studio developers are very smart, I finished It’s all possible to ignore something, and it actually makes sense to use [String] instead of String, so my question is:
Is it possible to use [String] instead of String in Visual Basic? Any conceivable advantages, or the Visual Studio editor just “does something wrong” and uselessly messes up the automatically generated code?
We all know that in C#, there is no use of String (CLR class) or string (C# keyword). Difference. For details, please refer to the following question
> What is the difference between String and string in C#?
So far, my impression is VB.NET The same is true. The language specification even says (emphasis mine):
The primitive types are identified through keywords, which are aliases for predefined types in the System namespace. < strong>A primitive type is completely indistinguishable from the type it aliases: writing the reserved word Byte is exactly the same as writing System.Byte.
So I was very surprised See Visual Studio 2015 is different: Visual Studio allows you to specify the frame name (Int32 / Int64 / DateTime / …) preferences (tools/options/text editor/basic/code style) native VB keywords (integer/long /日/ …).
The problem is: once you tell Visual Studio that you prefer the framework name, the automatically generated code uses [String] (using [] VB keyword escape, similar to C# @) Instead of String (object, single and all the same) VB keyword and Framework type Name matches other types). I think this is wrong (and have submitted a Connect issue) because the parentheses make the code messy, and as shown above, no matter you use [String] (because VB’s automatic system import effectively references System String), it will not produce semantic differences) or String (VB keyword alias System.String).
However, because the Visual Studio developers are very smart, it is entirely possible that I have overlooked some Stuff, and it actually makes sense to use [String] instead of String, so my question is:
Is there any conceivable advantage of using [String] instead of String in Visual Basic, or The Visual Studio editor just “does something wrong” and uselessly messes up the automatically generated code?
I think using String (refers to (1)) will be more continuous than [String]. Using [String] in the whole place is only in the syntax color of VB It doesn’t look good because it looks like a normal type instead of a keyword. I think that when coloring with VB syntax, in addition to its appearance, there is no possible advantage to using [String] instead of String in the code .