DISCSHOP NZEC error for C# code

I was trying to solve “Discount shop” and below is my piece of code.

int task = Convert.ToInt32(Console.ReadLine());
            long[] results = new long[task];
            long min;
            char[] numberDigits;
            long num;
            while (task-- > 0)
                min = Convert.ToInt64(Console.ReadLine().Trim());
                foreach(char x in min.ToString().ToArray())
                    num = Convert.ToInt64(String.Join("", min.ToString().ToArray().Where(y => y != x)));
                    min = (num < min) ? num : min;
                results[task] = (min);

            foreach(int rs in results.Reverse())

I’m not sure what am I missing.

To avoid unwanted values, I used try catch block as well, but ended up getting wrong answer