我有一个名为KeyRatioSymbol的基类。 我有一个继承自KeyRatioSymbol的类,名为GuruFocusKeyRatioSymbol。未找到继承的成员
KeyRatioSymbol有这个更新方法:
/// <summary>
/// Updates an existing key ratio symbol by setting the values from the new <see cref="KeyRatioSymbol"/>.
/// </summary>
public virtual void Update<T>(T newKeyRatioSymbol) where T : KeyRatioSymbol
{
this.Identifier = newKeyRatioSymbol.Identifier;
}
GuruFocusKeyRatioSymbol定义成员CurrencyId并希望重写更新方法,以包括新CurrencyId更新时:
private int _CurrencyId;
/// <summary>
/// Gets or sets the CurrencyId
/// </summary>
public int CurrencyId { get { return this._CurrencyId; } set { this.SetProperty(ref this._CurrencyId, value); } }
public override void Update<GuruFocusKeyRatioSymbol>(GuruFocusKeyRatioSymbol newKeyRatioSymbol)
{
base.Update(newKeyRatioSymbol);
this.CurrencyId = x.CurrencyId; // Compiler error
}
现在,编译器会抱怨:“GuruFocusKeyRatioSymbol '不包含'CurrencyId'的定义...
为什么编译器找不到CurrencyId mem eber在类GuruFocusKeyRatioSymbol?
问候!
@AluanHaddad - 当然是;基类定义了“T”的泛型类型参数,而派生类将类型参数提供为“GuruFocusKeyRatioSymbol”。 –
从'this.CurrencyId = x.CurrencyId',其中是否定义了'x'? –
如果我们能在这里看到一个更完整的例子,那将会很棒。对于我们所知道的,你在某个地方的某个类名上做了一个拼写错误,而“this”或“x”的类型不是你认为的那种类型。 – David