473,399 Members | 2,858 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,399 software developers and data experts.

DELEGATION PROBLEM

I want create a delegate method like that . However It returns ..

CsharpWeb1.deneme.test()' does not match delegate 'void
CsharpWeb1.deneme.foo()
Method 'CsharpWeb1.deneme.test2()' does not match delegate 'void
CsharpWeb1.deneme.foo()'

What is the my mistake ?

public class deneme

{
public int sal ()

{

foo x=new deneme.foo(test);

x+=new deneme.foo(test2);

}
public delegate void foo();

public int test ()

{
return 10;

}

public int test2()

{

return 100;

}

in Page_load

deneme sailim =new deneme ();

sa2.Text=sailim.sal().ToString();

Jul 1 '06 #1
4 1111
"Savas Ates" <in da club> wrote:
foo x=new deneme.foo(test);

x+=new deneme.foo(test2); public delegate void foo(); public int test () public int test2()


The delegate type "foo" is declared to return void, but both test() and
test2() return int. You either need to change "foo" to return int, or
change test() and test2() to return void.

-- Barry

--
http://barrkel.blogspot.com/
Jul 1 '06 #2
ok thanks for your helping

I changed the code like that

public class deneme

{
public delegate int foo();

public foo sal ()

{

foo x=new deneme.foo(test);

x+=new deneme.foo(test2);

return x;

}

public int test ()

{
return 10;

}


public int test2()

{

return 100;

}


}

It returns
CsharpWeb1.deneme+foo
I expect 10 and 100 which test and test2 methods return ? hoe can i get it
?
Jul 1 '06 #3
"Savas Ates" <in da club> wrote:
foo x=new deneme.foo(test);

x+=new deneme.foo(test2);

return x; It returns
CsharpWeb1.deneme+foo
I expect 10 and 100 which test and test2 methods return ? hoe can i get it


The type of x is foo. Because it's inside the deneme class, and the
deneme class is inside CsharpWeb1, and the default ToString() of
System.Object is to return the name of the type, and .NET creates nested
class names with '+', the total name of the *type* of x is
"CsharpWeb1.deneme+foo".

To call it, you need to use '()':

return x();

This will return the value of the last delegate attached, i.e. the value
of test2(). The value of the test() call is lost. For this reason, it's
recommended that delegates which return values shouldn't be combined.

-- Barry

--
http://barrkel.blogspot.com/
Jul 1 '06 #4
thank you sir.. Can you offer me any link to have more info about delegation
?
Jul 1 '06 #5

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

Similar topics

7
by: Rene Pijlman | last post by:
Section 6.5 "What is delegation?" of the FAQ says: "Python programmers can easily implement delegation. For example, the following class implements a class that behaves like a file but converts...
1
by: Robert Dick | last post by:
Derived classes sometimes need to delegate portions of the work in overridden methods to methods in their base classes. This was traditionally done with explicit calls in python, e.g., class...
6
by: DPfan | last post by:
Is the following so-called "delegation"? If not how to make some changes so that the F class delegates its operation to an E instance. On the other hand the following code runs without any...
3
by: Tony Johansson | last post by:
Hello! What does it mean with delegation and can you give me one example. //Tony
2
by: | last post by:
Hi, I am working on a n-tier app using remoting. I am using the VS 2005 beta 2. My server needs to access a remote resources on behalf on the connected user. I have configured my server like :...
1
by: jm | last post by:
I promise. I have tried everything I could find. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetHT05.asp (and much more) I have an asp (not .net) page...
2
by: russell.lane | last post by:
I'm building out a pretty standard n-tier web application. The stack includes application/presentation, biz logic, and data access layers on top of an SQL server back end. We want to use...
4
by: JimLad | last post by:
In advance, sorry if this is the wrong group... SQL Server 2000 SP3 on Server 2003. SQL Account and Computer both Trusted for Delegation. Given SPN. IIS 5.0 on W2000. Kerberos enabled....
6
by: Marc Castrechini | last post by:
This is a classic double hop delegation issue, however its the first time we are setting this up so we are doing something incorrectly. If we run through the IDE or using a localhost path on the...
5
by: =?Utf-8?B?TWF5ZXI=?= | last post by:
Hi, I'm using two form classes and I would like all methods of the second class (the child class) to be managed by the first class (the main class). Is delegation the best solution for me? If so,...
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: 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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.