dotnet / dotnet/vblang

Initialising array variables using "As New" syntax.

Open
#230 8 comments 0 reactions 0 assignees View on GitHub
Approved-in-Principle Proposal
Dominant language
No language data
Stars
328
Forks
71
PR merge metrics
No merged PRs in 30d

Description

I found myself writing this today:

```vb
Dim MyArray As New Integer(1024 - 1) {}
```

...and was surprised to see the compiler complain that too many arguments have been passed to `Sub Integer.New()`. Never in my life have I thought of calling a constructor on type `Integer`, so after some head scratching, I found the compiler wants me to write this instead:

```vb
Dim MyArray As Integer() = New Integer(1024 - 1) {}
```

Is there a reason the `As New` syntax is not supported for array variables?

CC: @AnthonyDGreen

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.