本文介绍了我不断收到错误,左侧必须是变量,属性或索引器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

using UnityEngine;
using System.Collections;

public class HelloWorld: MonoBehaviour {

    // Use this for initialization
    void Start () {
        string name = "Jesse Freeman";
        int age = 34;
        float speed = 4.3f;
        bool LikesGame = true;

        var stringArray = new string[2];
        stringArray (0) = "Hello";
        stringArray (1) = "World";

        var phrase = stringArray[0]+" "+ stringArray[1];

        Debug.Log(phrase);
    }

    // Update is called once per frame
    void Update () {

    }
}

推荐答案

static void Main(string[] args)
       {
        Start();
       }


public static void Start()
        {
            string name = "Jesse Freeman";
            int age = 34;
            float speed = 4.3f;
            bool LikesGame = true;

            var stringArray = new string[2];
            stringArray[0] = "Hello";
            stringArray[1] = "World";

            var phrase = stringArray[0] + " " + stringArray[1];
            Console.WriteLine(phrase);

            Console.ReadKey();
            // Debug.Log(phrase);
        }



希望这对您正在寻找的东西有所帮助



hope that will help if this is what you are looking for mark it as a solution


stringArray (0) = "Hello";
stringArray (1) = "World";


应该是...


It should be...

stringArray[0] = "Hello";
stringArray[1] = "World";


只是方括号.就是这样.


Just square brackets. That''s it.


这篇关于我不断收到错误,左侧必须是变量,属性或索引器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-14 08:40