# A Guide to Using DebuggerDisplay Attribute for Better Debugging

The DebuggerDisplayAttribute helps provide meaningful information about complex objects while debugging the application. Consider the following example where we set a breakpoint on the productList. In order to view the difference, comment out DebuggerDisplayAttribute and see what data we are viewing in the debugger window. we can see a list of products, but the details are not immediately visible, requiring us to expand each complex object to view its properties.

```csharp
using System;
using System.Collections.Generic;
using System.Diagnostics;

[DebuggerDisplay("Product name - {Name} and Product id - {Id}")]
public class Product
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
}

public class Program
{
    public static void Main(string[] args)
    {
        var products = new List<Product>()
        {
            new Product { Id = 1,Name="Product 1", Description="Product1 descriptio"},
            new Product { Id = 2,Name="Product 2", Description="Product2 descriptio"},
            new Product { Id = 3,Name="Product 3", Description="Product3 descriptio"},
            new Product { Id = 4,Name="Product 4", Description="Product4 descriptio"},
            new Product { Id = 5,Name="Product 5", Description="Product5 descriptio"}
        };
        var productsList = products;        
        Console.WriteLine($"{productsList.Count}");
    }
}
```

Remove commented code and see the difference.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1721311026618/1676a3a8-9e0d-4e48-91f5-0dda0beaf046.png align="center")

This technique is really useful when i was debugging some complex objects.
