generate functionThu, 22 Dec 2022

define class with two properties name as string age as int build get and set methods. regular build class method and a copy type method use old way of get and set add copy constructor add tostring

public class Person { private string name; private int age; public Person(string name, int age) { name = name; age = age; } public string Name { get { return name; } set { name = value; } } public int Age { get { return age; } set { age = value; } } public static Person CreatePerson(string name, int age) { return new Person(name, age); } public Person CopyPerson() { return new Person(this.name, this.age); } public override string ToString() { return $"{name} {age}"; } }

Questions about programming?Chat with your personal AI assistant