Menu function
1. The high-pass filter (class SignalFilterPassHigh, which implements all methods of interface ISignalFilter) and the low-pass filter (class SignalFilterPassLow, which implements all methods of interface ISignalFilter) have filtering functions (interface ISignalFilter defines the function of the filter: input a A set of integers, and then input another set of integers after filtering).
2. The user selects different filters, and the program generates interface instances corresponding to the filters. You can directly use the interface method.
3. Summarize the role of interfaces
(1) Standardize programming behavior, such as defined filter functions.
(2) It is convenient to establish a factory model, such as a factory providing different products according to different needs.
Source code features
Many beginners do not understand the role of C# interface, so I wrote the source code of "Example of Signal Filter Based on Interface Implementation" for your reference and understanding.
Things to note
The development environment is Visual Studio 2010, developed using .net 3.5
Updates:
1. Use two methods to generate interfaces: one is to create a new class instance that implements the interface and convert it into an interface; the other is to use reflection to generate an interface instance.
2. Change the filter threshold to 0, which is more convenient for demonstration.