CS1519: unexpected symbol


hi everyone i keep receiving this issues:
Assets/TextController.cs(10,48): error CS1519: Unexpected symbol `lock’ in class, struct, or interface member declaration
I checked everything but can’t see from where the issues comes from,
thanks for your help

Hi Patrick,

Can you copy/paste your code into your reply instead of the screenshot please, some of your code isn’t visible in that image.


See also;

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

public class TextController : MonoBehaviour {

	public Text text;
	
	private enum States { cell, mirror, sheets, lock, sheets_1, lock_1, mirror_cell, freedom };
	private States myState;

	// Use this for initialization
	void Start () {
		myState = States.cell;
	}
	
	// Update is called once per frame
	void Update () {
		print (myState);
	}

	void state_cell (){
		text.text = "You are in a prison cell, and you want to escape."+
					"A bed, with some dirty sheets, a miror and the door"+
					"is locked from the outside"+
					" welcome to Prison.\n\n" +
					" Press S to view Sheets, M to view Mirror and L to view lock";	
		if(Input.GetKeyDown(KeyCode.S)){
		}

	}
}

Thanks Rob i am getting crazy

Hey,

Your code is ok, but… you notice above how the word “lock” is a different colour? It is what is referred to as a keyword, as such you cannot use it in this way.

If you check the lecture again you’ll note that it should infact be lock_0, which then gets around the issue.

Also, please do check out the link I provided above with regards to the formatting of copy/pasted code in the replies, it will be beneficial to you and those that help you going forward :slight_smile:


See also;

Thanks so much Rob it works,
i ll read the doc.

1 Like

Great! You’re welcome and I’m glad you can move forward with the course again :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms