1
Q
如何传递结构变量
A
回答
0
将您的结构变量作为静态辅助类的静态成员。
0
您正在寻找的是单身课程。这是一个例子。
public class SingletonClass
{
#region Singleton instance
private static SingletonClass _instance;
public static SingletonClass Instance
{
get { return _instance ?? (_instance = new SingletonClass()); }
}
#endregion
#region Contructor
/// <summary>
/// Note that your singleton constructor is private.
/// </summary>
private SingletonClass()
{
// Initialize your class here.
}
#endregion
#region Public properties
// Place your public properties that you want "Global" in here.
public enum SomeEnumTypes
{
Type1,
Type2,
Type3
}
public int SomeMeasurements { get; set; }
public string SomeID { get; set; }
#endregion
}
所以,当你需要这个全球一流的,只需调用它像这样:
var currentMeasurements = SingletonClass.Instance.SomeMeasurements;
有乐趣。
相关问题
- 1. 使用结构来传递变量Swift
- 2. 将变量传递给结构函数
- 3. 如何从多个结构变量(永久存储)的临时结构变量传递变量
- 4. 传递结构与将变量传递给函数C
- 5. 如何malloced变量传递到结构到新创建的结构用C
- 6. 如何传递变量routes.index
- 7. 如何传递变量ejs.compile
- 8. 传递变量
- 9. 传递变量
- 10. 传递变量
- 11. 传递变量
- 12. 传递变量
- 13. 传递变量
- 14. 传递变量
- 15. 访问结构成员变量传递到功能
- 16. C++传递变量 “结构” 型的作为参考(&)或由值
- 17. C#错误传递一个新的结构变量给方法?
- 18. 结构传递变量在另一个类
- 19. 如何通过引用传递结构?
- 20. 如何使用postThreadMessage传递结构
- 21. 如何通过GET方法传递变量后获得自定义URL结构?
- 22. PHP将mysql结果传递给变量
- 23. 如何将结构向量传递给C++中的函数?
- 24. 如何将任意数量的结构体传递给函数?
- 25. 如何在Laravel Schema构建器中传递变量
- 26. 如何将条件拆分的结果传递给变量?
- 27. 如何在mysql_fetch_assoc中传递帖子变量结果
- 28. C#如何在一个数组变量中传递Datatable结果
- 29. 传递变量Javascript
- 30. 传递PHP变量
在什么编程语言? – 2010-05-04 02:52:16
正在使用c#lang .. – 2010-05-04 03:21:22