Advertisement
nahidjamalli

Lesson #10

Apr 12th, 2020
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.55 KB | None | 0 0
  1. using System;
  2.  
  3. namespace MyNamespace
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             MyClass my = new MyClass();
  10.             my.a = 1465;
  11.             my.a = 945;
  12.             Console.WriteLine(my.a);
  13.         }
  14.     }
  15.  
  16.     class MyClass
  17.     {
  18.         private int myValue;
  19.  
  20.         public int a
  21.         {
  22.             get
  23.             {
  24.                 return myValue;
  25.             }
  26.             set
  27.             {
  28.                 if (value > 90)
  29.                     myValue = value;
  30.             }
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement