How to do it...

Let's take a look at the following implementation of the generic interface as follows:

  1. Go ahead and create a generic interface called IListClassProperties<T>. The interface will define a method that needs to be used called GetPropertyList() that simply uses a LINQ query to return a List<string> object:
        interface IListClassProperties<T>         {           List<string> GetPropertyList();         }
  1. Next, create a generic class called InspectClass<T>. Let the generic class implement the IListClassProperties<T> interface created in the previous step:
        public class InspectClass<T> : IListClassProperties<T>         {         }
  1. As usual, Visual Studio will highlight that the interface member GetPropertyList() has not been implemented in the InspectClass<T>

Get C# 7 and .NET Core Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.