我不断收到错误,左侧必须是变量,属性或索引器
问题描述:
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 () {
}
}
答
我试图修改您的代码,对我来说,它的工作原理是Hello World
我创建一个控制台应用程序
I tried to modified your code and it work fine for me out put is Hello World
I create a console application
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
由于以下几行...
Because of the below lines...
stringArray (0) = "Hello";
stringArray (1) = "World";
应该是...
It should be...
stringArray[0] = "Hello";
stringArray[1] = "World";
只是方括号.就是这样.
Just square brackets. That''s it.