Reference.cs 736 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Collections.Generic;
  3. namespace Utilities
  4. {
  5. public class Reference<T> where T : struct
  6. {
  7. T m_value;
  8. public Reference(T value)
  9. {
  10. m_value = value;
  11. }
  12. public T Value
  13. {
  14. get { return m_value; }
  15. set { m_value = value; }
  16. }
  17. public override string ToString()
  18. {
  19. return m_value.ToString();
  20. }
  21. public static implicit operator T(Reference<T> wrapper)
  22. {
  23. return wrapper.Value;
  24. }
  25. public static implicit operator Reference<T>(T value)
  26. {
  27. return new Reference<T>(value);
  28. }
  29. }
  30. }