我编写了一些代码,通过调用的标识符匹配两个数组,seqNum
并从一些数学中得到答案。我能够打印出我得到的seqNum
和 ,Answer
但我无法获取 . 随附的所有其他信息seqNum
。我希望能够输出这样的东西:
Name Date `seqNum` Answer...
seqNum
我的代码给了我答案,但它只是用不同的 s 和s一遍又一遍地吐出文件中的第一个 Name Answer
。
这是代码:
private void executeBtn_Click(object sender, EventArgs e)
{
//NET OIL VARIANCE MATHEMATICS
if (netOilRadBtn.Checked)
{
using (var sw = new StreamWriter("testNetOil.csv"))
{
var items = netOil.Zip(seqNum, (oil, seq) => new { Oil = oil, Seq = seq });
var items2 = netOil2.Zip(seqNum2, (oil, seq) => new { Oil = oil, Seq = seq });
sw.WriteLine("Lease Name, Field Name, Reservoir, Operator, County, ST, Majo, Resv Cat, Discount Rate, Net Oil Interest, Net Gas Interest, Working Interest, Gross Wells, Ultimate Oil, Ultimate Gas, Gross Oil, Gross NGL, Gross Gas, Net Oil, Net Gas, Net NGL, Revenue To Int., Oper. Expense, Total Invest., Revenue Oil, Revenue Gas, Operating Profit, Revenue NGL, Disc Net Income, SEQ, Well ID, INC ASN, Life Years, Own Qual, Production Tax, NET OIL VARIANCE");
foreach (var item in items.Join(items2, i => i.Seq, i => i.Seq, (a, b) => new
{SeqID = a.Seq, Answer = this.GetTheAnswer(Convert.ToDouble(a.Oil), Convert.ToDouble(b.Oil))
}))
{
int x = 0;
x.Equals(item.SeqID);
while (x != -1)
{
sw.WriteLine(leaseName[x] + "," + item.SeqID + "," + item.Answer);
x--;
}
所以基本上我只需要用正确的seqNum
and打印出匹配的名称Answer
。如果有人有任何想法或意见,将不胜感激。如果有人需要看,我的数学方法非常简单:
public double GetTheAnswer(double first, double second)
{
double answer = (first - second) / second;
return answer;
}