Skip to content

Allow multiple return values in C# #102

@GoEddie

Description

@GoEddie

Hi,

In a newer version of c#, can you consider this as a new feature?

Returning multiple values from a function is really useful and would avoid either returning a class / struct or using out parameters.

The syntax could be something like:

var result = false;
var someOtherValue = "";

result, someOtherValue = SomeMethod(100, 100);

to return multiple values do something like:

public bool, string SomeMethod(int number1, int number2) {
return true, "blah blah blah";
}

which seems a lot nicer than:

public bool SomeMethod(int number1, int number2, out string returnValue) {
returnValue = "blah blah blah";
return true;
}

There are a few uservoices for this:

https://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2083753-return-multiple-values-from-functions-effortlessly

https://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/6072768-allow-methods-to-have-multiple-return-values

https://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/6348329-returning-multiple-values

UPDATE: This is covered by #347 which is listed as having "Strong Interest" on the C# 7 work list :)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions