dotnet / dotnet/vblang

Proposal: Allow ByRef overloading in VB

Open
#505 13 comments 2 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
328
Forks
71
PR merge metrics
No merged PRs in 30d

Description

Overloading between _in_ parameters and _out_ or _ref_ parameters is supported in C#.
But in VB, if you want to call one of an overload method which differ only by ByVal and ByRef, the compiler will report error BC31429 .
This feature was used in some C# class libraries such as CocosSharp, made them incompatible with VB.

**C# signature:**

``` c#
public void TestA(int param);
public void TestA(ref int param);
public void TestB(int param);
public void TestB(out int param);
public void TestC(int param);
```

**C# call:**

``` c#
int i = 0;
TestA(i);
TestA(ref i);
TestB(i);
TestB(out i);
TestC(i);
```

**Suggested new VB syntax to distinguish between ByVal and ByRef:**

``` vb
Dim i = 0
TestA(i) ' TestA(i);
TestA(ByRef i) ' TestA(ref i);
TestB(i) ' TestB(i);
TestB(ByRef i) ' TestB(out i);
TestC(i) ' TestC(i);
```

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.