|
Hi,
I believe i understand the concept of delegates. To put it simply, I think they are used to invoke methods in another class.
What I don't quite understand is:
What is the point of using delegates when you can easily call the method in the other class the normal way which is create an iinstance of the class and then call the method.
Can you please help to understand this issue?
Thanks
|
|
|
|
|
fmardani wrote: What is the point of using delegates when you can easily call the method in the other class the normal way which is create an iinstance of the class and then call the method.
Because a delegate creates a link between classes where there often isn't one. For example, I create a form, form1. It has a modeless child, form2. I want to call a method in form1 when something happens in form2. Now, I CAN make a reference to form1 inside form2, but that's kind of ugly. Delegates are a nicer solution. Events can also be chained, so calling one event can call methods in several class instances. That's all happening for you, for free.
Every time I go back to C++, delegates are the first thing I miss. Yes, I have function pointers, but it's a lot more work.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
|
In oop its an usual practice for an object to send a message to another object, itq common for an object to report back to the sender, resulting in two way conversation between objects (callback methods).
C, C++ did this using function pointers.
C# does it using delegates. Its a special type of object which contains details about the method rather than the data.
They are used for two purposes
1. Callback
2. Event handling
i hope this helps
---------------------------------------------------------------
where there is a will there is a way
|
|
|
|
|
I have the following problem:
i want to be able to fill a class with data in the client side which uses my web service and then send that class to one of its web methods.
For this purpose, i used [Serializable] attribute above all my classes in the web service that should be available in the client side for that purpose.
The problem is that i can see the classes in the client side, but can't call their methods and properties even though they are public.
how can i do that? is there an attribute which should be used above each public method/property of a class which is marked Serializable?
Thanks.
-- modified at 5:30 Thursday 3rd August, 2006
|
|
|
|
|
Create an bject for the Class in the web service in your Application
For Eg
WebApplication1.MyWebservice1.Service1 ObJEct = new WebApplication1.MyWebservice1.Service1();
ObJEct.methdName();
By this you can call the Web methods and propertiesof your Web Services.
Hope this Solves your problem.
note : You should Add [WebMethod] attribute on top of all the methods in the web service to make the methods visible to your client ..
-- modified at 17:27 Thursday 3rd August, 2006
Luck is Opportunity with hardwork
|
|
|
|
|
This is not the case...
The problem is not with the Web service's methods (which are woking just fine). it is with classes that are used to create an object that should be used by the client to fill information.
let's say i have the following in the web service's class "Service1":
-----
[WebMethod]
public string test(MyInfo TestData)
-----
Now, "MyInfo" is a class which has other classes as attributes which have properties/methods. In the client side, i want to be able to fill the TestData class with information (and its internal classes) and send it to the method. These are the methods/properties i want to be able to use in the client side.
So, to be able to see all the classes that MyInfo holds, i used [XmlInclude] attribute for each of these classes.
now - i can create these classes and see them in the client, but all their properties/methods i cannot see even though they are public.
|
|
|
|
|
Hi all
Can i retrive from hashtable objects in those seqency in which ones had been added to one.
I mean
<br />
<br />
ht.Add("key1", object1);<br />
ht.Add("key2", object2);<br />
ht.Add("key3", object3);<br />
<br />
foreach(DictionaryEntry de in ht)<br />
{<br />
WriteLine(de.Key);<br />
}<br />
<br />
------------------<br />
result can be as this:<br />
<br />
key3<br />
key2<br />
key1<br />
<br />
how i can do what:<br />
<br />
key1<br />
key2<br />
key3<br />
<br />
Thank
|
|
|
|
|
I don't believe so, no. A hash table, by definition, stores according to hashes. If you need the order, you need to store them in a list or something as well.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I belive in what i saw
When in watch window i debug this hashtable i saw what all entries walk in ordem in which i add ones .Since what i think should exist any mechanism for retrive ones in same ordem.
Please ,any key ,get me opinion :
i need any ordered collection and simulatently
key-value-pares in one. Which type of collection i should use.
Thank.
-- modified at 5:23 Thursday 3rd August, 2006
|
|
|
|
|
A hashtable does not retain the order that the items were added in. If the items were displayed in the same order you added them, it was a coincidence.
---
b { font-weight: normal; }
|
|
|
|
|
You can make sure in this. Try to oneself.
When displayed items in ordem, when retrived not.
ht.Add("one", null);
ht.Add("two", null);
-----
Displayed:
ht
["one"]
["two"]
------
Retrived
two
one
-- modified at 5:51 Thursday 3rd August, 2006
|
|
|
|
|
Use SortedList instead of Hashtable.
|
|
|
|
|
Thank think this is exactly what i need
|
|
|
|
|
hi all i have this pro on hand now.. i have downloaded some sample database applications from the internet..however when i want to debug it i gives me the error--An unhandled exception of type "system.Data.OleDb.OledbException" occurred in system.data.dll
and also the database is in access format but when i want to open it it gives a message--the file is located outside yr intranet or on an untrusted site. Microsoft Access will not open the file due to potential security problems.TO open the file, copy it to yr machine or an accessible network location.
i inferred that this errors occur due to where the dB file is located..is it correct? can someone out there help will this pro? and maybe guide me to correcting it ..thanks in advance..
|
|
|
|
|
Probably you need to right click the MDB file and mark it as trusted, it's probably marked as having come from the web.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
hi u are right! i can access the DB now but my application still have debugging errors with the same message which i first posted here.. how can i solve it??
|
|
|
|
|
Well, now we're at the point where you need to tell us the error and post some code.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
can u share he link with me from where u downloaded that sample applications with databse please
|
|
|
|
|
Hi all,
How to select a particular treenode in TreeView using index or object
|
|
|
|
|
this.treeView1.SelectedNode = this.treeView1.Nodes[0];
|
|
|
|
|
Hi,
It should be possible to get the scoll lock key status (ON or OFF) in javascript. any one help me out.
thanks in advance!
Have A Nice Day!
Murali.M
|
|
|
|
|
I doubt that very much. It sure has nothing to do with C#.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
So u want to use Scroll Lock Key.
That's great.
Just inform these peaples.
-- modified at 5:16 Thursday 3rd August, 2006
And use right board for right forum (java forum)
regards,
Divyang Mithaiwala
System Engineer & Software Developer
|
|
|
|
|
Hello,
Im wondering how to merge two different List<> into one?
List1
1, Green
2, Blue
3, Red
4, Black
List2
1, 11
2, 22
3, 33
4, 44
result
List1 (after merge)
1, Green, 11
2, Blue, 22
3, Red, 33
4, Black, 44
I now it´s possible in C# 3.0 (http://blogs.msdn.com/abhinaba/archive/2005/09/15/467926.aspx) but i cant use that! It must be a way to solve this, I don´t give up;)
/Albin
|
|
|
|