c# 我的这个代码哪里错了

来源:百度知道 编辑:UC知道 时间:2024/05/23 14:19:36
我想弄个登陆的程序
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication17
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{

string Name = textBox1.Text; //获取用户名
string Pswd = textBox2.Text; //获取密码值
//判断用户名和密码是否与指定的值匹配
if (Name == "Wendy" && Pswd == "123")
{
MessageBox.Show("登录成功!");
}
else
{
MessageBox.Show("用户名和密码不匹配!");
}

}

private void

贴出具体的错误提示,帮你看看

具体是什么错误?
我看的时候好像没看见错误的样子
可能不仔细···

private void button1_Click(object sender, EventArgs e)
{
string Name = textBox1.Text; //获取用户名
string Pswd = textBox2.Text; //获取密码值
//判断用户名和密码是否与指定的值匹配
if (Name == "Wendy" && Pswd == "123")
{
MessageBox.Show("登录成功!");
}
else
{
MessageBox.Show("用户名和密码不匹配!");
}
}
我测试了
这段代码没有错啊···

这句
if (Name == "Wendy" && Pswd == "123")
应该写成:
if ((Name == "Wendy") && (Pswd == "123"))

汗,哪错了》?没看出来,能否贴出提示的错误看看

if (Name == "Wendy" && Pswd == "123")和
if ((Name == "Wendy") && (Pswd == "123"))
我用时觉得都一样

为啥我试着就是对的呢
你的名称空间弄对没有呀?