Click here to Skip to main content
15,887,304 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
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 () {

    }
}
Posted
Comments
[no name] 13-Oct-14 14:27pm    
What programming language is "Errors"?
VC.J 13-Oct-14 14:28pm    
you have a syntax of C# I think so the code like would be like
stringArray[0] = "Hello";
stringArray[1] = "World";
[no name] 13-Oct-14 14:38pm    
That is the most likely answer.
VC.J 13-Oct-14 14:29pm    
and which line you are getting this error its not clear from your question and when you are getting this error
BrittneyPowers 13-Oct-14 14:31pm    
line 14 and 15

I tried to modified your code and it work fine for me out put is Hello World
I create a console application
C#
static void Main(string[] args)
       {
        Start();
       }

C#
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
 
Share this answer
 
v3
Comments
BrittneyPowers 13-Oct-14 14:47pm    
yah i used () instead of []
Because of the below lines...
C#
stringArray (0) = "Hello";
stringArray (1) = "World";

It should be...
C#
stringArray[0] = "Hello";
stringArray[1] = "World";

Just square brackets. That's it.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900