List, , GetRange List, , , 2 4 . , .
int left = cardGameValue(new List<int>(D.GetRange(1, D.Count - 1)), myScore + D[0], opponentScore);
int right = cardGameValue(new List<int>(D.GetRange(0, D.Count - 1)), myScore + D[D.Count - 1], opponentScore);
, , startIndex length, cardGameValue List.
static int cardGameValue(List<int> D, int startIndex, int length, int myScore, int opponentScore)
, :
int left = cardGameValue(D, startIndex + 1, length - 1, myScore + D[startIndex], opponentScore);
int right = cardGameValue(D, startIndex, length - 1, myScore + D[startIndex + length - 1], opponentScore);
i.e. Code that refers to an index 0, such as D[0]and D.RemoveAt(0), will need to be modified to use startIndex, such as D[startIndex]and D.RemoveAt(startIndex). The code that refers to D.Countshould be replaced by startIndex + length. Correction: code that refers to D.Count - 1should be replaced either length - 1by or startIndex + length - 1(depending on context), but code that just refers to D.Countwill simply be replaced by length.