我曾经了解到自动实现的属性不能只读或只写,它们只能是读写的。
然而,在学习接口时,我发现了以下代码,它创建了一个可读/仅写和读写类型的自动属性。这样做是否可行?
public interface IPointy
{
// A read-write property in an interface would look like:
// retType PropName { get; set; }
// while a write-only property in an interface would be:
// retType PropName { set; }
byte Points { get; }
}