I was doing some sample example which were perfectly fine. But, when I read about SOLID design principle, I had to change my code.I have implemented DIP and DI (Constructor Injection) in my code. Please let me know whether I have implemented successfully or not.Old code before SOLID design principlss:class Program{    static void Main(string[] args)    {        Higherclass obj = new Higherclass(Female);        obj.CallLowerClass();        Console.ReadLine();    }}public class Higherclass{    public readonly string sex;    lowerClass_Male objLowerClass_Male = null;    lowerClass_Female objLowerClass_Female = null;    public Higherclass(string _sex)    {        sex = _sex;    }    public void CallLowerClass()    {        if (sex == Male)        {            objLowerClass_Male = new lowerClass_Male();            objLowerClass_Male.DoSomeAction();        }        else        {            objLowerClass_Female = new lowerClass_Female();            objLowerClass_Female.DoSomeAction();        }    }}public class lowerClass_Male{    public void DoSomeAction()    {        Console.WriteLine(Hey It's Male. Do Some Action);    }}public class lowerClass_Female{    public void DoSomeAction()    {        Console.WriteLine(Hey It's FeMale. Do Some Action);    }}Newly modified code:class Program{    static void Main(string[] args)    {        //Now, It depends on my requirement to call any sex class.Let's Say, I want to call Female Class.        lowerClass_FeMale objLowerfemale = new lowerClass_FeMale();        Higherclass obj = new Higherclass(objLowerfemale);        obj.CallLowerClass();        Console.ReadLine();    }}public interface ISex{    void DoSomeAction();}public class lowerClass_Male : ISex{    public void DoSomeAction()    {        Console.WriteLine(Hey It's Male. Do Some Action);    }}public class lowerClass_FeMale : ISex{    public void DoSomeAction()    {        Console.WriteLine(Hey It's FeMale. Do Some Action);    }}public class Higherclass{    public ISex MySexInterface = null;    public Higherclass(ISex objISex)    {        this.MySexInterface = objISex;    }    public void CallLowerClass()    {        MySexInterface.DoSomeAction();    }}
Dependency Inversion Principle and Dependency Injection in C#
c#;beginner;object oriented;comparative review;dependency injection