469,623 Members | 1,409 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,623 developers. It's quick & easy.

How to show the value of a private variable in some debug window? (C# Express)

Let's say I have a Person class with a private int age member variable. I
have a get and set accessor for the Age property. When I am running the code
in debug mode, I would like to have a debug window show me the value of age
(rather than the value of the Age property). Is there a way to do this?

Thanks!
Jun 24 '06 #1
2 2332

Yes, certainly there are ways. For example you have the code similar to
this.

public class Person
{
private Int32 _Age;

public Int32 Age
{
set {
_Age = value;
System.Diagnostics.Debug.Write(_Age.ToString());
}
get {
return _Age;
}
}
}

Check out the line System.Diagnostics.Debug.Write(_Age.ToString());
which prints the value of the _Age in the debug window.

Let us know if you have any trouble in doing this.

-
Vadivel Kumar
http://www.vadivelk.net
Johann Schuler wrote:
Let's say I have a Person class with a private int age member variable. I
have a get and set accessor for the Age property. When I am running the code
in debug mode, I would like to have a debug window show me the value of age
(rather than the value of the Age property). Is there a way to do this?

Thanks!


Jun 24 '06 #2
> prints the value of the _Age in the debug window

Vadivel:

I am using C# Express edition and I cannot get a "debug" window as such.
While running in debug mode, the windows I can get under Debug -> Windows
are: Output, Locals, Watch, Immediate, and Call Stack. None of these windows
will display _Age. Could this be a limitation of the Express edition?

Johann (newbie)

"Vadivel Kumar" <va*****@gmail.com> wrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...

Yes, certainly there are ways. For example you have the code similar to
this.

public class Person
{
private Int32 _Age;

public Int32 Age
{
set {
_Age = value;
System.Diagnostics.Debug.Write(_Age.ToString());
}
get {
return _Age;
}
}
}

Check out the line System.Diagnostics.Debug.Write(_Age.ToString());
which prints the value of the _Age in the debug window.

Let us know if you have any trouble in doing this.

-
Vadivel Kumar
http://www.vadivelk.net
Johann Schuler wrote:
Let's say I have a Person class with a private int age member variable. I
have a get and set accessor for the Age property. When I am running the
code
in debug mode, I would like to have a debug window show me the value of
age
(rather than the value of the Age property). Is there a way to do this?

Thanks!

Jun 24 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by marane moll | last post: by
4 posts views Thread by Thomas Anderson | last post: by
3 posts views Thread by Mike Turco | last post: by
3 posts views Thread by jeko | last post: by
5 posts views Thread by risha | last post: by
7 posts views Thread by Thomas Pecha | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.