读书人

控制台应用程序简单的有关问题分不多

发布时间: 2013-03-13 10:56:58 作者: rapoo

控制台应用程序简单的问题,分不多,求指点,急!
控制台应用程序中,
代码如下,
为什么我输出什么都没有,哪里错了,不是应该输出“待家里么”

string weather = "多云";

if (weather != "下雨")
{
if (weather == "晴天")
{
Console.WriteLine("晒太阳");
}
}

else
{
Console.WriteLine("待家里");
}
[解决办法]
string weather = "多云";

if (weather != "下雨")//满足这个条件,进入这个条件
{
if (weather == "晴天")//不满足这个条件,不执行
{
Console.WriteLine("晒太阳");
}
}

else
{
Console.WriteLine("待家里");
}
[解决办法]

string weather = "多云";

if (weather != "下雨")//满足这个条件,进入这个条件
{
if (weather == "晴天")//不满足这个条件,不执行
{
Console.WriteLine("晒太阳");
}
else
{
Console.WriteLine("影响心情");//添加一个条件分支,输出影响心情


}
}

else
{
Console.WriteLine("待家里");
}
[解决办法]
string weather = "多云";

if (weather != "下雨")
{
if (weather == "晴天")
{
Console.WriteLine("晒太阳");
}
else
{
Console.WriteLine("待家里");
}
}

读书人网 >C#

热点推荐