c#类,结构或接口成员声明中的’while’标记无效(while循环不起作
发布时间:2020-12-16 01:59:38 所属栏目:百科 来源:网络整理
导读:参见英文答案 Invalid token ‘while’ in class,struct,or interface member declaration in very simple code????????????????????????????????????5个 我是c#的新手但对c非常熟悉,但这个错误对我来说没有多大意义,因为我已经特别遵循了 http://msdn.micro
参见英文答案 >
Invalid token ‘while’ in class,struct,or interface member declaration in very simple code????????????????????????????????????5个
我是c#的新手但对c非常熟悉,但这个错误对我来说没有多大意义,因为我已经特别遵循了 http://msdn.microsoft.com/en-us/library/2aeyhxcd.aspx所示的必要语法 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 WindowsFormsApplication1 { public partial class Form1 : Form { int years = 1; while (years <=10) { public Form1() { InitializeComponent(); } private void numericUpDown1_ValueChanged(object sender,EventArgs e) { int value = Convert.ToInt32(bushels1.Text); numericUpDown1.Maximum = value; } private void bushels1_Click(object sender,EventArgs e) { } private void nextYear_Click(object sender,EventArgs e) { } } } } 解决方法
你有直接在类里面,它应该是一个方法的一部分,你不能直接在类内部编写语句.
public partial class Form1 : Form { int years = 1; while (years <=10) { //^^ 它应该是方法的一部分,如: public partial class Form1 : Form { int years = 1; public void SomeMethod() { while (years <=10) { //rest of your code } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- oracle中创建MD5加密的存储函数 学习笔记
- c – 使用任意值初始化/调整容器大小的建议方法
- Flex 地图 查询出错 fault400
- Oracle-内存管理解读-更新中
- Oracle 异常 ORA-01861: literal does not match format st
- dreamweaver中用正则表达式查找替换批量删除 tppabs标签的方
- 关于AJAX/javascript 跨域访问的解决办法及 CORS(Cross-Ori
- Xcode GIT无法复制新文件
- c# – 将datetime值分配给具体时间的今天日期
- xml 绑定到 comboBox (DisplayMember和ValueMember)