Hi, i made a class in a win form app in c#. I want to open the class/degbue it when someone presses button3.
How do i do that?

Do this:

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MyClass mc = new MyClass();
            mc.MyMethod();
        }
    }

    public class MyClass
    {
        public void MyMethod()
        {
            System.Windows.Forms.MessageBox.Show("This is a message from my class.");
        }
    }

This is the code in my class:

static void main(string[] args)
        {
            string kommando = Console.ReadLine();
            if (kommando == "areal")
            {
                Console.WriteLine("k = kvadrat");
                Console.WriteLine("r = rektangel");
                Console.WriteLine("t = trekant");
                Console.WriteLine("s = sirkel");
console.readkey();
}

How will it be then? :L

This is the code in my class:

static void main(string[] args)
        {
            string kommando = Console.ReadLine();
            if (kommando == "areal")
            {
                Console.WriteLine("k = kvadrat");
                Console.WriteLine("r = rektangel");
                Console.WriteLine("t = trekant");
                Console.WriteLine("s = sirkel");
console.readkey();
}

How will it be then? :L

I want to show the class in a console app when someone presses button3

What do you mean by "show it"? Classes aren't things you 'show'. They have methods and properties that you get, set or call.

This article has been dead for over six months. Start a new discussion instead.