Home > OS >  I have this code with a class which has a method with type of inteface created in my project , anyon
I have this code with a class which has a method with type of inteface created in my project , anyon

Time:01-15

Here is my class with the interface type method

internal class MyClass
    {
        public static IMainInterface MyMethod(Main main)
        {
           ///some code
        }
    }

CodePudding user response:

It means that the method returns an instance of a class that implements the IMainInterface interface.

This is often done for design reasons; in particular, it's usually a good practice to program to interfaces rather than concrete implementations. By analogy, when you learn to drive, you learn to drive cars "in general", not just a Ford Focus. You know how to use all cars to the extent that their interface is the same.

  • Related