예제 #1
0
 // 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));
 }
예제 #2
0
 // 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);
 }