判断字符串是否与变量相符

判断字符串是否与变量相符

利用Equals()来判断字符串是否与变量一致

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

public class MainPlayer : MonoBehaviour
{
    public string Name;
    
    void Start()
    {
        if (Name.Equals("LBW"))
        {
            Debug.Log("欢迎回来");
        }
        else
        {
            Debug.Log("不存在的名字");
        }
    }
}
posted @ 2023-02-15 18:37  快给我上菜  阅读(7)  评论(0)    收藏  举报