I have a method (AlphaCalcResult) that should return multiple values. Each forloop has some logic which assigns value to a List field. I would then like to return the result object with the two values generated from two loops described below. New to C# development and having issues with the syntax.
How can I have return statement do that in my code below?
public AlphaCalcResult CalculateAlpha(AlphaCalcParam param)
{
AlphaCalcResult result = new AlphaCalcResult
{
portfolios = new List<Portfolio>()
};
// Lists Portfolios & Settings
var portfolioListItem = param.portfolios.portfolioHoldings;
var scoreListItem = param.settings.grossAlphas;
// 1. CALCULATE FUND ALPHA
for (var i = 0; i<portfolioListItem.Count; i++)
{
portfolioListItem[i].fundRating = i;
for (var j = 0; j<scoreListItem.Count; j++)
{
scoreListItem[j].fundRating = j;
if(i == j)
{
portfolioListItem[i].fundAlpha = scoreListItem[j].grossAlpha - portfolioListItem[i].fundExpenseRatio;
}
}
}
//2. CALCULATE PORTFOLIO ALPHA
var portfolioAlphaResult = param.portfolios.portfolioAlpha;
for (var i =0; i<portfolioListItem.Count; i++)
{
portfolioAlphaResult = portfolioListItem[i].fundWeight * portfolioListItem[i].fundAlpha;
};
// populate result
return result;
}
portfolioAlphaResult, but never actually adding it toresult.portfolios.