Is VB really case insensitive?

后端 未结 14 2007
名媛妹妹
名媛妹妹 2020-11-30 05:28

I\'m not trying to start an argument here, but for whatever reason, it\'s typically stated that Visual Basic is case insensitive and C languages aren\'t (and somehow that is

相关标签:
14条回答
  • 2020-11-30 05:53

    Yes, the VB.NET compiler treats identifiers in a case insensitive way. And yes, that can cause problems when it consumes assemblies that were written in another language or uses COM components. The former case is covered by the Common Language Specification. The relevant rule is:

    For two identifiers to be considered distinct, they must differ by more than just their case.

    The COM case is rather crudely taken care of by the type library builder, it forces the casing of identifiers with the same name to be identical. Even when those identifiers have different roles. In other words, a method parameter with the name "index" will force a method name "Index" to be recased to "index". That has produced rather a lot of head scratching, as you might imagine :)

    0 讨论(0)
  • 2020-11-30 05:53

    This is part of the editor you are using, they may behave differently but the fact is that Visual Basic really is case-insensitive language. So, ss and SS are same.

    Please have a look at VB.NET Basics tutorial for more information :)

    0 讨论(0)
  • 2020-11-30 05:56

    Yes, VB is case insensitive. It sometimes throws those not used to it for a bit of a loop.

    0 讨论(0)
  • 2020-11-30 06:00

    I'm not sure I understand you? VB is case insensitive, so ss and SS is the same variable, so the compiler correctly complains that you re-declared the variable.

    I think that Variables are not case sensitive, but function names are.

    0 讨论(0)
  • 2020-11-30 06:03

    One doesn't have to try all that hard in VB.NET to create code with different uppercase/lowercase "spellings" of an identifier. Changing the casing of an identifier in the file where it's declared without using the "Rename" function will not cause the name to be updated in other files, though editing any line which contains the name will cause it to conform to the present definition.

    In this way, one can determine that VB.NET is mostly case insensitive, but it does make the case of identifiers available to the CLR which may use that information in case-sensitive ways.

    0 讨论(0)
  • 2020-11-30 06:05

    VB is mostly case insensitive, but there are exceptions. For example, XML literals and comprehension is case sensitive. String comparisons are usually case sensitive, unlike say T-SQL, but there are compiler switch to make string comparisons case insensitive. And of course there are the edge cases when dealing with inheritance, COM, and Dynamic Language Runtime.

    0 讨论(0)
提交回复
热议问题