Click here to Skip to main content
15,911,306 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a problem how to make some variables or output of a private function in C# WFA accessibile to other forms or other private functions.

For example Let us assume Button 1 will give you summation of two variables and store the summation in variable sum. Then I want use variable sum in other functions. Any Idea?

What I have tried:

I aways make kind of dublications of codes which is not a solution. I think I should do somehting with public. The solution still need help from you. Thanks
Posted
Updated 4-Jun-19 22:23pm

1 solution

The easy (but wrong) way is to use static variables with are global to everything in the app domain. The proper way will be to store your data in your "main" form, and if other forums need it they can be passed the data when you call those functions, or if the data is needed by a child form you can give the child form the data when you create it. Other traditional ways of communicating between forms are using events when one forum will subscribe to the events of another if they want to be notified of changes.
 
Share this answer
 
Comments
EngAb1989 5-Jun-19 4:37am    
Do you have an example? if there is example, it would be great! Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900