Consider the following class:
[DebuggerDisplay("{GetType().Name,nq}: FileName = {FileName,nq}")]
public class FileWrapper
{
public string FileName { get; set; }
public bool IsTempFile { get; set; }
public string TempFileName { get; set; }
}
I would like to add a debugger display based on the IsTempFileName
property. I would like to add the string , TempFileName = {TempFileName,nq}
when the instance is a temp file. How would I achieve something this?
You can use the conditional operator (?:)
[DebuggerDisplay("{GetType().Name,nq}: FileName = {FileName,nq}{IsTempFile ? \", TempFileName: \" + TempFileName : System.String.Empty,nq}")]
IsTempFile == false
IsTempFile == true