Suppose I have two functions which look like this:
public static void myFunction1(int a, int b, int c, string d)
{
//dostuff
someoneelsesfunction(c,d);
//dostuff2
}
public static void myFunction2(int a, int b, int c, Stream d)
{
//dostuff
someoneelsesfunction(c,d);
//dostuff2
}
What would be a good way to avoid repeated dostuff?
Ideas I've thought of, but don't like:
- I could make d an object and cast at runtype based on type, but this strikes me as not being ideal; it removes a type check which was previously happening at compile time.
- I could also write a private helper class that takes an object and write both signatures as public functions.
- I could replace dostuff and dostuff2 with delegates or function calls or something.