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

Encapsulate a method...

Hi
How can I encapsulate a specific method from a specific object? I have some
different object with different methods, and I would like that the object
could put a reference to one of its methods into a common arraylist. A
control element should then at a later time, go through the arraylist and
execute the methods, but I do not know how to encapsulate the methods to put
then into the arraylist?

Hope that my question is somehos understandable, and that someone can
help...

Regards
Thorbjørn
Dec 5 '05 #1
5 1656

"Thorbjørn Jørgensen softdoc.dk>" <thorbjorn@<REMOVE> wrote in message
news:43***********************@news.sunsite.dk...
Hi
How can I encapsulate a specific method from a specific object? I have
some different object with different methods, and I would like that the
object could put a reference to one of its methods into a common
arraylist. A control element should then at a later time, go through the
arraylist and execute the methods, but I do not know how to encapsulate
the methods to put then into the arraylist?


Look into delegates.
Dec 5 '05 #2
Hi,

You can use an array of delegates ( or a ArrayList if the number of element
change) .

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Thorbjørn Jørgensen softdoc.dk>" <thorbjorn@<REMOVE> wrote in message
news:43***********************@news.sunsite.dk...
Hi
How can I encapsulate a specific method from a specific object? I have
some different object with different methods, and I would like that the
object could put a reference to one of its methods into a common
arraylist. A control element should then at a later time, go through the
arraylist and execute the methods, but I do not know how to encapsulate
the methods to put then into the arraylist?

Hope that my question is somehos understandable, and that someone can
help...

Regards
Thorbjørn

Dec 5 '05 #3
Look at the delegates.
I hope this MSDN article could shed some light on the matter

http://msdn.microsoft.com/library/de...estutorial.asp
--

Stoitcho Goutsev (100) [C# MVP]

"Thorbjørn Jørgensen softdoc.dk>" <thorbjorn@<REMOVE> wrote in message
news:43***********************@news.sunsite.dk...
Hi
How can I encapsulate a specific method from a specific object? I have
some different object with different methods, and I would like that the
object could put a reference to one of its methods into a common
arraylist. A control element should then at a later time, go through the
arraylist and execute the methods, but I do not know how to encapsulate
the methods to put then into the arraylist?

Hope that my question is somehos understandable, and that someone can
help...

Regards
Thorbjørn

Dec 5 '05 #4
Hi
Look at the delegates.
I hope this MSDN article could shed some light on the matter

http://msdn.microsoft.com/library/de...estutorial.asp


Thank you very much for all of you replies, I works great...

Regards
Thorbjørn
Dec 6 '05 #5
Hi again...
Hi
Look at the delegates.
I hope this MSDN article could shed some light on the matter

http://msdn.microsoft.com/library/de...estutorial.asp


Thank you very much for all of you replies, I works great...

.... it works greatly!

Regards
Thorbjørn
Dec 6 '05 #6

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

Similar topics

11
by: Dave Rahardja | last post by:
OK, so I've gotten into a philosophical disagreement with my colleague at work. He is a proponent of the Template Method pattern, i.e.: class foo { public: void bar() { do_bar(); } protected:...
0
by: beyond | last post by:
does anyone knows, how to encapsulate pl/sql-packages into DAO-object (java)? we are considering to separate logic from data-structure in oracle. what are the technical problems /risks doing...
5
by: Chris | last post by:
Hi I have a scenario where I've created another AppDomain to dynamically load a DLL(s) into. In this newly loaded DLL I want to call a static method on a class. The problem arise is that I have...
3
by: charliewest | last post by:
this is a very newbie question re: oop - pls excuse my ignorance: i have inserted in each of my asp.net web forms written using C# error handing code that i would like to encapsulate in one,...
2
by: Matt | last post by:
Hiding Method. How to Hide tx.carry() I want tx.carry not to be reached on test(); any ideas? public abstract class Car { public abstract void run(); public abstract void carry(); } public...
6
by: TBass | last post by:
Hi, I've been using C for years, but I'm new to C++. For the most part it's been smooth, but here's my current snag: COPCClassFactor.h =============== class COPCClassFactory {
1
by: Jason Huang | last post by:
Hi, In my C# windows form, is it possible to encapsulate a Label to an Image? If possible, how to do that? Thanks for help. Jason
2
by: kabradley | last post by:
Hello everyone. I have three reports that I would like to put into one main report. I tried creating the main report and then putting three seperate subreports in the detail section of the parent...
4
by: nw | last post by:
Hi All, I currently have a vector of objects (lets call them MyObject). I want to perform various operations regularly on the whole vector, for example find the maximum, average, or operations...
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?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.