5
Contributors
7
Replies
8
Views
5 Years
Discussion Span
Last Post by divin757
0

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.");
        }
    }
0

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

0

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

0

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

0

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.