Is there a ToString() generator available in Visual Studio 2010?

前端 未结 11 840
伪装坚强ぢ
伪装坚强ぢ 2021-01-03 17:39

Is there any way to generate a ToString() using Visual Studio 2010?

I really don\'t want to do this by hand!

[EDIT]

I\'m looking for a s

11条回答
  •  感动是毒
    2021-01-03 18:12

    You can use the StatePrinter project

    class AClassWithToString
    {
      string B = "hello";
      int[] C = {5,4,3,2,1};
    
      // Nice stuff ahead!
      static readonly StatePrinter printer = new StatePrinter();
      public override string ToString()
      {
        return printer.PrintObject(this);
      }
    }
    

提交回复
热议问题