关于this指针的 error....求解答

freediim 2012-04-10 10:40:14

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指针超出了权限吗??求指导
...全文
76 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
freediim 2012-04-10
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 的回复:]

引用 4 楼 的回复:

引用 2 楼 的回复:

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

this.Close()

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

是关闭当前窗体,
学的时候认真点,
这种错误太低级了。。。
[/Quote]

好吧,我承认自己当时二了……
ohkuy 2012-04-10
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 的回复:]

引用 2 楼 的回复:

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

this.Close()

正在自学C#,对着书打的…… 它的目的貌似是想关闭对话框
[/Quote]
是关闭当前窗体,
学的时候认真点,
这种错误太低级了。。。
freediim 2012-04-10
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]

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

this.Close()
[/Quote]
正在自学C#,对着书打的…… 它的目的貌似是想关闭对话框
传递正能量 2012-04-10
  • 打赏
  • 举报
回复
楼上的火眼金睛
cheng2005 2012-04-10
  • 打赏
  • 举报
回复
Close是方法,谁告诉你方法可以这么调用的?

this.Close()
Rotaxe 2012-04-10
  • 打赏
  • 举报
回复
this.Close();

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧