通过使用C#形式之间数据的最佳方式 [英] Best way to pass data between forms using C#

查看:112
本文介绍了通过使用C#形式之间数据的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个更基础的理论问题。我工作的设计我在C#中,这是创建危害最终的项目。我的问题是,这将是在它们之间传递数据的最佳方式?例如,栏目要求游戏飞溅节目后选择屏幕打开。在这里,他们将选择的球员和他们的名字的数量。我知道,在我的gameform加载事件,我可以只指定那些东西作为参数,并把它们传递从optionsform参数。这似乎凌乱,虽然,有没有创造,我可以引用不管我目前使用的形式项目范围变量更有效的方法?

This is more of a theory based question. I am working on the design for my final project in C#, which is to create Jeopardy. My question is, what would be the best way to pass data between them? For instance, the rubric requires the game opens with an options screen after the splash shows. Here, they will select the number of players and their names. I know that in my gameform load event, I can just specify those things as parameters and pass them as arguments from the optionsform. This seems messy though, is there a more efficient way to create project wide variables that I could reference no matter the form I am currently using?

感谢您的任何答案,它总是AP preciated!

Thanks for any answers, it's always appreciated!

- 年轻的学徒codeR

-- Young Padawan Coder

推荐答案

有关如何用静态属性或单模式建立一个独立的业务对象(即类)。然后,您可以存储所有的应用价值那里,你可以参考他们从任何地方在你的应用程序,而周围的变量传递到处都是凌乱的工作。

How about creating a separate business object (i.e. class) with either static properties or singleton pattern. You would then store all your application values there and you can refer to them from anywhere in your application without the messy work of passing around variables all over the place.

这篇关于通过使用C#形式之间数据的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆