我有一個名爲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