Generation

generate functionFri, 06 Jan 2023

create a class with props int Id, string name then create an interface for it including Rename(string name) method in it

class Person { public int Id { get; set; } public string Name { get; set; } } interface Renamable { void Rename(string name); } class Program { static void Main(string[] args) { Person p = new Person(); p.Id = 100; p.Name = "dd"; var renamer = p as Renamable; renamer.Rename("new name"); } }

Questions about programming?Chat with your personal AI assistant