jwood803
8/24/2013 - 6:42 PM

Showing the DebuggerDisplay attribute in .NET.

Showing the DebuggerDisplay attribute in .NET.

[DebuggerDisplay("Rate - {InsuranceRate} Age (months) - {AgeInMonths}")]
public class Car
{
 public decimal InsuranceRate { get; set; }
 public int AgeInMonths { get; set; }
 public int NumberOfMiles { get; set; }
 public int NumberOfPreviousOwners { get; set; }
 public int NumberOfCollisions { get; set; }
}
[DebuggerDisplay("{ToString, nq}")]
public class Car
{
   public decimal InsuranceRate { get; set; }
   public int AgeInMonths { get; set; }
   public int NumberOfMiles { get; set; }
   public int NumberOfPreviousOwners { get; set; }
   public int NumberOfCollisions { get; set; }
 
   public override string ToString()
   {
      return string.Format("Rate - {0}. Age (months) - {1}.", this.InsuranceRate, this.AgeInMonths);
   }
}
public class Car
{
   public decimal InsuranceRate { get; set; }
   public int AgeInMonths { get; set; }
   public int NumberOfMiles { get; set; }
   public int NumberOfPreviousOwners { get; set; }
   public int NumberOfCollisions { get; set; }
}