Hi there just a quick question I am using C#Express. When I add the reference System.Windows.Forms I cannot seem to access Messagebox.Show...any ideas what I am doing wrong?

Btw this is in a console application...

Surely this is a quick fix that someone knows about...doing my head in...can access MessageBox members fine in forms app but cannot access it in console app!!

Do you have this namespace in the References (Solution explorer tab)?
Otherwise you can try with writing the full path:

System.Windows.Forms.MessageBox.Show("buuu");

Im such a dork..thanks for your help...I had the using System.Windows.Forms namespace defined but didnt add the reference.

just one more question, could you explain the reason behind adding the reference when you right click on your project...

I understand the reason for adding the namespace at the top..so that you dont have to keep writing the whole path...

i dont see why just declaring that i am using the System.Windows.Forms would be enough??

Hope i make sense and thanks for your help!

1st, what is in the References (Solution explorer), you can use as namespaces. If the namespace (like you wanted to use MessageBox) does not exist in the References, it cannot be used at all.
So 1st is the References (if there is no, you can simlpy add one) and 2nd is to add it into the projct on the top of it as namespase, and as you have figured it out by user self, simply that you dont need to write the whole path of the contols every time.

Thanks mate for your help...

Just started uni and learning C# and love it...

Glad I found this place as it is a great help!!

Come around every time you will encounter the problem. I was in the same position as you 2 years ago. :)

btw: if you get what you have wanted, please mark the thread as salved, so every one who is looking for a similar issue can get the answer.
And one more thing: Ask one thing at ones, if there is another bothering you, pleaser start another thread.

best regards,
Mitja

commented: Thanks +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.