Advertisement
Caminhoneiro

Debugger with a display attributte

Jul 16th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1.     [DebuggerDisplay("This person is called {Name} and is {AgeInYears} years old")]
  2.     class PersonWithDebuggerDisplay
  3.     {
  4.         [DebuggerDisplay("{AgeInYears} years old")]
  5.         public int AgeInYears { get; set; }
  6.         public string Name { get; set; }
  7.     }
  8.  
  9.  
  10. //Test
  11.  
  12.  
  13.  
  14.         [TestMethod]
  15.         public void With()
  16.         {
  17.             var p = new PersonWithDebuggerDisplay
  18.                         {
  19.                             AgeInYears = 50,
  20.                             Name = "Sarah"
  21.                         };
  22.         }
  23.  
  24.  
  25.  
  26.  
  27.         // DebuggerDisplay can be applied to:
  28.         //Classes
  29.         //Structs
  30.         //Delegates
  31.         //Enums
  32.         //Fields
  33.         //Properties
  34.         //Assemblies
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement