C# 7 Features - Deconstruction

In my previous post, we discussed the possible feature of tuples in C# 7.0. Using the same code, we will discuss another feature named Deconstruction. Thus, I recommend you to go through that feature first.
In order to retrieve the multiple values returned by the method, we can use this deconstruction feature. In order to do this, we simply need to declare two variables of int and string types to catch the values returned by our method. The syntax will look, as shown below.
  1. (int age, string dept) = GetEmployeeById(21);  
  2. Console.Write("Age is: " + age + ", Department is:" + dept);  
 Also, we can use the var keyword for the types, if we do not want to explicitly specify the types of the variables. See the code given below. 
  1. (var age, var dept) = GetEmployeeById(21);  
  2. Console.Write("Age is: " + age + ", Department is:" + dept);  
Hope, you enjoyed reading this one. Happy coding.