473,382 Members | 1,202 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How to pass delegate as parameter

Pls Help me - Asap

public void start(delegate wm,string name) - is this possiable ?

if so

Pls tell me how to do?
r - give some sample codes?
r - tell me some sites to learn?
Thanx
Gopal Prabhakaran
Nov 15 '05 #1
4 1938

"Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
news:ud**************@tk2msftngp13.phx.gbl...
Pls Help me - Asap

public void start(delegate wm,string name) - is this possiable ?

if so

Pls tell me how to do?
r - give some sample codes?
r - tell me some sites to learn? Sure, its possible. Basically, a delegate is a type just like any other, so
you would do something like:
//define your delegate type
public delegate void MyDelegate();
//define the method that takes the delegate
public void start(MyDelegate del, string name)
{

}

to call it, the code would be
start(new MyDelegate(TestMethod),"name");
public void TestMethod()
{
}

Thanx
Gopal Prabhakaran

Nov 15 '05 #2
ok, how to do if have 2 classes means.
I have a class a and class b,

i want to pass a delegate (i.e method) to classb

pls help me asap

Thanx
Prabhakaran.G

"Daniel O'Connell" <onyxkirx@--NOSPAM--comcast.net> wrote in message
news:eP**************@TK2MSFTNGP11.phx.gbl...

"Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
news:ud**************@tk2msftngp13.phx.gbl...
Pls Help me - Asap

public void start(delegate wm,string name) - is this possiable ?

if so

Pls tell me how to do?
r - give some sample codes?
r - tell me some sites to learn? Sure, its possible. Basically, a delegate is a type just like any other,

so you would do something like:
//define your delegate type
public delegate void MyDelegate();
//define the method that takes the delegate
public void start(MyDelegate del, string name)
{

}

to call it, the code would be
start(new MyDelegate(TestMethod),"name");
public void TestMethod()
{
}


Thanx
Gopal Prabhakaran


Nov 15 '05 #3

"Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
news:Oi**************@tk2msftngp13.phx.gbl...
ok, how to do if have 2 classes means.
I have a class a and class b,

i want to pass a delegate (i.e method) to classb in that case you want to do a fully qualified name passed
class A
{
public void MyMethod(MyDelegate del);
}
class B
{
public void callMethod()
{
}
}
the code would be:
A a = new A();
B b = new B();
a.MyMethod(new MyDelegate(b.callMethod));

pls help me asap

Thanx
Prabhakaran.G

"Daniel O'Connell" <onyxkirx@--NOSPAM--comcast.net> wrote in message
news:eP**************@TK2MSFTNGP11.phx.gbl...

"Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
news:ud**************@tk2msftngp13.phx.gbl...
Pls Help me - Asap

public void start(delegate wm,string name) - is this possiable ?

if so

Pls tell me how to do?
r - give some sample codes?
r - tell me some sites to learn?

Sure, its possible. Basically, a delegate is a type just like any other,

so
you would do something like:
//define your delegate type
public delegate void MyDelegate();
//define the method that takes the delegate
public void start(MyDelegate del, string name)
{

}

to call it, the code would be
start(new MyDelegate(TestMethod),"name");
public void TestMethod()
{
}


Thanx
Gopal Prabhakaran



Nov 15 '05 #4
Thanx For ur Timiing Help

Thanx
Gopal Prabharkaran

"Daniel O'Connell" <onyxkirx@--NOSPAM--comcast.net> wrote in message
news:#C**************@tk2msftngp13.phx.gbl...

"Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
news:Oi**************@tk2msftngp13.phx.gbl...
ok, how to do if have 2 classes means.
I have a class a and class b,

i want to pass a delegate (i.e method) to classb

in that case you want to do a fully qualified name passed
class A
{
public void MyMethod(MyDelegate del);
}
class B
{
public void callMethod()
{
}
}
the code would be:
A a = new A();
B b = new B();
a.MyMethod(new MyDelegate(b.callMethod));

pls help me asap

Thanx
Prabhakaran.G

"Daniel O'Connell" <onyxkirx@--NOSPAM--comcast.net> wrote in message
news:eP**************@TK2MSFTNGP11.phx.gbl...

"Gopal Prabhakaran" <pr*******@takescm.com> wrote in message
news:ud**************@tk2msftngp13.phx.gbl...
> Pls Help me - Asap
>
> public void start(delegate wm,string name) - is this possiable ?
>
> if so
>
> Pls tell me how to do?
> r - give some sample codes?
> r - tell me some sites to learn?
Sure, its possible. Basically, a delegate is a type just like any
other, so
you would do something like:
//define your delegate type
public delegate void MyDelegate();
//define the method that takes the delegate
public void start(MyDelegate del, string name)
{

}

to call it, the code would be
start(new MyDelegate(TestMethod),"name");
public void TestMethod()
{
}
>
>
> Thanx
> Gopal Prabhakaran
>
>



Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: yoramo | last post by:
hello can I pass a static method as a parameter to a method? if the answer is yes how do I do that ? how do I call the method ? yoramo.
4
by: KC Eric | last post by:
Hi all, I have a dll file, it has a class, say: class Temp, this class has a function which has a delegate as a parameter, say: public void Test(GameOverHandler _overHandler)
6
by: Minfu Lu | last post by:
I have a problem dealing with passing a function address to a COM callback. I use this COM function for communicating to a hardware. My original project was written in VB. I have converted it to...
0
by: verpeter | last post by:
When try pass only one delegate as parameter, all work fine. But I need call function, that take as parameter array of function pointers. From C++ code I used such code: static void* aFuncPtrs =...
3
by: Bob Speaking | last post by:
Hi at all, Is possible to pass a parameter though a delegate or to override it? (I'm newbie and I'm trying to understand delegates and their use in a real scenario) In my scenario I need to...
3
by: John Dalberg | last post by:
I have seen examples for List<T>.FindAll(findthis)where findthis is a predicate. How do I pass a parameter to this predicate so that I have different values to search for? I don't want to use...
2
by: Curious | last post by:
I have a C#.NET program that uses a delegate, "BuildExistingReportFile". It's called in such a fashion: IList lFiles = this.GetListFromStoredProcedure( null,...
6
by: =?Utf-8?B?emlubw==?= | last post by:
I'm trying to pass a delegate as parameter but the code below does not compile. It display an error: 'AddressOf operand must the name of a method(without parantheses)' How can I make it work. ...
24
by: =?Utf-8?B?U3dhcHB5?= | last post by:
Can anyone suggest me to pass more parameters other than two parameter for events like the following? Event: Onbutton_click(object sender, EventArgs e)" Event handler: button.Click += new...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.