Quantcast
Channel: Is it possible to make a group of classes that are similar? - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Is it possible to make a group of classes that are similar?

$
0
0

I am wondering if I can make a group of classes that all have the same functions, but the algorithm in each is different. Let's say we had. Multiply.cs, Add.cs ,and Subtract.cs. Each would have this structure:

public Class(int BaseInt){    ...}public MakeNumber(int Oint){    ...}

So the Multiply.cs MakeNumber() would be different from the Add.cs MakeNumber() method, but both would return an int and so could be used in similar contexts. Is there any way to pair these classes up, let's say we call this group operators. Would I be able to declare a variable under this group.

Operators MyOperator = new Operators();

But then later I could say

MyOperator = Multiply;

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>