asp net 3.5unleashed

Page 328

public void ProcessItems(Feedback feedback) { for (Int32 item = 0; item < items.Length; item++) { if (feedback != null) { // If any callbacks are specified, call them. feedback(items[item], item + 1, items.Length); } } } }

class App { static void Main() { StaticCallbacks(); InstanceCallbacks(); }

static void StaticCallbacks() { // Create a set with five items in it. Set setOfItems = new Set(5);

// Process the items, but give no feedback. setOfItems.ProcessItems(null); Console.WriteLine(); // Process the items, and give feedback to the console. setOfItems.ProcessItems(new Set.Feedback(App.FeedbackToCons ole)); Console.WriteLine();

// Process the items, and give feedback to a message box. setOfItems.ProcessItems(new Set.Feedback(App.FeedbackToMsgB ox)); Console.WriteLine();

// Process the items, and give feedback to the // console AND to a message box. Set.Feedback fb = null; fb += new Set.Feedback(App.FeedbackToConsole); fb += new Set.Feedback(App.FeedbackToMsgBox);


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.