public List <string> handleParant(List <string> toCalc) { int parantIndex; int closeParentIndex = 0; while ((parantIndex = toCalc.FindIndex(r => r.Equals("("))) != -1) { List <string> tempList = new List <string>(); int numParant = 1; int foundEndParent = 0; int i = parantIndex + 1; while (foundEndParent != numParant) { tempList.Add(toCalc[i]); if (toCalc[i].Equals("(")) { numParant++; } if (toCalc[i].Equals(")")) { foundEndParent++; } if (foundEndParent == numParant) { closeParentIndex = i; } i++; } //Trouve l'index de la parenthese fermante tempList.RemoveAt(tempList.Count - 1); //Supprime la parenthese fermante //s'il n'y a pas de parentheses dans les parentheses if (!tempList.Contains("(")) { calcMaking("*", tempList); calcMaking("/", tempList); calcMaking("-", tempList); calcMaking("+", tempList); if (toCalc.Contains("(")) { for (int x = parantIndex; x < closeParentIndex + 1; x++) { toCalc.RemoveAt(parantIndex); } toCalc.Add(tempList[0]); } } else { List <string> tmp = handleParant(tempList); for (int x = parantIndex; x < closeParentIndex + 1; x++) { toCalc.RemoveAt(parantIndex); } calcMaking("*", tmp); calcMaking("/", tmp); calcMaking("-", tmp); calcMaking("+", tmp); toCalc.Insert(parantIndex, tmp[0]); } } return(toCalc); }