Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如果签入C,则出现问题#_C#_.net - Fatal编程技术网

C# 如果签入C,则出现问题#

C# 如果签入C,则出现问题#,c#,.net,C#,.net,好的,这是我的if检查,不管我怎么尝试,它都不能正常通过,它一直停止 DateTime now = new DateTime(); string s = "Everyday"; string currentTime = now.ToString("HH:mm"); string remDate = "21:00"; //set to a minute or two i the future string CurrentDay = "Sunday"; if ((s.ToUpper() == "W

好的,这是我的if检查,不管我怎么尝试,它都不能正常通过,它一直停止

DateTime now = new DateTime();
string s = "Everyday";
string currentTime = now.ToString("HH:mm");
string remDate = "21:00"; //set to a minute or two i the future
string CurrentDay = "Sunday";

if ((s.ToUpper() == "WORKDAYS") ||(s.ToUpper() == "EVERYDAY" || s.ToUpper() == CurrentDay.ToUpper()) 
&& ((currentTime == remDate) && (s.ToUpper() != "SUNDAY") && (s.ToUpper() != "SATURDAY")))
{
     MessageBox.Show("Success!!!!");
}

因此,当它点击if复选框时,它会停止,永远不会到达消息框。无论我试过什么样的检查顺序,它都不起作用,盯着它看了一段时间,觉得有人可以给我一个更好的方法,或者看看我遗漏了什么。

如果你看到你的是每天的,那么第一个条件就满足了。但你有自己的条件

(currentTime==remDate)和(s.ToUpper()!=“星期日”)和(s.ToUpper()!=“星期六”)

只有当时间为21:00时,这才是正确的


但现在不是这样。因此,该条件失败

如果您看到您的是每天的,则满足第一个条件。但你有自己的条件

(currentTime==remDate)和(s.ToUpper()!=“星期日”)和(s.ToUpper()!=“星期六”)

只有当时间为21:00时,这才是正确的


但现在不是这样。因此,该条件失败

如果您看到您的是每天的,则满足第一个条件。但你有自己的条件

(currentTime==remDate)和(s.ToUpper()!=“星期日”)和(s.ToUpper()!=“星期六”)

只有当时间为21:00时,这才是正确的


但现在不是这样。因此,该条件失败

如果您看到您的是每天的,则满足第一个条件。但你有自己的条件

(currentTime==remDate)和(s.ToUpper()!=“星期日”)和(s.ToUpper()!=“星期六”)

只有当时间为21:00时,这才是正确的


但现在不是这样。因此,该条件失败

因为它只能在21:00工作

UPD: 对不起,这是个错误。第一行的真正原因
您必须编写
DateTime now=DateTime.now

因为它只能在21:00工作

UPD: 对不起,这是个错误。第一行的真正原因
您必须编写
DateTime now=DateTime.now

因为它只能在21:00工作

UPD: 对不起,这是个错误。第一行的真正原因
您必须编写
DateTime now=DateTime.now

因为它只能在21:00工作

UPD: 对不起,这是个错误。第一行的真正原因
您必须编写
DateTime now=DateTime.now

让我们从提高代码可读性开始,这也有助于显示您的
|
&
问题

DateTime now = new DateTime();
string s = "Everyday";
string currentTime = now.ToString("HH:mm");
string remDate = "21:00"; //set to a minute or two i the future
string CurrentDay = "Sunday";

if (
    // condition 1
    (s.ToUpper() == "WORKDAYS") 
    // condition 2
    || (
        s.ToUpper() == "EVERYDAY" 
        || s.ToUpper() == CurrentDay.ToUpper()
    ) 
    // condition 3
    && (
        // condition 3.1
        (currentTime == remDate) 
        && (s.ToUpper() != "SUNDAY") 
        && (s.ToUpper() != "SATURDAY")
    )
)
{
    // I'm using LINQPad, so I just output this to the results
    "Success!!!!".Dump();
}
一个问题是条件3.1:
(currentTime==remDate)
。给定提供的示例输入,这必须为真,因此消息框仅在时间为21:00时显示

另一个问题是,条件2和条件3将被视为一个组(因为它们与
&&
连接在一起)。这是你真正的意思吗

这个
if
语句的逻辑很难理解,分组或/和表达式增加了混乱


试着用英语写出条件,可能是一个项目符号列表,看看错误是否对你来说不明显。

让我们先让你的代码更具可读性,这也有助于显示你的
|
&
问题

DateTime now = new DateTime();
string s = "Everyday";
string currentTime = now.ToString("HH:mm");
string remDate = "21:00"; //set to a minute or two i the future
string CurrentDay = "Sunday";

if (
    // condition 1
    (s.ToUpper() == "WORKDAYS") 
    // condition 2
    || (
        s.ToUpper() == "EVERYDAY" 
        || s.ToUpper() == CurrentDay.ToUpper()
    ) 
    // condition 3
    && (
        // condition 3.1
        (currentTime == remDate) 
        && (s.ToUpper() != "SUNDAY") 
        && (s.ToUpper() != "SATURDAY")
    )
)
{
    // I'm using LINQPad, so I just output this to the results
    "Success!!!!".Dump();
}
一个问题是条件3.1:
(currentTime==remDate)
。给定提供的示例输入,这必须为真,因此消息框仅在时间为21:00时显示

另一个问题是,条件2和条件3将被视为一个组(因为它们与
&&
连接在一起)。这是你真正的意思吗

这个
if
语句的逻辑很难理解,分组或/和表达式增加了混乱


试着用英语写出条件,可能是一个项目符号列表,看看错误是否对你来说不明显。

让我们先让你的代码更具可读性,这也有助于显示你的
|
&
问题

DateTime now = new DateTime();
string s = "Everyday";
string currentTime = now.ToString("HH:mm");
string remDate = "21:00"; //set to a minute or two i the future
string CurrentDay = "Sunday";

if (
    // condition 1
    (s.ToUpper() == "WORKDAYS") 
    // condition 2
    || (
        s.ToUpper() == "EVERYDAY" 
        || s.ToUpper() == CurrentDay.ToUpper()
    ) 
    // condition 3
    && (
        // condition 3.1
        (currentTime == remDate) 
        && (s.ToUpper() != "SUNDAY") 
        && (s.ToUpper() != "SATURDAY")
    )
)
{
    // I'm using LINQPad, so I just output this to the results
    "Success!!!!".Dump();
}
一个问题是条件3.1:
(currentTime==remDate)
。给定提供的示例输入,这必须为真,因此消息框仅在时间为21:00时显示

另一个问题是,条件2和条件3将被视为一个组(因为它们与
&&
连接在一起)。这是你真正的意思吗

这个
if
语句的逻辑很难理解,分组或/和表达式增加了混乱


试着用英语写出条件,可能是一个项目符号列表,看看错误是否对你来说不明显。

让我们先让你的代码更具可读性,这也有助于显示你的
|
&
问题

DateTime now = new DateTime();
string s = "Everyday";
string currentTime = now.ToString("HH:mm");
string remDate = "21:00"; //set to a minute or two i the future
string CurrentDay = "Sunday";

if (
    // condition 1
    (s.ToUpper() == "WORKDAYS") 
    // condition 2
    || (
        s.ToUpper() == "EVERYDAY" 
        || s.ToUpper() == CurrentDay.ToUpper()
    ) 
    // condition 3
    && (
        // condition 3.1
        (currentTime == remDate) 
        && (s.ToUpper() != "SUNDAY") 
        && (s.ToUpper() != "SATURDAY")
    )
)
{
    // I'm using LINQPad, so I just output this to the results
    "Success!!!!".Dump();
}
一个问题是条件3.1:
(currentTime==remDate)
。给定提供的示例输入,这必须为真,因此消息框仅在时间为21:00时显示

另一个问题是,条件2和条件3将被视为一个组(因为它们与
&&
连接在一起)。这是你真正的意思吗

这个
if
语句的逻辑很难理解,分组或/和表达式增加了混乱


试着用英语写下条件,可能是一个项目符号列表,看看错误是否对你来说不明显。

这里我假设你的变量
CurrentDay
等于
DayOfWeek.Monday.ToString().ToUpper()

根据你的陈述,看起来

if(false || true && false)
因为
(s.ToUpper()=“WORKDAYS”)
始终为假,直到您更改
s

(s.ToUpper()=“Daily”| | s.ToUpper()=“CurrentDay.ToUpper())
在更改s之前始终为真
((currentTime==remDate)和&(s.ToUpper()!=“星期日”)和&(s.ToUpper()!=“星期六”)
&&(CurrentDay==s))
始终为false,因为
(currentTime.ToString("HH:mm") == remDate)