Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/257.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# MVC模型:赋值的左侧必须是变量、属性或索引器_C#_Variables_Variable Assignment - Fatal编程技术网

C# MVC模型:赋值的左侧必须是变量、属性或索引器

C# MVC模型:赋值的左侧必须是变量、属性或索引器,c#,variables,variable-assignment,C#,Variables,Variable Assignment,我继承了一个应用程序,但没有原始代码。我已经使用Reflector 9反编译了程序集,其中一个生成的模型被标题中的错误卡住了。通常这种错误很简单,但这一次我很困惑。下面是完整代码,错误在包含 (((nullable2 = this.Variations) = nullable2.HasValue 变体是在代码后面10行定义的属性,带有 public decimal? Variations { get; set; } 该功能的完整代码为: public decimal GMActu

我继承了一个应用程序,但没有原始代码。我已经使用Reflector 9反编译了程序集,其中一个生成的模型被标题中的错误卡住了。通常这种错误很简单,但这一次我很困惑。下面是完整代码,错误在包含

  (((nullable2 = this.Variations) = nullable2.HasValue 
变体是在代码后面10行定义的属性,带有

  public decimal? Variations { get; set; }
该功能的完整代码为:

 public decimal GMActual
    {
        get
        {
            decimal? nullable2;
            decimal? nullable3;
            decimal? pOValue = this.POValue;
            if ((pOValue.HasValue ? pOValue.GetValueOrDefault() : (((nullable2 = this.Variations) = nullable2.HasValue ? new decimal?(nullable2.GetValueOrDefault()) : ((decimal?) (nullable3 = null))).HasValue ? nullable2.GetValueOrDefault() : 0M)) == 0M)
            {
                return 0M;
            }
            pOValue = this.POValue;
            pOValue = this.MonthActual;
            pOValue = this.POValue;
            return (((pOValue.HasValue ? pOValue.GetValueOrDefault() : (((nullable2 = this.Variations) = nullable2.HasValue ? new decimal?(nullable2.GetValueOrDefault()) : ((decimal?) (nullable3 = null))).HasValue ? nullable2.GetValueOrDefault() : 0M)) - (pOValue.HasValue ? pOValue.GetValueOrDefault() : (((nullable2 = this.CostOnSage) = nullable2.HasValue ? new decimal?(nullable2.GetValueOrDefault()) : ((decimal?) (nullable3 = null))).HasValue ? nullable2.GetValueOrDefault() : 0M))) / (pOValue.HasValue ? pOValue.GetValueOrDefault() : (((nullable2 = this.Variations) = nullable2.HasValue ? new decimal?(nullable2.GetValueOrDefault()) : null).HasValue ? nullable2.GetValueOrDefault() : 0M)));
        }
    }
据我所知。我将十进制赋值为十进制。这是一个简单的赋值,但是,我遗漏了什么


感谢您的建议

您想用代码实现什么


你的意思是检查平等性吗?如果是这样,那么将需要在return语句中的所有引用中用==替换=

这对我来说真的没有任何意义:
((nullable2=this.Variations)=nullable2.HasValue
,从这里我可以看到,这是if语句的条件部分。我想你要做的事情更像这样:

nullable2 = this.Variations
nullable2.HasValue ? ... //and the rest of the statement
或者您试图检查它是否不为null且是否等于变量?那么这应该可以:

(nullable2 != null && nullable2 == this.Variations) ? ...//the rest of the statement.

反编译程序可能把代码搞乱了-请尝试另一个来检查。否则,您想知道您的“修复”是正确的吗


PS:你是想偷那个代码吗?它被弄糊涂了:原来的程序员不想让你看到那个代码;)。

使用
=
操作符进行比较,使用
=
进行赋值有两行包含
((nullable2=this.Variations)=nullable2.HasValue
。是
if
中的错误,还是
return
行中的错误?它在两行中都存在。代码被混淆了:尝试减少它:f.e.“nullable3”总是空的,所以“((十进制?)(nullable3=null))).HasValue'为false…我确实尝试过减少它,但它导致了变量未定义的错误。这是一个奇怪的结果,因为我可以想象,如果大括号出现问题,它会出现。但情况似乎并非如此,因为没有其他属性或方法受到影响,所以我返回到原始版本,带有errorhaha,即在大楼的左边(大约2年前,拿走了所有的代码,也许吧?我们不知道。剩下的只是一堆用于web应用程序的已编译二进制文件…)没有文档,没有同事在公司的新手…我尝试过ilspy、telerik和finally Reflector。没有涉及代码窃取,但总是有更好的方法:)