作者hiroshima (ppp)
看板C_Sharp
標題[問題] MessageBox.Show()的問題
時間Sat Nov 20 16:54:02 2010
以下是我的程式碼
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int x = 10, y=0,re;
try
{
re=x/y;
}
catch (System.DivideByZeroException ex) {
MessageBox.Show("除數不可以為0");
}
finally {
MessageBox.Show("finally");
}
Console.Read();
}
}
}
我要使用MessageBox.Show的方法,先查了msdn知道要
using System.Windows.Forms;
在編譯後,它卻告訴我
命名空間 'System' 中沒有型別或命名空間名稱 'Windows' (您是否遺漏了組件參考?)
我找不出原因
請各位為什麼會有錯呢
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.117.3.231
1F:推 liaommx:console application沒有form吧? 11/20 16:57
2F:→ liaommx:console application應該不能用windows的組件 11/20 16:58
※ 編輯: hiroshima 來自: 59.117.3.231 (11/20 17:11)
4F:→ hiroshima:感謝james 11/20 17:12
5F:→ andymai:所以程式是Copy來的?因為沒加入參考前用using是打不出來的 11/20 17:50
6F:→ andymai:應該瞭解一下"加入參考"是什麼意思和加入的是什麼東西... 11/20 17:53
7F:推 liaommx:喔喔,也是可以這樣啦,我通常用console就不用form了..XD 11/20 18:24
8F:→ james732:一般來說我也覺得別混用比較好,但技術上是可以做到的 11/20 18:31
其實,我是照書上所講的來寫的,書上沒有完整的程式,我以為以用主控台應用程式來寫
原來是要用windows form應用程式來寫,書上也沒講"加入參考"的東西,不曉得是沒有講,
還是我沒讀到,謝謝各位囉
※ 編輯: hiroshima 來自: 59.117.10.164 (11/20 19:39)