C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C# DeconstructionC# deconstruction is a process of deconstruct instance of a class. It is helpful when we want to reinitialize object of a class. Make sure all the parameters of deconstructor are out type. Let's see an example. C# Deconstruction Exampleusing System; namespace CSharpFeatures { public class Student{ private string Name; private string Email; public Student(string name, string email) { this.Name = name; this.Email = email; } // creating deconstruct public void Deconstruct(out string name, out string email) { name = this.Name; email = this.Email; } } class DeconstructExample { static void Main(string[] args) { var student = new Student("irfan", "irfan@abc.com"); var (name, email) = student; Console.WriteLine(name +" "+email); } } }
Next TopicC# Local Functions
|