C# allows the use of the same multiple destructor methods in the same program Number of output parameters or the same number and type of output parameters Different order.
It is part of the new tuple syntax - not related to the Tuple class, but taken from functional programming.
Deconstruct keyword is used for destructuring functions
public class Employee{ public Employee(string employeename, string firstName, string lastName){ Employeename = employeename; FirstName = firstName; LastName = lastName; } public string Employeename { get; } public string FirstName { get; } public string LastName { get; } public void Deconstruct(out string employeename, out string firstName, out string lastName){ employeename = Employeename; firstName = FirstName; lastName = LastName; } } class Program{ public static void Main(){ Employee employee = new Employee("emp", "fname", "lname"); (string EName, string Fname, string Lname) = employee; System.Console.WriteLine(EName); System.Console.WriteLine(Fname); System.Console.WriteLine(Lname); Console.ReadLine(); } }
emp fname lname
The above is the detailed content of What are destructors in C# 7.0?. For more information, please follow other related articles on the PHP Chinese website!