Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 1559

C# Conversion

$
0
0

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.

 

publicstaticclass ExceptionExtension
        {publicstaticstring 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();
            }
        }

Viewing all articles
Browse latest Browse all 1559

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>