ReSharper的建议改变的可访问一个公开
构造在摘要
类保护
,但它没有说明理由背后。
ReSharper suggests changing the accessibility of a public
constructor in an abstract
class to protected
, but it does not state the rationale behind this.
您可以提供一些线索?
很简单,因为公职使得在一个抽象类,没有任何意义。一个抽象类定义不能直接创建。它只能通过创建派生类型的实例被创建。因此,应该有机会获得一个构造函数的唯一类型派生类型,因此保护更有道理公众。它更准确地描述了易用性。
Simply because being public makes no sense on an abstract class. An abstract class by definition cannot be created directly. It can only be created by creating an instance of a derived type. Therefore the only types that should have access to a constructor are derived types and hence protected makes much more sense that public. It more accurately describes the accessibility.
上一篇:从URL加载图像插入一个图片图像、加载、图片、URL
下一篇:针对SQL Server 2008上运行时是否有SqlDataReader.HasRows一个错误?错误、Server、SQL、HasRows