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. 如何将值传递给结构变量,然后将结构写入文件?
- 7. 递增结构变量
- 8. 将内部变量传递给结构构造函数C++
- 9. 如何传递变量routes.index
- 10. 如何传递变量ejs.compile
- 11. 结构化变量传递给方法变为零?
- 12. 如何将结构传递给NSOperation Init
- 13. 如何使用postThreadMessage传递结构
- 14. 如何通过引用传递结构?
- 15. 如何通过引用传递结构?
- 16. 结构传递变量在另一个类
- 17. C++传递变量 “结构” 型的作为参考(&)或由值
- 18. 传递一个结构的内容,另一个变量用C
- 19. 访问结构成员变量传递到功能
- 20. C#错误传递一个新的结构变量给方法?
- 21. 传递变量
- 22. 传递变量
- 23. 传递变量
- 24. 传递变量
- 25. 传递变量
- 26. 传递变量
- 27. 传递变量
- 28. 传递变量
- 29. 传递变量
- 30. 传递变量
在什么编程语言? – 2010-05-04 02:52:16
正在使用c#lang .. – 2010-05-04 03:21:22