RSCG Example – Class2Interface – part 29
name | BoilerplateFree |
nuget |
https://www.nuget.org/packages/boilerplatefree |
link | https://github.com/GeeWee/boilerplatefree |
author | Gustav Wengel |
This will generate interface from a class
The code that you start with is
[AutoGenerateInterface] public partial class Person: IPerson { public void Foo() { Console.WriteLine("Foo"); } //dummy private string s { get; set; } public int ID { get; set; } public string Name { get; set; } //dummy public static string NewID { get; set; } }
The code that you will use is
IPerson p = new Person(); p.Name = "Andrei"; p.Foo(); Console.WriteLine(p.Name);
The code that is generated is
public interface IPerson { public void Foo(); public int ID {get; set; } public string Name {get; set; } }
Example Code: https://github.com/ignatandrei/RSCG_Examples/tree/main/Class2Interface
Leave a Reply