You can use the DebuggerDisplay Attribut like in the sample shown below.
Sample C#
class Program
{
static void Main(string[] args)
{
var myPlayer = new Player
{
Firstname = "John",
Lastname = "Doe",
CreationDate = DateTime.Now,
Points = 9999
};
Console.WriteLine("Firstname={0}, Lastname={1}, Points={2}, CreationDate={3}", myPlayer.Firstname, myPlayer.Lastname, myPlayer.Points, myPlayer.CreationDate);
}
[DebuggerDisplay("Firstname={Firstname}, Lastname={Lastname}, Points={Points}, CreationDate={CreationDate}")]
public class Player
{
public string Firstname { get; set; }
public string Lastname { get; set; }
public long Points { get; set; }
public DateTime CreationDate { get; set; }
}
}
Sample VB.NET
Sub Main(args As String())
Dim myPlayer = New Player() With { _
.Firstname = "John", _
.Lastname = "Doe", _
.CreationDate = DateTime.Now, _
.Points = 9999 _
}
Console.WriteLine("Firstname={0}, Lastname={1}, Points={2}, CreationDate={3}", myPlayer.Firstname, myPlayer.Lastname, myPlayer.Points, myPlayer.CreationDate)
End Sub
<DebuggerDisplay("Firstname={Firstname}, Lastname={Lastname}, Points={Points}, CreationDate={CreationDate}")> _
Public Class Player
Public Property Firstname() As String
Get
Return m_Firstname
End Get
Set(value As String)
m_Firstname = Value
End Set
End Property
Private m_Firstname As String
Public Property Lastname() As String
Get
Return m_Lastname
End Get
Set(value As String)
m_Lastname = Value
End Set
End Property
Private m_Lastname As String
Public Property Points() As Long
Get
Return m_Points
End Get
Set(value As Long)
m_Points = Value
End Set
End Property
Private m_Points As Long
Public Property CreationDate() As DateTime
Get
Return m_CreationDate
End Get
Set(value As DateTime)
m_CreationDate = Value
End Set
End Property
Private m_CreationDate As DateTime
End Class
Result
it will be shown like this when debugging.
for more informations see the MSDN Using DebuggerDisplay Attribute

RT @CodeSnippetsNET: How to use the DebuggerDisplay Attribut: http://t.co/ULnblp5iMp #csharp #dotnet #vb
RT @CodeSnippetsNET: How to use the DebuggerDisplay Attribut: http://t.co/ULnblp5iMp #csharp #dotnet #vb