Points to remember while setting debugger display:
- Debugger identifies only the Property name placed inside the curly brace {Property}.
- Example: {Name}={PropertyName}.
- Nested Class Example : {ClassName.PropertyName}={Product.Name}.
Step 1: Used Namespaces
using System;
using System.Diagnostics;
Step 2: Usage
protected void Page_Load(object sender, EventArgs e)
{
Book book = new Book();
book.Name = "Practical Demo";
book.Title = "CSharp";
book.Register = DateTime.Today;
Product product=new Product();
book.Product = product;
}
Step 3: Class for Demo
[DebuggerDisplay("BookTitle{Title}-- {Name} , {Register}--{Product.Name}")]
public class Book
{
public string Title;
public DateTime Register;
public string Name;
public Product Product;
}
Step 4: Nested Class for Demo
[DebuggerDisplay("ProductName{Name}")]
public class Product
{
public string Name;
}
Step 5: Format of Class Debugger Display
[DebuggerDisplay("ProductName{Name}")]
Step 6: Format of Nested Class Debugger Display
[DebuggerDisplay("BookTitle{Title}-- {Name} , {Register}--{Product.Name}")]
Step 7: Output
Code Snippet:
using System;
using System.Diagnostics;
namespace SampleApplication.New
{
public partial class DebuggerDisplatClass : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Book book = new Book();
book.Name = "Practical Demo";
book.Title = "CSharp";
book.Register = DateTime.Today;
Product product=new Product();
product.Name = "Programming";
book.Product = product;
}
}
[DebuggerDisplay("BookTitle{Title}-- {Name} , {Register}--{Product.Name}")]
public class Book
{
public string Title;
public DateTime Register;
public Product Product;
}
[DebuggerDisplay("ProductName{Name}")]
public class Product
{
public string Name;
}
}
Thanks for reading this blog. Have a nice day.