BasicKnowledgeCSharp/LessonsAndTasks/Lesson 62 - Свойства get, set ключевое слово value, авто-свойства/Program.cs

24 lines
403 B
C#
Raw Permalink Normal View History

2024-10-05 09:59:53 +03:00
using System;
/*
* Сыойства (Properties)
*
* Автоматические свойства (prop)
*/
class Point
{
private int x;
public void SetX(int x) => this.x = x;
public int GetX() => x;
}
class Program
{
static void Main()
{
Point point = new Point();
point.SetX(5);
Console.WriteLine(point.GetX());
Console.ReadKey();
}
}