c# - if 和 else 语句输出相同的问题
问题描述
我一周前开始编程,并陷入了一个 if else 相关的问题。我写的代码是:-
Console.WriteLine("hello, what is your username?");
string name = Console.ReadLine();
Console.WriteLine("hi, " + name + " nice to meet you!");
Console.WriteLine("please enter your password");
string password = Console.ReadLine();
if (password == "blablabla")
{
Console.WriteLine("you are signed in");
}
else;{
Console.WriteLine("incorrect password");}
而且,在输出中,即使我输入了正确的密码,它也会显示“您已登录”以及“密码错误”。请告诉我我做错了什么,谢谢:)
解决方案
从 else; 中删除逗号“;” 那将
推荐阅读
- html - 导航栏字体
- c - 我尝试用 C 进行冒泡排序,但它不起作用(它进行了 10 次冒泡排序)
- javascript - Bootstrap 选择插件 Jquery 选择选项更改
- excel-formula - excel中循环引用的解决方法
- canvas - THREE.js 在顶部的画布中渲染/重叠另一个渲染器
- java - IntelliJ IDEA:如何在项目树中显示警告?
- c++ - c++ 在循环中定义一组概率分布
- html - 将两个 div 放在同一行会使第一个开始低于应有的值
- devops - 如何将文件从 linux 复制到 windows 服务器、脚本或 jenkins 或 azure devops?
- c++ - 我可以推断作为模板参数传递的函数的返回类型吗?