Jump to content

Variable to Debug Window

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
Void

Void

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 411 posts
Is there a way to output the valiue of a variable to the debug window?

Say variable _Mon
Void

#2
brackett

brackett

    Programmer

  • Members
  • PipPipPipPip
  • 192 posts
In VS, you can just do ?_Mon in the immediate window, or add a watch.

#3
RobSoftware

RobSoftware

    Programmer

  • Members
  • PipPipPipPip
  • 143 posts
I just created a program real quick that does what you ask:


using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;


namespace debugTest

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }


        private void button1_Click(object sender, EventArgs e)

        {

            String _Mon = "TEST";

            System.Diagnostics.Debug.WriteLine(_Mon);

        }

    }

}



"brackett" said:

In VS, you can just do ?_Mon in the immediate window, or add a watch.


I'm not sure what you mean brackett - how do I add a watch in VS?

#4
brackett

brackett

    Programmer

  • Members
  • PipPipPipPip
  • 192 posts

RobSoftware said:

I'm not sure what you mean brackett - how do I add a watch in VS?

I assumed that Void was interested in knowing the value while debugging. In that case, in the VS debugger you can (a) use the immediate window and type "?variableName" which will print the value, (b) hover over the declaration and a tooltip will show you the value, or © add to the QuickWatch window by just typing the name in.

Of course, a Debug.WriteLine like you have will work as well.