You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A `Const` statement doesn't properly initialize a constant, or an array declaration uses a variable to specify the number of elements.
14
+
A `Const` statement doesn't properly initialize a constant, an array declaration uses a variable to specify the number of elements, or you're trying to initialize an array as the default value for an optional parameter.
15
15
16
16
**Error ID:** BC30059
17
17
18
18
## To correct this error
19
19
20
-
1. If the declaration is a `Const` statement, check to make sure the constant is initialized with a literal, a previously declared constant, an enumeration member, or a combination of literals, constants, and enumeration members combined with operators.
20
+
- If the declaration is a `Const` statement, check to make sure the constant is initialized with a literal, a previously declared constant, an enumeration member, or a combination of literals, constants, and enumeration members combined with operators.
21
21
22
-
2. If the declaration specifies an array, check to see if a variable is being used to specify the number of elements. If so, replace the variable with a constant expression.
22
+
- If the declaration specifies an array, check to see if a variable is being used to specify the number of elements. If so, replace the variable with a constant expression.
23
+
24
+
- If you're trying to initialize an array as the default value for an optional parameter, use one of the alternative approaches described in the [Array initialization in optional parameters](#array-initialization-in-optional-parameters) section.
23
25
24
-
3. If the preceding checks don't address the issue, try setting the `Const` to a different temporary value, running the program, and then resetting the `Const` to the desired value.
26
+
- If the preceding checks don't address the issue, try setting the `Const` to a different temporary value, running the program, and then resetting the `Const` to the desired value.
27
+
28
+
## Array initialization in optional parameters
29
+
30
+
You cannot initialize an array as the default value for an optional parameter because array initialization is not a constant expression. The following code generates BC30059:
0 commit comments