473,378 Members | 1,347 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,378 software developers and data experts.

delegate instance creation

public delegate bool MyDelegate();

public void MyMethod()
{
return false;
}

What is difference between follwoing two statements?

1) MyDelegate aDelegate = new MyDelegate(MyMethod);
2) MyDelegate aDelegate = MyMethod;

Thanks In advance.

Aug 2 '06 #1
4 1286
The second doesn't work in 1.1; other than that, they are the same.

Marc
Aug 2 '06 #2
Oh, and neither will work as MyMethod has the wrong return type... it should
return a bool.

Marc
Aug 2 '06 #3

Marc Gravell wrote:
Oh, and neither will work as MyMethod has the wrong return type... it should
return a bool.

Marc
public delegate bool MyDelegate();

public bool MyMethod()
{
return false;
}

1) MyDelegate aDelegate = new MyDelegate(MyMethod);
2) MyDelegate aDelegate = MyMethod;

I have corrected the return type. Now 1 and 2 are the same.

Thanks a lot Marc.

Aug 2 '06 #4
I have corrected the return type. Now 1 and 2 are the same.
Thanks a lot Marc.
No problem; but they always were the same ;-p
Aug 2 '06 #5

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

Similar topics

1
by: Pieter Breed | last post by:
Hi All, I am trying to use the attribute/reflection system to as much potential as I can think of, but I've run into a snag. I would appreciate it if someone would point me in the right...
5
by: - | last post by:
Hi to All, Is there any trick for adding additional runtime info (for example a string) to a delegate instance? I would like to mimic the Java EventListener - EventListenerProxy,...
1
by: Anurag | last post by:
Hello Folks, Here's wishing you MERRY CHRISTMAS and Festive seasons's greeting!! Now this has been bugging me for quite a while and I seek your help in setting my mind to peace. As part of DB2...
9
by: glomde | last post by:
Hi I wonder if you can set what subclass a class should have at instance creation. The problem is that I have something like: class CoreLang(): def AssignVar(self, var, value): pass class...
1
by: mitrofun63 | last post by:
Hi, All I have trouble with db2 instance creation (DB2 9.1.2 on AIX 5.3) When i run command for instance creation : ../db2icrt -a SERVER -p 50000 -s ese -u db2fenc1 db2inst1 a reciveve...
7
by: colin | last post by:
Hi, How can I use a delegate that I can set to call a non static function but of any instance of the class ? eg class TypeTeader<T> { delegate T readDelegate<T>();
0
tlhintoq
by: tlhintoq | last post by:
My project involves reading magstripe cards, capturing an ID number, then spinning off to do some other things including taking a photograph. 99% of this is done and good. All early phases of work...
3
by: puzzlecracker | last post by:
A cut-and-paste from the Jon's book, with a question to follow: Utter garbage! (Or not, as the case may be…)—It’s worth being aware that a delegate instance will prevent its target from being...
0
by: db2dbdba | last post by:
How can I find time/timestamp of instance creation on DB2 LUW? I thought I might find this info on dbm snapshot but no luck. it gives only the information on last start time of instance ? I...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.