> ## Content Index
> Fetch the complete content index at: https://blog.jsinh.in/llms.txt
> Use this file to discover other available public pages before exploring further.

# DebuggerDisplay in C# comes handy when debugging
- URL: https://blog.jsinh.in/debuggerdisplay-in-c-comes-handy-when-debugging/
- Published: 2014-08-03T12:44:00.000Z
- Updated: 2026-07-07T15:10:36.000Z
- Author: Jsinh
- Tags: #Import 2026-10-04 19:16

One thing a developer does all the time is debugging code, very obvious. At times the value of property or output of a method you are interested in might be deep inside a class.

While debugging you would frequently add them to quick watch window or pin (bookmark) them to reach out quickly.

One productivity tip is that you can use `DebuggerDisplay` on entities to make it quickly accessible while debugging.

Let's take a simple class as example:

```
namespace DebuggerDisplaySample
{
    using System;
    using System.Diagnostics;
    using System.Globalization;

    public class Program
    {
        public static void Main(string[] args)
        {
            var programInstance = new Program();
            programInstance.LastSavedDateTime = DateTime.ParseExact(
                "21-05-1985 12:12 PM",
                "dd-MM-yyyy hh:mm tt",
                CultureInfo.InvariantCulture,
                DateTimeStyles.None);
            Console.ReadLine();
        }

        public DateTime LastSavedDateTime { get; set; }
    }
}

```

Here when you debug and hover on the programInstance or pin it (bookmark) it will show you the full name of the class as `DebuggerDisplaySample.Program`.

To access the `LastSavedDateTime` value you will have to expand the object further.

![DebuggerDisplay - Before](https://blob.jsinh.in/media/2014/08/03/SS01-DebuggerDisplay-Before.png)

Now add `DebuggerDisplay` attribute from `System.Diagnostics` on the `Program` class to see the change:

```
namespace DebuggerDisplaySample
{
    using System;
    using System.Diagnostics;
    using System.Globalization;

    [DebuggerDisplay("{LastSavedDateTime}")]
    public class Program
    {
        public static void Main(string[] args)
        {
            var programInstance = new Program();
            programInstance.LastSavedDateTime = DateTime.ParseExact(
                "21-05-1985 12:12 PM",
                "dd-MM-yyyy hh:mm tt",
                CultureInfo.InvariantCulture,
                DateTimeStyles.None);
            Console.ReadLine();
        }

        public DateTime LastSavedDateTime { get; set; }
    }
}

```

For attribute input we have passed `{LastSavedDateTime}` which is a property in program class. The `{` braces indicates the runtime to fetch the value of property named `LastSavedDateTime` and display it instead of the class name (which is debugging default behavior).

After doing this when you run and debug, you will see the value of `LastSavedDateTime` property on hover or pinning of `programInstance` variable.

![DebuggerDisplay - After](https://blob.jsinh.in/media/2014/08/03/SS02-DebuggerDisplay-After.png)

This is not only limited to class and / or properties - refer [MSDN](https://msdn.microsoft.com/en-us/library/x810d419.aspx?ref=blog.jsinh.in) to find out more ways to optimize your debugging time.

Happy coding !!