Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MyClass
- {
- //1 - read and write property short record
- public string Name1 { get; set; } = "Name1 content";
- //2 - variable instead of property from 1 ex.
- public string Name2 = "Name2 content";
- //3 - read and write property long record
- private string _name3 = default(string);
- public string Name3
- {
- get => _name3;
- set => _name3 = value;
- }
- //4 - read and write property with checking of value
- private string _name4 = default(string);
- public string Name4
- {
- get
- {
- return _name4;
- }
- set
- {
- if (value.Length >= 3)
- _name4 = value;
- }
- }
- //5 - read only property short record
- public string Name5 { get; } = "Name5 content";
- //6 - read only variable
- public static readonly string Name6 = "Name6 content";
- //7 - read (public) and write (in class range) property
- private string _name7 = default(string);
- public MyClass(string n)
- {
- this._name7 = n;
- }
- public string Name7
- {
- get => _name4;
- private set => _name7 = value;
- }
- }
Add Comment
Please, Sign In to add comment