forked from dotnet/docs
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deconstruction allows assignment and initialization
Fixes dotnet#24116 Beginning with C# 10, the left side of a deconstruction can mix variable assignment and variable initialization. With this PR, I searched for all instances of "deconstruct" to see if they referenced the previous restriction. Only one instance made that declaration. Update the "deconstruct" article to add a new samples that shows the new syntax.
- Loading branch information
1 parent
f4523e1
commit 8cc6500
Showing
3 changed files
with
28 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
docs/csharp/fundamentals/functional/snippets/deconstructing-tuples/deconstruct-tuple6.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
public class Example5 | ||
{ | ||
// <Snippet1> | ||
public static void Main() | ||
{ | ||
string city = "Raleigh"; | ||
int population = 458880; | ||
|
||
(city, population, double area) = QueryCityData("New York City"); | ||
|
||
// Do something with the data. | ||
} | ||
// </Snippet1> | ||
|
||
private static (string, int, double) QueryCityData(string name) | ||
{ | ||
if (name == "New York City") | ||
return (name, 8175133, 468.48); | ||
|
||
return ("", 0, 0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters