关于this指针的 error....求解答
- C# code
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 Picturer_1{ public partial class Login : Form { public Login() { //windows窗体设计器支持所必需的 InitializeComponent(); //向组合框添加3个选项 comboname.Items.Add("王菲"); comboname.Items.Add("张强"); comboname.Items.Add("李铁"); //将组合框的选定项设置为第一项 comboname.SelectedIndex = 0; } private void comboname_SelectedIndexChanged(object sender, EventArgs e) { txtpassw.Focus(); switch (comboname.Text) { case "王菲": { txttitle.Text = "总经理"; txtlevel.Text = "一级"; picB.Image = Image.FromFile(@"C:\Users\YE\Documents\Visual Studio 2010\Projects\Picturer_1\bmp\a.jpg"); txtit.Text = "公司总经理,2005年1月加入本公司"; break; } case "张强": { txttitle.Text = "副总经理"; txtlevel.Text = "二级"; picB.Image = Image.FromFile(@"C:\Users\YE\Documents\Visual Studio 2010\Projects\Picturer_1\bmp\b.jpg"); txtit.Text = "副总经理,2004年3月加入本公司"; break; } case "李铁": { txttitle.Text = "经理"; txtlevel.Text = "三级"; picB.Image = Image.FromFile(@"C:\Users\YE\Documents\Visual Studio 2010\Projects\Picturer_1\bmp\c.jpg"); txtit.Text = "经理,2004年8月加入本公司"; break; } } } private void btnOk_Click(object sender, EventArgs e) { txtpassw.Focus(); switch (comboname.Text) { case "王菲": { if (txtpassw.Text == "123456") { MessageBox.Show("输入密码正确"); this.Close; break; } else { MessageBox.Show("你输入的密码不正确,请重新输入密码"); txtpassw.SelectionStart = 0; txtpassw.SelectionLength = txtpassw.Text.Length; break; } } case "张强": { if (txtpassw.Text == "234567") { MessageBox.Show("输入密码正确"); this.Close; break; } else { MessageBox.Show("你输入的密码不正确,请重新输入密码"); txtpassw.SelectionStart = 0; txtpassw.SelectionLength = txtpassw.Text.Length; break; } } case "李铁": { if (txtpassw.Text == "345678") { MessageBox.Show("输入密码正确"); this.Close; break; } else { MessageBox.Show("你输入的密码不正确,请重新输入密码"); txtpassw.SelectionStart = 0; txtpassw.SelectionLength = txtpassw.Text.Length; break; } } } } }}
c:\users\ye\documents\visual studio 2010\Projects\Picturer_1\Form1.cs(69,29): 错误 CS0201: 只有 assignment、call、increment、decrement 和 new 对象表达式可用作语句
c:\users\ye\documents\visual studio 2010\Projects\Picturer_1\Form1.cs(85,29): 错误 CS0201: 只有 assignment、call、increment、decrement 和 new 对象表达式可用作语句
c:\users\ye\documents\visual studio 2010\Projects\Picturer_1\Form1.cs(101,29): 错误 CS0201: 只有 assignment、call、increment、decrement 和 new 对象表达式可用作语句
报错语句
this.Close;
请问是this指针超出了权限吗??求指导
[解决办法]
this.Close();
[解决办法]