Hi all I'm new to C#.
I try to return a result "totalAmount" from my method called "GetAllKschl". In this method I returned a list with "KSCHL, KSCHLData, price, pieces und totalPrice".
So in my new method I need the total amount of all "totalPrice" together.
first method:
public List<Result> GetAllKschl(string fileNameResult, string fileNameData)
{
List<Result> listResult = new List<Result>();
docResult.Load(fileNameResult);
docData.Load(fileNameData);
var resultList = docResult.SelectNodes("//root/CalculationLogCompact/CalculationLogRowCompact");
foreach (XmlNode nextText in resultList)
{
XmlNode KSCHL = nextText.SelectSingleNode("KSCHL");
string nextKschl = KSCHL.InnerText;
// ... and so on...
if (pieces > 0 && totalPrice > 0)
{
listResult.Add(new Result(nextKschl, nextKSCHLData, nextEinzelpreis, pieces, totalPrice));
}
}
return listResult;
}
second method: (don't know exactly what to do)
public decimal GetTotalAmount(string amount, string totalAmount)
{
string total = GetAllKschl(amount, totalAmount); // ??
return total;
}
So here I want to have just the TotalAmount (every totalPrice from GetAllKschl) und not the whole list from GetAllKschl. How do I do this?
here my class result:
public class Result
{
public string KSCHL { get; set; }
public string Info { get; set; }
public int individualPrice { get; set; }
public int Pieces { get; set; }
public int TotalCosts { get; set; }
public Result(string kschl, string info, int individualPrice, int pieces, int totalCosts)
{
KSCHL = kschl;
Info = info;
IndividualPrice = individualPrice;
Pieces = pieces;
TotalCosts = totalCosts;
}
}