Finding the person with the biggest loss For a course I following and my code is approved I had to make some code that finds the person with the biggest loss where the input is a string[] 

The string arrray looks like this : 

{ "Tom, 1, 3, -1", "Gillie, 2, 3, 1", "Thor, 1000, 1001, 1002" };


I solved it this way but it's not a clean way. I must say we were not allowed to use classes. that will be the next chapter of the course. 

My solution looks now like this : 

 public static string FindPersonWithBiggestLoss(string[] peopleAndBalances)
        {
            if (IsInValidInput(peopleAndBalances))
            {
                return InValidOutput;
            }

            var highestLossEver = decimal.MinValue;
            var personWithHighestLoss = new StringBuilder();

            for (int i = 0; i &lt;= peopleAndBalances.Length - 1; i++)
            {
                var currentPersonData = peopleAndBalances[i].Split(',');
                var allAmounts = currentPersonData[1..];

                // calculateLoss

                if (allAmounts.Length &lt;= 1)
                {
                    return InValidOutput;
                }

                for (int j = 0; j &lt; allAmounts.Length - 1; j++)
                {
                    try
                    {
                        var amount1 = decimal.Parse(allAmounts[j], NumberStyles.Currency | NumberStyles.Number);
                        var amount2 = decimal.Parse(allAmounts[j + 1], NumberStyles.Currency | NumberStyles.Number);
                        var lossForCurrentPerson = amount1 - amount2;

                        //check if loss is greater then the current highest loss
                        if (lossForCurrentPerson &gt; highestLossEver)
                        {
                            highestLossEver = lossForCurrentPerson;
                            personWithHighestLoss.Clear();
                            personWithHighestLoss.Append(currentPersonData[0]);
                        }
                    }
                    catch (FormatException ex)
                    {
                        Console.WriteLine($"there is not a valid character in the database. Reason{ex}");
                        break;
                    }
                }
            }

            if (personWithHighestLoss.ToString().Contains(','))
            {
                ReplaceCommaWithAnd(personWithHighestLoss);
            }

            return $"{personWithHighestLoss} lost the most money. -¤{highestLossEver}.";
    }


it works but also I need a lot of nested control statements to make it work.
Is there a cleaner way to make this work ?
A few things I noticed:

Using the range option of the array index(var allAmounts = currentPersonData[1..];) doesn't really help here.  All that's needed is to use the appropriate indexes of the original array.

It's quite inefficient to use a try block to test if a string is a valid number.  Using the tryParse method is much more efficient.

A hard coded currency symbol means that your output might not format properly on someone else's machine.  I would suggest using the format overload of the ToString method with the currency format.

I appears you're using a StringBuilder to change the name of whichever person has the highest loss.  If I'm not mistaken this will copy the string you already have.  I would suggest just use the string array itself.  This will be assigned by reference and won't require recopying the string.
This:

if (personWithHighestLoss[0].Contains(','))
{
    ReplaceCommaWithAnd(personWithHighestLoss);
}


doesn't really make much sense.  The Split method already removes the commas.  If you're worried about extra commas use the StringSplitOptions.RemoveEmptyEntries option of the Split method.

Here's what the modified code could look like:

public static string FindPersonWithBiggestLoss(string[] peopleAndBalances)
{
    if (IsInValidInput(peopleAndBalances))
    {
        return InValidInput;
    }

    var highestLossEver = decimal.MinValue;
    string[] personWithHighestLoss = new string[] { "" };

    for (int i = 0; i &lt;= peopleAndBalances.Length - 1; i++)
    {
        var currentPersonData = peopleAndBalances[i].Split(',',StringSplitOptions.RemoveEmptyEntries);

        // calculateLoss

        if (currentPersonData.Length &lt; 4)
        {
            return InValidInput;
        }

        for (int j = 1; j &lt; currentPersonData.Length - 1; j++)
        {
            var amount1 = 0.0M;
            var amount2 = 0.0M;
            if (!(decimal.TryParse(currentPersonData[j], NumberStyles.Currency | NumberStyles.Number, null, out amount1) &amp;&amp;
                decimal.TryParse(currentPersonData[j + 1], NumberStyles.Currency | NumberStyles.Number, null, out amount2)))
            {
                Console.WriteLine($"there is not a valid character in the database");
            }

            var lossForCurrentPerson = amount1 - amount2;

            //check if loss is greater then the current highest loss
            if (lossForCurrentPerson &gt; highestLossEver)
            {
                highestLossEver = lossForCurrentPerson;
                personWithHighestLoss = currentPersonData;
            }
        }

    }
    return $"{personWithHighestLoss[0]} lost the most money. -{highestLossEver.ToString("C")}.";
}