全局方法的最佳/简便方法 [英] Best/Easiets ways for Global methods
本文介绍了全局方法的最佳/简便方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我以一种形式使用了几根琴弦,
现在需要那些字符串的值
在我其余的表格中.我该怎么办?
这是我使用的字符串:
Hi all,
I used a couple of strings in my one forms and
now need those values of those string
in the rest of my forms. How can I do this?
Here is my strings I use:
public string strUsername;
public string strPassword;
public string strLog;
请提供任何帮助.
Please any help would be appriciated
推荐答案
好吧,如果仅使用上述变量的一个实例,则只需声明一个静态类即可将它们保存在一个公共变量中.地点.也可以用作Helper类,其中包含到处都需要的通用静态方法.
步骤:
1.有一个通用的命名空间:Namespace.Common
2.声明一个静态类,例如:public static HelperClass
3.在这里声明您的变量
4.在整个应用程序中使用它们
Well if you are using only one instance of the variables above, you can just simply declare a static class which holds them in a common location. This can also be used as a Helper class containing common static methods which are required everywhere.
Steps:
1. Have a common namespace: Namespace.Common
2. Declare a static class like: public static HelperClass
3. Declare your variables here
4. Use them throughout your application
这篇关于全局方法的最佳/简便方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文