July 2017
Beginner
466 pages
9h 37m
English
Deconstruction is a syntax to split a value into multiple parts and store those parts individually into new variables. For example, tuples that return multiple values. Let us take the following method as an example, which returns a tuple of two string variables, Title and Author (see the New changes to tuples section):
public (string Title, string Author) GetBookDetails()
{
return (Title: "Mastering Visual Studio 2017", Author: "Kunal Chowdhury");
}
Now, when you call the method GetBookDetails(), it will return a tuple. You can access its elements by calling the element name, as follows:
var bookDetails = GetBookDetails(); // returns Tuple Console.WriteLine("Title : " + bookDetails.Title); Console.WriteLine("Author ...Read now
Unlock full access