Search code examples
vb.netnaming-conventionsidentifierrestriction

What is the maximum identifier length in vb.net?


Whats the max number of characters that can be used for a VB.NET variable or procedure identifier?


Solution

  • According to the MSDN article Declared Element Names (Visual Basic) the maximum length of an element's name (variable, method, class, etc.) is 1023 characters.

    An element name in Visual Basic must observe the following rules:

    • It must begin with an alphabetic character or an underscore (_).

    • It must only contain alphabetic characters, decimal digits, and underscores.

    • It must contain at least one alphabetic character or decimal digit if it begins with an underscore.

    • It must not be more than 1023 characters long.

    This applies to fully qualified names as well. For example: MyNamespace.SubNamespace.ClassName.MethodName.