litn2018
New member
- Joined
- Oct 27, 2024
- Messages
- 1
- Programming Experience
- 10+
this code has cs1061 error, even just use what github copilot suggested code:
C#:
public class LoanPerformance
{
public decimal Principal { get; set; }
}
public class AggregatedPerformance
{
public int LoanId { get; set; }
public decimal Principal { get; set; }
public virtual void Aggregate<TLoanPerformance, TAggregated>(IEnumerable<TLoanPerformance> loanPerformances, Action<TLoanPerformance> accumulator)
where TLoanPerformance : LoanPerformance
where TAggregated : AggregatedPerformance, new()
{
foreach (TLoanPerformance loanPerformance in loanPerformances)
{
this.Principal += loanPerformance.Principal;
accumulator(loanPerformance);
}
}
public void Aggregate<TLoanPerformance, TAggregated>(IEnumerable<TLoanPerformance> loanPerformances)
where TLoanPerformance : LoanPerformance
where TAggregated : AggregatedPerformance, new()
{
Aggregate<TLoanPerformance, TAggregated>(loanPerformances, _ => { });
}
}
public class CreditCardPerformance : LoanPerformance
{
public decimal CreditLimit { get; set; }
}
public class CCAggregatedPerformance : AggregatedPerformance
{
public decimal CreditLimit { get; set; }
public override void Aggregate<CreditCardPerformance, CCAggregatedPerformance>(IEnumerable<CreditCardPerformance> loanPerformances, Action<CreditCardPerformance> accumulator)
{
base.Aggregate<CreditCardPerformance, CCAggregatedPerformance>(loanPerformances,
(_perf) =>
{
var creditCardPerf = _perf as CreditCardPerformance;
if (creditCardPerf != null)
{
this.CreditLimit += creditCardPerf.CreditLimit; // Error CS1061 'CreditCardPerformance' does not contain a definition for 'CreditLimit' and no accessible extension method 'CreditLimit' accepting a first argument of type 'CreditCardPerformance' could be found(are you missing a using directive or an assembly reference ?)
}
});
}
}
Last edited by a moderator: