Han*_*esh 0 c# inheritance properties
C#支持这个吗?这是什么语法?我希望这个属性的获取被密封(并不重要),并且这个集合是抽象的.我尝试了以下代码(语法不正确)来实现这个想法.
public sealed Texture target
{
get { return texture; }
}
public abstract Texture target { set; }
Run Code Online (Sandbox Code Playgroud)
和
public Texture target
{
sealed get { return texture; }
abstract set;
}
Run Code Online (Sandbox Code Playgroud)
我不知道这样做的语法,但是您可以轻松地实现一个从派生类的角度来看只会丑陋的变通方法:
public abstract class Base
{
private string name;
public string Name
{
get { return name; }
set { SetName(value); }
}
protected abstract void SetName(string value);
}
Run Code Online (Sandbox Code Playgroud)
另一方面,不清楚如何name(或texture在你的情况下)将被设置,除非它变成受保护的领域(ick,IMO).
你能提供一些关于你想要达到的目标的更多信息吗?可能有更好的方法.
| 归档时间: |
|
| 查看次数: |
1049 次 |
| 最近记录: |