高手帮我,编译出错!

ahjon 2005-10-31 05:12:11
using System;

class NetUser
{
public string id;
string password;
string email;
public NetUser(string vid,string vpass,string vemail)
{
id=vid;
password=vpass;
if(vemail="")
email=id+"@hope.com";
else email=vemail;
}

void Main()
{
string iid;
string ipass;
string iemail;
Console.WriteLine("Please enter your id!");
iid=Console.ReadLine();
Console.WriteLine("Please enter your password!");
ipass=Console.ReadLine();
Console.WriteLine("Please enter your email!");
iemail=Console.ReadLine();
NetUser a= new NetUser(iid,ipass,iemail);
Console.WriteLine("Your info:{0},{1},{2}",a.id,a.password,a.email);
}
}

编译时却出错:
D:\csc pnetuser.cs
pnetuser.cs<12,6>:error cs0029:无法将类型"string"隐式转换为"bool"

程序里我没有作类型转换啊,哪位高手帮帮我
...全文
61 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
liuchengit 2005-11-01
  • 打赏
  • 举报
回复
dfdf
Samen168 2005-11-01
  • 打赏
  • 举报
回复
hoho,顶下
jxufewbt 2005-11-01
  • 打赏
  • 举报
回复
虽然这里if,else下面只有一条语句,但是还是建议楼主加花括号,这样代码层次比较清晰。
jxufewbt 2005-11-01
  • 打赏
  • 举报
回复
if(vemail="")
改成
if(vemail=="")
zhy0101 2005-11-01
  • 打赏
  • 举报
回复
看错了,刚才第二次的作废
zhy0101 2005-11-01
  • 打赏
  • 举报
回复
id=int.Parse(vid);
zhy0101 2005-11-01
  • 打赏
  • 举报
回复
= 在C#里是赋值
== 是相等
寒星 2005-10-31
  • 打赏
  • 举报
回复
if(vemail="")错了,应该是if(vemail=="")

110,536

社区成员

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

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

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