Where does Console.WriteLine go in Debug?

后端 未结 10 2128
后悔当初
后悔当初 2020-12-15 16:23

I found this question, but what I want to know is different - does the output from Console.WriteLine go anywhere when debugging? I know that for it to go to the output windo

10条回答
  •  时光取名叫无心
    2020-12-15 17:20

    The best solution for me was to change Console.WriteLine() to System.Diagnostics.Debug.WriteLine(). For example:

     catch (DbEntityValidationException dbEx)
     {
        foreach (var validationErrors in dbEx.EntityValidationErrors)
        {
           foreach (var validationError in validationErrors.ValidationErrors)
           {
              System.Diagnostics.Debug.WriteLine("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
           }
        }
    

    Then you can view your errors as an object in the output window.

提交回复
热议问题