Johnson Bill

Johnson Bill

  • 1.7k
  • 63
  • 3.3k

What's the best solution & design pattern for this ?

Mar 10 2022 8:51 PM

I need to write reusable oop code in C#  which does the following (just one solution):
(I'm interested more in the design pattern that needs to be implemented in this scenario)
 
1. counts occurences of a specific letter in a string.  e.g ('l',"Hello world") => 3
2. counts occurences of a specific digit in a number e.g. (2,2546522772) => 4
3. Adds two numbers together. e.g (2,5) => 7

Which is the best way to approach this?  

Is this a good solution ? :

        public interface IFoo
        {
            void DoWork(params object[] arguments);
        }

Thanks.