The Rect
struct does not override ToString
. Therefore converting it to string will only yield the full type name. Nothing else.
Try
string s = String.Format("left = {0}, top = {1}, right = {2}, bottom = {3}",
NotepadRect.Left, NotepadRect.Top, NotepadRect.Right, NotepadRect.Bottom);
MessageBox.Show(s);
Alternatively you could override ToString
in Rect
:
public struct Rect
{
public int Left { get; set; }
public int Top { get; set; }
public int Right { get; set; }
public int Bottom { get; set; }
public override string ToString()
{
return String.Format("left = {0}, top = {1}, right = {2}, bottom = {3}",
Left, Top, Right, Bottom);
}
}
Then MessageBox.Show(NotepadRect)
will work as expected.