Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication56
- {
- class Program
- {
- static void Main(string[] args)
- {
- Student student = new Student(5);
- Console.WriteLine(student.GetAge);
- Student2 student2 = new Student2();
- student2.CheckAge = 3;
- Console.WriteLine(student2.CheckAge);
- }
- }
- class Student
- {
- public Student(int age)
- {
- GetAge = age;
- }
- public int GetAge { get; private set; }
- }
- class Student2
- {
- private int _age;
- public int CheckAge
- {
- get
- { return _age; }
- set
- {
- if (value <= 0)
- _age = 0;
- else
- _age = value;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement