Question

enter image description here

How do i write to console while compiling a windows application in SharpDevelop? I'd like to see which random numbers are generated in a certain method for debugging purposes.

Was it helpful?

Solution

If you want to view compiling output, then select "Output" from "View" menu. Output window will appear at bottom of SharpDevelop. Select "Build" from drop-down list.

SharpDevelop Output Menu item and Output Window

Debug output will appear when "Debug" selected for output.

SharpDevelop debug output

Console.Output will never appear anywhere inside IDE - SharpDevelop didn't catch this. You can see it only inside console window of your application.

Code from last screenshoot:

using System;
using System.Diagnostics;
using System.Windows.Forms;

namespace TestApp
{
    class MainForm : Form
    {
        private Random rd;
        private const int buttonsCount = 42;

        public MainForm()
        {
            rd = new Random();
            Text = "Click on me!";
        }

        protected override void OnClick(EventArgs e)
        {
            compMode();
        }   

        public void compMode()
        {
            int rn = rd.Next(1, buttonsCount);
            Debug.WriteLine("rn is {0}", rn);
        }

        public static void Main(string[] args)
        {
            Application.Run(new MainForm());
        }
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top