在我解决了上面链接中的最后一个问题后,我遇到了一个新问题,我尝试搜索一个已发布的问题,但我仍然对它印象深刻。
在最后一行我想用来Result(object)
查看,我不知道如何通过它。
问题出在最后一行(返回),它说
无法隐式转换类型“十进制”
谢谢你们 :)
namespace finance3.Models
{
public class Expected_and_Risk
{
public void Initialize(int size)
{
Prop = new decimal[size];
AxB = new decimal[size];
Forecast = new decimal[size];
PowAxB = new decimal[size];
Name = new string[size];
}
public decimal[] Prop { get; set; }
public decimal[] Forecast { get; set; }
public string[] Name { get; set; }
public decimal[] AxB { get; set; }
public decimal[] PowAxB { get; set; }
public decimal ExpectValue(Expected_and_Risk abc)
{
int count = abc.Forecast.Count();
Expected_and_Risk Result = new Expected_and_Risk();
Result.Initialize(count);
for (int i = 0 ; i < count ; i++)
{
Result.Name[i] = abc.Name[i];
Result.Prop[i] = abc.Prop[i];
Result.Forecast[i] = abc.Forecast[i];
Result.AxB[i] = abc.Prop[i] * abc.Forecast[i];
decimal a = Result.AxB[i];
decimal sumAxB =+ a;
double temp = (double)(a * a) ;
Result.PowAxB[i] = (decimal)(temp);
}
// here is the problem
return (Result);
}
}
}