using System;
namespace _001_004_017_Property
{
class Program
{
static void Main(string[] args)
{
Classe classe = new Classe(10);
Console.WriteLine(classe.AutoImplementedProperty = 1);
Console.WriteLine(classe.AutoImplementedReadOnlyProperty);
Console.WriteLine(classe.BackingField = 100);
Console.WriteLine(classe.ReadOnlyProperty);
classe.WriteOnlyProperty = 10000;
Console.ReadKey();
}
}
class Classe
{
public Classe(int autoImplementedReadOnlyProperty)
{
this.AutoImplementedReadOnlyProperty = autoImplementedReadOnlyProperty;
}
public int AutoImplementedProperty { get; set; }
public int AutoImplementedReadOnlyProperty { get; private set; }
private int backingField;
public int BackingField
{
get { return backingField; }
set { backingField = value; }
}
private int readOnlyProperty = 1000;
public int ReadOnlyProperty
{
get { return readOnlyProperty; }
}
private int writeOnlyProperty;
public int WriteOnlyProperty
{
set
{
writeOnlyProperty = value;
Console.WriteLine(">> atribuiu valor {0} à variável", value);
}
}
}
}