Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/296.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#_If Statement_Conditional Statements - Fatal编程技术网

C# 写一篇",;如果;条件,但其中不会写入任何代码

C# 写一篇",;如果;条件,但其中不会写入任何代码,c#,if-statement,conditional-statements,C#,If Statement,Conditional Statements,我有一个数据表pgRestrictionTbl: pgRestrictionTbl = GetDataTable(ProjectID, sgID) 我写了一个“如果”条件,在这个条件中我又写了“如果和其他”条件 if() { if() { KnownErrorException.Throw("eSGNTRSTRCTD"); } else { KnownErrorException.Throw("eSGNKKTURST

我有一个数据表pgRestrictionTbl:

pgRestrictionTbl = GetDataTable(ProjectID, sgID)
我写了一个“如果”条件,在这个条件中我又写了“如果和其他”条件

if()
{
    if()
    {
         KnownErrorException.Throw("eSGNTRSTRCTD");
    }
    else
    {
          KnownErrorException.Throw("eSGNKKTURSTRCTD");
    }
}
else
{
    if()
    {
       // I dont need any code to be execute in this block
    }
    else
    {
        KnownErrorException.Throw("eSGNTRHJISTRCTD");
    }
}

method call();
在所有这些条件之后,有一些代码。 现在,如果我的条件在elseif条件下为true,我需要执行所有这些条件之外的代码方法调用。 我不想写任何转到标签。还有别的办法吗?有人能帮忙吗

我没有在if条件下编写任何代码就尝试了这个方法,但我认为这不是一个有效的方法。

只是反转if

if()
{
if()
{
 KnownErrorException.Throw("eSGNTRSTRCTD");
}
else
{
  KnownErrorException.Throw("eSGNKKTURSTRCTD");
}
}
else
{
if(!expr)
{
KnownErrorException.Throw("eSGNTRHJISTRCTD");
}
}
只是颠倒一下假设

if()
{
if()
{
 KnownErrorException.Throw("eSGNTRSTRCTD");
}
else
{
  KnownErrorException.Throw("eSGNKKTURSTRCTD");
}
}
else
{
if(!expr)
{
KnownErrorException.Throw("eSGNTRHJISTRCTD");
}
}
只是颠倒一下假设

if()
{
if()
{
 KnownErrorException.Throw("eSGNTRSTRCTD");
}
else
{
  KnownErrorException.Throw("eSGNKKTURSTRCTD");
}
}
else
{
if(!expr)
{
KnownErrorException.Throw("eSGNTRHJISTRCTD");
}
}
只是颠倒一下假设

if()
{
if()
{
 KnownErrorException.Throw("eSGNTRSTRCTD");
}
else
{
  KnownErrorException.Throw("eSGNKKTURSTRCTD");
}
}
else
{
if(!expr)
{
KnownErrorException.Throw("eSGNTRHJISTRCTD");
}
}
您可以尝试:

if(cond1)
{
  if(cond2)
  {
   KnownErrorException.Throw("eSGNTRSTRCTD");
  }
  else
  {
    KnownErrorException.Throw("eSGNKKTURSTRCTD");
  }
}
else if(!cond3)
{
  KnownErrorException.Throw("eSGNTRHJISTRCTD");
}
您可以尝试:

if(cond1)
{
  if(cond2)
  {
   KnownErrorException.Throw("eSGNTRSTRCTD");
  }
  else
  {
    KnownErrorException.Throw("eSGNKKTURSTRCTD");
  }
}
else if(!cond3)
{
  KnownErrorException.Throw("eSGNTRHJISTRCTD");
}
您可以尝试:

if(cond1)
{
  if(cond2)
  {
   KnownErrorException.Throw("eSGNTRSTRCTD");
  }
  else
  {
    KnownErrorException.Throw("eSGNKKTURSTRCTD");
  }
}
else if(!cond3)
{
  KnownErrorException.Throw("eSGNTRHJISTRCTD");
}
您可以尝试:

if(cond1)
{
  if(cond2)
  {
   KnownErrorException.Throw("eSGNTRSTRCTD");
  }
  else
  {
    KnownErrorException.Throw("eSGNKKTURSTRCTD");
  }
}
else if(!cond3)
{
  KnownErrorException.Throw("eSGNTRHJISTRCTD");
}

这只是风格和惯例的问题。没有一个正确的答案

有些人会争辩说要颠倒逻辑,这样就没有必要讨论分支

其他人会争辩说要把该分支机构包括在内,并在其中放一条评论,说什么都不需要做,只是为了表明该分支机构已经被考虑过,没有被错误地遗漏


总结:做对你最有意义的事,或者做你当前工作/学习地点的人做的事

这只是风格和惯例的问题。没有一个正确的答案

有些人会争辩说要颠倒逻辑,这样就没有必要讨论分支

其他人会争辩说要把该分支机构包括在内,并在其中放一条评论,说什么都不需要做,只是为了表明该分支机构已经被考虑过,没有被错误地遗漏


总结:做对你最有意义的事,或者做你当前工作/学习地点的人做的事

这只是风格和惯例的问题。没有一个正确的答案

有些人会争辩说要颠倒逻辑,这样就没有必要讨论分支

其他人会争辩说要把该分支机构包括在内,并在其中放一条评论,说什么都不需要做,只是为了表明该分支机构已经被考虑过,没有被错误地遗漏


总结:做对你最有意义的事,或者做你当前工作/学习地点的人做的事

这只是风格和惯例的问题。没有一个正确的答案

有些人会争辩说要颠倒逻辑,这样就没有必要讨论分支

其他人会争辩说要把该分支机构包括在内,并在其中放一条评论,说什么都不需要做,只是为了表明该分支机构已经被考虑过,没有被错误地遗漏


总结:做对你最有意义的事情,或者做你当前工作/学习地点的人做的事情

我认为如果你结合以下条件,你的生活会更轻松:

if(condition1 && condition2) // Combine conditions
{
   KnownErrorException.Throw("eSGNTRSTRCTD");
}
else if(condition1Only)
{
   KnownErrorException.Throw("eSGNKKTURSTRCTD");
}
else
{
   // Since there in no sense to have an IF statement with no statements then no need to define it.
   KnownErrorException.Throw("eSGNTRHJISTRCTD");
}

// Congratulation, you have all valid inputs, it is safe to call a method.
methodCall();

我认为,如果您结合以下条件,您的生活会更轻松:

if(condition1 && condition2) // Combine conditions
{
   KnownErrorException.Throw("eSGNTRSTRCTD");
}
else if(condition1Only)
{
   KnownErrorException.Throw("eSGNKKTURSTRCTD");
}
else
{
   // Since there in no sense to have an IF statement with no statements then no need to define it.
   KnownErrorException.Throw("eSGNTRHJISTRCTD");
}

// Congratulation, you have all valid inputs, it is safe to call a method.
methodCall();

我认为,如果您结合以下条件,您的生活会更轻松:

if(condition1 && condition2) // Combine conditions
{
   KnownErrorException.Throw("eSGNTRSTRCTD");
}
else if(condition1Only)
{
   KnownErrorException.Throw("eSGNKKTURSTRCTD");
}
else
{
   // Since there in no sense to have an IF statement with no statements then no need to define it.
   KnownErrorException.Throw("eSGNTRHJISTRCTD");
}

// Congratulation, you have all valid inputs, it is safe to call a method.
methodCall();

我认为,如果您结合以下条件,您的生活会更轻松:

if(condition1 && condition2) // Combine conditions
{
   KnownErrorException.Throw("eSGNTRSTRCTD");
}
else if(condition1Only)
{
   KnownErrorException.Throw("eSGNKKTURSTRCTD");
}
else
{
   // Since there in no sense to have an IF statement with no statements then no need to define it.
   KnownErrorException.Throw("eSGNTRHJISTRCTD");
}

// Congratulation, you have all valid inputs, it is safe to call a method.
methodCall();

-1没有缩进,代码无效,关于代码中没有出现的数据表的一些注意事项。如果有空的
if
子句,则没有效率问题。首先对其进行正确性编码,然后对其进行可读性编码(这可能是您所拥有的,也可能不是您所拥有的;鉴于您的伪代码,这很难说)。-1没有缩进,不是有效的代码,关于代码中没有出现的数据表的一些注释。如果有一个空的if子句,则没有效率问题。首先对其进行正确性编码,然后对其进行可读性编码(这可能是您所拥有的,也可能不是您所拥有的;鉴于您的伪代码,这很难说)。-1没有缩进,不是有效的代码,关于代码中没有出现的数据表的一些注释。如果有一个空的if子句,则没有效率问题。首先对其进行正确性编码,然后对其进行可读性编码(这可能是您所拥有的,也可能不是您所拥有的;鉴于您的伪代码,这很难说)。-1没有缩进,不是有效的代码,关于代码中没有出现的数据表的一些注释。如果有一个空的if子句,则没有效率问题。先编写正确性代码,然后编写可读性代码(这可能是您拥有的,也可能不是您拥有的;考虑到您的伪代码,这很难说)。