Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 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 June 7th, 2007, 06:03 AM
Registered User
 
Join Date: Jun 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Multicasting Delegates

hii all,



First time I am just learning Delegates in c#.



I have faced a conceptual problem.

In books it is written that A Multicasting Delegate should have a return type of Void unless it will throw a run time exception.

But i am written a code snippet with a Multicasting Delegate with a string return type .But it is not throw any exception at all.





Can anybody tell me what is happening here............



Plz somebody help me out...........



The code is given below:







delegate string Delegate_Multicast(int x, int y);

class Class2


{

static string Method1(int x, int y)

{

Console.WriteLine("You r in Method 1");

return "hi";

}

static string Method2(int x, int y)

{

Console.WriteLine("You r in Method 2");

return "hi";

}

public static void Main()

{

Delegate_Multicast func = new Delegate_Multicast(Method1);

func += new Delegate_Multicast(Method2);

string s=func(1,2); // Method1 and Method2 are called

}





Similar Threads
Thread Thread Starter Forum Replies Last Post
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
I still Don't get Delegates p_nut33 Pro VB.NET 2002/2003 2 April 26th, 2004 01:50 PM





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