Copy object values in Visual Studio debug mode

前端 未结 12 740
轻奢々
轻奢々 2021-01-29 19:17

In Visual Studio debug mode it\'s possible to hover over variables to show their value and then right-click to \"Copy\", \"Copy Expression\" or \"Copy Value\".

In case t

12条回答
  •  感动是毒
    2021-01-29 19:47

    I know I'm a bit late to the party, but I wrote a JSON implementation for serializing an object, if you prefer to have JSON output. Uses Newtonsoft.Json reference.

    private static void WriteDebugJSON (dynamic obj, string filePath)
    {
        using (StreamWriter d = new StreamWriter(filePath))
        {
            d.Write(JsonConvert.SerializeObject(obj));
        }
    }
    

提交回复
热议问题