我该如何解决:无法将lambda表达式转换为类型'bool',因为它不是委托类型

问题描述

我一直在向游戏中添加一个已保存的Highscore系统,但出现此错误

无法将lambda表达式转换为类型'bool',因为它不是委托类型

这是我的剧本

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

public class Highscoredisplay : MonoBehavIoUr
{
    public Text display;
    public static int score;
    private int Highscore;
    private int Latescore;

    void Start()
    {
        Highscore = PlayerPrefs.GetInt("Highscore",0);
    }

    // Update is called once per frame
    void Update()
    {
        display.text = (score.ToString());

        // This is the error
        if (score => Highscore)
        {
            Highscore = score;
            score = 0;
        }
        // ^This is the error^

        if (Highscore == Latescore)
        {

        }
        else
        {
        PlayerPrefs.SetInt("Highscore",Highscore);
        }
    }

    void LateUpdate()
    {
        Latescore = Highscore;
    }
}

请帮助

Thx 布伦

解决方法

您需要> =,而不是=>(翻转订单) 您只能进行> =进行比较,因为=>用于lambda表达式