private void button1_Click(object sender, EventArgs e) { string mystring = "Abracadabra"; WorksWithAString StringAction = DisplayString; StringAction(mystring); StringAction = DisplayLength; StringAction(mystring); }
private void demoButton_Click(object sender, EventArgs e) { // Create a string. string mystring = "Abracadabra"; // Create a delegate referencing the DisplayString method. WorksWithAString StringAction = DisplayString; // Add the DisplayLength method to the delegate. StringAction += DisplayLength; // Call the methods that StringAction references. StringAction(mystring); }