如何修复错误CS0136

时间:2017-09-03 08:31:52

标签: c# unity3d scope

我有一个给我错误的脚本

  

Assets / Scripts / CraftItem.cs(11,6):错误CS0136:局部变量   名为requiredcount' cannot be declared in this scope because it would give a different meaning to requiredcount'已经是   用于“父母或现在的”#39;范围来表示别的东西

我无法在网上找到任何好的答案,也不知道如何解决这个问题,以下是剧本:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;



    public class CraftItem : MonoBehaviour {

         public GameObject countholder;

         public void Craftitem(int crafttype, int requiredtype, int requiredcount, int requiredamount){
             requiredcount = countholder.GetComponent<Counts> ().Counters [requiredtype];
                 if(requiredcount => requiredamount){

             }

         }
     }

1 个答案:

答案 0 :(得分:2)

您在if条件中使用>=,在C#中表示箭头函数/ lambda表达式。您正在寻找的运营商是if (age1>age2 && age1>age3) { oldest=age1; if (age2>age3) middle = age2; youngest=age3; } else { middle = age3; youngest=age2; } } else if (age2>age3) { oldest=age2; if (age1>age3) middle = age1; youngest=age3; } else { middle = age3; youngest=age1; } } else { oldest=age3; if (age2>age1) middle = age2; youngest=age1; } else { middle = age1; youngest=age2; } }