Wrox Programmer Forums
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 10th, 2010, 08:08 AM
Registered User
 
Join Date: Aug 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Delegates

Hi,

Please give me realtime example of delegates
 
Old August 23rd, 2010, 06:27 AM
Friend of Wrox
 
Join Date: Nov 2009
Posts: 156
Thanks: 13
Thanked 16 Times in 16 Posts
Default sample

Code:
delegate double mathAction(double a, double b);

double Sum(double x, double y)
{
    return x + y;
}

double Mul(double x, double y)
{
    return x * y;
}

// in code
mathAction m1 = new mathAction(Sum);
double result1 = m1(3, 5); // result = Sum(3, 5)

mathAction m2 = new mathAction(Sum);
double result2 = m2(3, 5); // result = Mul(3, 5)





Similar Threads
Thread Thread Starter Forum Replies Last Post
C# Delegates Christopher C# 2008 aka C# 3.0 7 November 20th, 2009 05:08 AM
Help with delegates mike_remember ASP.NET 1.0 and 1.1 Professional 2 November 7th, 2006 12:33 AM
Delegates RalphJr C# 2005 1 April 29th, 2006 08:06 AM
Delegates pramos.21d C# 1 April 11th, 2006 03:43 AM
Help with Delegates mike_remember ASP.NET 1.0 and 1.1 Basics 4 October 4th, 2005 07:32 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.