我不断收到错误,左侧必须是变量,属性或索引器 [英] I keep getting the error the left hand side must be a variable, property, or indexer
本文介绍了我不断收到错误,左侧必须是变量,属性或索引器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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.
这篇关于我不断收到错误,左侧必须是变量,属性或索引器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文