// A method requiring a HandleTwo delegate argument. static int Multiply(int x, int y, HandleTwo proc) { // Always check the delegate for null before trying to // invoke it. if (proc == null) { // Oops! Delegate no good. // See Bonus Chapter 2 for exceptions. throw new ArgumentNullException("Null delegate passed."); } return(proc(x, y)); }
// A method requiring a HandleTwo delegate argument. static int Multiply(int x, int y, HandleTwo proc) { // Always check the delegate for null before trying to // invoke it. if (proc == null) { // Oops! Delegate no good. // See Bonus Chapter 2 for exceptions. throw new ArgumentNullException("Null delegate passed."); } return proc(x, y); }