hi,
Im new to C# - ive have my background in c/c++ - and somethings are abit new
to me, so havent really gotten the total feel of the laguage yet.
I have a situation which i really have no idea to solve in c# - what i do,
is that i have a MAIN form, which subsequently calls several other forms.
There are very few variable things between each form, but i need to have a
"SaveData()" function for each form.
In C++ it was possible to do this by inheratice of classes - in C i could
pass a functionpointer to my local function, and obtain the thing i wish.
How do i do a similar thing i c# ? - pass some reference to a local function
(in one class) to another class ?
Hope you can help. 7 1010
dtdev:
You can have a base class which has the SaveData() function.
All other forms can inherit the base class with the common SaveData or other
common functions.
You can also override the SaveData function in each Form depending on
whether you want to implement the same functionality or use a variation of
it.
Thanks
--
data mining and .net team http://www.visual-basic-data-mining.net/forum
"dtdev" <no*****@spamnotx.it> wrote in message
news:O9****************@TK2MSFTNGP12.phx.gbl... hi,
Im new to C# - ive have my background in c/c++ - and somethings are abit
new to me, so havent really gotten the total feel of the laguage yet.
I have a situation which i really have no idea to solve in c# - what i do, is that i have a MAIN form, which subsequently calls several other forms.
There are very few variable things between each form, but i need to have a "SaveData()" function for each form.
In C++ it was possible to do this by inheratice of classes - in C i could pass a functionpointer to my local function, and obtain the thing i wish.
How do i do a similar thing i c# ? - pass some reference to a local
function (in one class) to another class ?
Hope you can help.
Hi,
You would typically do that sort of thing with inheritance in C# too. Create
a new baseclass that inherits from System.Windows.Forms.Form and then let
all your other forms inherit from that baseclass instead of the default
System.Windows.Forms.Form.
In the baseclass you can implement the Save() method.
--
Patrik Löwendahl - C# [MVP]
cshrp.net - 'Elegant code by witty programmers'
cornerstone.se - 'IT Training for proffessionals'
"dtdev" <no*****@spamnotx.it> wrote in message
news:O9****************@TK2MSFTNGP12.phx.gbl... hi,
Im new to C# - ive have my background in c/c++ - and somethings are abit
new to me, so havent really gotten the total feel of the laguage yet.
I have a situation which i really have no idea to solve in c# - what i do, is that i have a MAIN form, which subsequently calls several other forms.
There are very few variable things between each form, but i need to have a "SaveData()" function for each form.
In C++ it was possible to do this by inheratice of classes - in C i could pass a functionpointer to my local function, and obtain the thing i wish.
How do i do a similar thing i c# ? - pass some reference to a local
function (in one class) to another class ?
Hope you can help.
hi guys,
Thanks for your quick answers.
Do you know anywhere where there might be an example of this on the internet
? - just to make sure im getting it right from the start.
Check MSDN.COM for Inheritance, Object Oriented Programming (OOP) examples,
etc.
It is really not that complex :)
--
data mining and .net team http://www.visual-basic-data-mining.net/forum
"dtdev" <no*****@spamnotx.it> wrote in message
news:OV**************@TK2MSFTNGP15.phx.gbl... hi guys,
Thanks for your quick answers.
Do you know anywhere where there might be an example of this on the
internet ? - just to make sure im getting it right from the start.
Yeah okay i guess its like in C++ so youre right ;)
Thanks ;)
"http://www.visual-basic-data-mining.net/forum" <si******@gmail.com> skrev i
en meddelelse news:eP**************@TK2MSFTNGP14.phx.gbl... Check MSDN.COM for Inheritance, Object Oriented Programming (OOP)
examples, etc.
It is really not that complex :)
C# is very similar to C++. Just tidier.
public class BaseForm : System.Windows.Forms.Form
{
public virtual void SaveData()
{
// do some saving...
}
}
public class MammothForm : BaseForm
{
public void doFunkyStuff_click(object sender, EventArgs e)
{
base.SaveData();
// - or -
this.SaveData();
// same, same but different ;)
}
}
public class MammothEatingForm : BaseForm
{
public override void SaveDate()
{
// Save data elswhere
}
public void eatAMammoth_click(object sender, EventArgs e)
{
this.SaveData();
// - not equal to -
base.SaveData();
}
}
"dtdev" <no*****@spamnotx.it> wrote in message
news:OV**************@TK2MSFTNGP15.phx.gbl... hi guys,
Thanks for your quick answers.
Do you know anywhere where there might be an example of this on the
internet ? - just to make sure im getting it right from the start.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: domeceo |
last post by:
can anyone tell me why I cannot pass values in a setTimeout function
whenever I use this function it says "menu is undefined" after th
alert.
function imgOff(menu, num) {
if (document.images) {...
|
by: jr |
last post by:
Sorry for this very dumb question, but I've clearly got a long way to go!
Can someone please help me pass an array into a function. Here's a starting
point.
void TheMainFunc()
{
// Body of...
|
by: kalinga1234 |
last post by:
there is a problem regarding passing array of characters to another
function(without using structures,pointer etc,).can anybody help me to
solve the problem.
|
by: collinm |
last post by:
hi
i got some error with parameter
my searchFile function:
char *tmp;
int size;
....
|
by: Mr Newbie |
last post by:
I am often in the situation where I want to act on the result of a function,
but a simple boolean is not enough. For example, I may have a function
called
isAuthorised ( User, Action ) as ?????...
|
by: Andrew Poelstra |
last post by:
int gets_ws (char *buff, int maxlen, int sc, FILE *fh);
This function reads up to maxlen characters from fh, stopping when it
encounters whitespace, sc, or EOF. If EOF is encountered, the...
|
by: John Friedland |
last post by:
My problem: I need to call (from C code) an arbitrary C library
function, but I don't know until runtime what the function name is,
how many parameters are required, and what the parameters are. I...
|
by: Larax |
last post by:
Best explanation of my question will be an example, look below at this
simple function:
function SetEventHandler(element)
{
// some operations on element
element.onclick =
function(event)
{
|
by: Bryan Parkoff |
last post by:
I write my large project in C++ source code. My C++ source code
contains approximate four thousand small functions. Most of them are
inline. I define variables and functions in the global scope....
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |