C# Conversion

Can someone convert this for me?  When I convert this and try to use it, my var exception is always null and it shouldn't be as I am purposefully causing an exception to test this out.  When it encounters the while statement (perform until in .net Cobol) it will bypass the sb.appendline as exception is always null.

 

public static class ExceptionExtension
        {
            public static string ToFullBlownString(this System.Exception e, int level = int.MaxValue)
            {
                var sb = new StringBuilder();
                var exception = e;
                var counter = 1;
                while (exception != null && counter <= level)
                { 
                  sb.AppendLine($"{counter}-> Level: {counter}");
                  sb.AppendLine($"{counter}-> Message: {exception.Message}");
                  sb.AppendLine($"{counter}-> Source: {exception.Source}");
                  sb.AppendLine($"{counter}-> Target Site: {exception.TargetSite}");
                  sb.AppendLine($"{counter}-> Stack Trace: {exception.StackTrace}");

                  exception = exception.InnerException;
                  counter  ;
                }

            return sb.ToString();
            }
        }