首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

关于this指针的 error.求解答解决方法

2012-04-12 
关于this指针的 error....求解答C# codeusing Systemusing System.Collections.Genericusing System.Com

关于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();

[解决办法]
探讨

引用:

Close是方法,谁告诉你方法可以这么调用的?

this.Close()

正在自学C#,对着书打的…… 它的目的貌似是想关闭对话框

热点排行