Guest User

Untitled

a guest
May 26th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.41 KB | None | 0 0
  1. public class CanBeReadOnly<T>
  2. {
  3.     private T _value;
  4.  
  5.     public CanBeReadOnly(T value, bool readOnly)
  6.     {
  7.         _value = value;
  8.         IsReadOnly = readOnly;
  9.     }
  10.  
  11.     public T Value
  12.     {
  13.         get { return _value; }
  14.         set
  15.         {
  16.             if (!IsReadOnly)
  17.             {
  18.                 _value = value;
  19.             }
  20.         }
  21.     }
  22.  
  23.     public bool IsReadOnly { get; set; }
  24. }
Add Comment
Please, Sign In to add comment