tags:

views:

260

answers:

3

So I have the declaration at the beginning of my class file

using System.Windows.Forms;

But when I try to issue the statement

MessageBox.Show("Pow");

I receive the error

Error   2   'System.Windows.Forms.MessageBox.Show(System.Windows.Forms.IWin32Window, string)' is a 'method' but is used like a 'type'

Complete code:

using System.Windows.Forms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Contacts
{
    class AnotherClass
    {
        MessageBox.Show("Pow");
    }   
}

I can't seem to find any reason for this. The other oddity is that when I type MessageBox, Intellisense finds it, but after placing my ( . ) I don't receive the typical menu of method options from that class such as "Show".

Any thoughts?

+1  A: 

I figured it out nevermind. The principal of Class which can contain methods, properties and field declarations.

pghtech
A: 

I have the same problem. What exactly was your fix.

octalsys
A: 

Got it. Should have renamed Main() to NotMain() in Program.cs then added code to AnotherClass. The code should look like this.

class AnotherClass
{
    public static void Main()
    {
        MessageBox.Show("Pow!);
    }
}

Not exactly why but it works... newbie

octalsys