daily pastebin goal
1%
SHARE
TWEET

Untitled

a guest Feb 11th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class MyClass
  2.     {
  3.         //1 - read and write property short record
  4.         public string Name1 { get; set; } = "Name1 content";
  5.  
  6.         //2 - variable instead of property from 1 ex.
  7.         public string Name2 = "Name2 content";
  8.  
  9.         //3 - read and write property long record
  10.         private string _name3 = default(string);
  11.         public string Name3
  12.         {
  13.             get => _name3;
  14.             set => _name3 = value;
  15.         }
  16.  
  17.         //4 - read and write property with checking of value
  18.         private string _name4 = default(string);
  19.         public string Name4
  20.         {
  21.             get
  22.             {
  23.                 return _name4;
  24.             }
  25.             set
  26.             {
  27.                 if (value.Length >= 3)
  28.                     _name4 = value;
  29.             }
  30.         }
  31.  
  32.         //5 - read only property short record
  33.         public string Name5 { get; } = "Name5 content";
  34.  
  35.         //6 - read only variable
  36.         public static readonly string Name6 = "Name6 content";
  37.  
  38.         //7 - read (public) and write (in class range) property
  39.         private string _name7 = default(string);
  40.  
  41.         public MyClass(string n)
  42.         {
  43.             this._name7 = n;
  44.         }
  45.  
  46.         public string Name7
  47.         {
  48.             get => _name4;
  49.             private set => _name7 = value;
  50.         }
  51.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top