В чем отличие свойств от полей? - C#
Формулировка задачи:
Кто может просто объяснить?
Решение задачи: «В чем отличие свойств от полей?»
textual
Листинг программы
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication9
{
static class dd
{
private static int d = 2;
public static int D
{
get
{
return d;
}
set
{
if (d == 2)
{
d = value;
}
}
}
}
class Program
{
static void Main(string[] args)
{
dd.D = 55;
dd.D = 666;
}
}
}