本文介绍了error使用namespace命令只能应用于名称空间; 'System.Windows.Forms.Application'是一个类型而不是命名空间C:\ Users \ Surya \documents\visual studio 2010 \Projects\menuForm \ Program的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 使用系统; 使用 System.Collections.Generic; 使用 System.ComponentModel; 使用 System.Data; 使用 System.Drawing; 使用 System.Linq; 使用 System.Text; 使用 System.Windows.Forms; 命名空间 menuForm { public partial class Form3:表单 { private void calculatefee() { int coursefee; switch (cmbcourse.SelectedIndex) { case 0 :coursefee = 7500 ; break ; case 1 :coursefee = 6000 ; break ; case 2 :coursefee = 4000 ; break ; case 3 :coursefee = 3000 ; break ; 默认:MessageBox.Show( please选择课程!, 错误); cmbcourse.Focus(); return ; } if (rbafternoon.Checked) coursefee = coursefee * 80/100; else if (rbmorning.Checked) coursefee = coursefee *百分之九十零; if (chkcoursematerial.Checked) coursefee + = 500 ; lblfee.Text = coursefee.ToString(); } private void rbmorning_CheckedChanged( object sender,EventArgs e) { calculatefee(); } private void rbafternoon_CheckedChanged( object sender,EventArgs e) { calculatefee(); } private void rbevening_CheckedChanged( object sender,EventArgs e) { calculatefee(); } 私有 void chkcoursematerial_CheckedChanged( object sender,EventArgs e) { calculatefee(); } private void cmbcourse_SelectedIndexChanged( object sender,EventArgs e) { calculatefee(); } } } 解决方案 您是在Web应用程序或控制台应用程序中使用它吗? ? using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace menuForm{ public partial class Form3 : Form { private void calculatefee() { int coursefee; switch(cmbcourse.SelectedIndex) { case 0:coursefee=7500; break; case 1:coursefee=6000; break; case 2:coursefee=4000; break; case 3:coursefee=3000; break; default:MessageBox.Show("please select a course!","Error"); cmbcourse.Focus(); return; } if(rbafternoon.Checked) coursefee=coursefee*80/100; else if(rbmorning.Checked) coursefee=coursefee*90/100; if(chkcoursematerial.Checked) coursefee+=500; lblfee.Text=coursefee.ToString(); } private void rbmorning_CheckedChanged(object sender, EventArgs e) { calculatefee(); } private void rbafternoon_CheckedChanged(object sender, EventArgs e) { calculatefee(); } private void rbevening_CheckedChanged(object sender, EventArgs e) { calculatefee(); } private void chkcoursematerial_CheckedChanged(object sender, EventArgs e) { calculatefee(); } private void cmbcourse_SelectedIndexChanged(object sender, EventArgs e) { calculatefee(); } }} 解决方案 Are You Using it in web application or console application ?? 这篇关于error使用namespace命令只能应用于名称空间; 'System.Windows.Forms.Application'是一个类型而不是命名空间C:\ Users \ Surya \documents\visual studio 2010 \Projects\menuForm \ Program的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-29 11:22