description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid |
---|---|---|---|---|---|
Compiler Error CS1001 |
Compiler Error CS1001 |
07/20/2015 |
CS1001 |
CS1001 |
327ad669-9c20-4fe8-a771-234878dbb90e |
Compiler Error CS1001
Identifier expected
You did not supply an identifier. An identifier is the name of a class, struct, namespace, method, variable, and so on, that you provide.
The following example declares a simple class but does not give the class a name:
public class //CS1001 { public int Num { get; set; } void MethodA() {} }
The following sample generates CS1001 because, when declaring an enum, you must specify members:
public class Program { enum Colors { 'a', 'b' // CS1001, 'a' is not a valid int identifier // The following line shows examples of valid identifiers: // Blue, Red, Orange }; public static void Main() { } }
Parameter names are required even if the compiler doesn’t use them, for example, in an interface definition. These parameters are required so that programmers who are consuming the interface know something about what the parameters mean.
interface IMyTest { void TestFunc1(int, int); // CS1001 // Use the following line instead: // void TestFunc1(int a, int b); } class CMyTest : IMyTest { void IMyTest.TestFunc1(int a, int b) { } }
See also
- Operators and expressions
- Types
I’m new to programming and am taking a C# class. I am getting compiler error CS1001 when I try to write this program.
I read the Compiler Error description (link below), but I’m really not getting it. What am I doing wrong?
http://msdn.microsoft.com/en-us/library/b839hwk4.aspx
Here is my source code:
using System;
public class InputMethodDemoTwo
{
public static void Main()
{
int first, second;
InputMethod(out first, out second);
Console.WriteLine("After InputMethod first is {0}", first);
Console.WriteLine("and second is {0}", second);
}
public static void InputMethod(out first, out second)
// The error is citing the line above this note.
{
one = DataEntry("first");
two = DataEntry("second");
}
public static void DataEntry(out int one, out int two)
{
string s1, s2;
Console.Write("Enter first integer ");
s1 = Console.ReadLine();
Console.Write("Enter second integer ");
s2 = Console.ReadLine();
one = Convert.ToInt32(s1);
two = Convert.ToInt32(s2);
}
}
According to the instructions, I’m supposed to have a method b (InputData) which pulls statements from method c (DataEntry)… Here are the instructions:
The InputMethod()in the InputMethodDemo program in Figure 6-24 contains repetitive
code that prompts the user and retrieves integer values. Rewrite the program so the
InputMethod()calls another method to do the work. The rewritten InputMethod()
will need to contain only two statements:one = DataEntry(«first»);
two = DataEntry(«second»);
Save the new program as InputMethodDemo2.cs.»
The InputMethodDemo they are referring to is the same program, except that it calls only one method (the InputMethod) instead of two.
The text I referred to above is «Microsoft® Visual C#® 2008, An Introduction to Object-Oriented Programming, 3e, Joyce Farrell»
Any advice/ help would be greatly appreciated.
here is my player attach code for moving platforms:
I’m getting an error CS1001: Identifier expected for some reason ant youtube is not helping me…
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerAttach : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
function OnTriggerEnter(other.Collider){
if (other.gameObject.tag == "player")
{
transform.parent = other.transform;
}
}
function OnTriggerExit(other.Collider){
if (other.gameObject.tag == "player")
{
transform.parent = null;
}
}
}
}
asked Jul 13, 2021 at 15:05
3
What you have is unityscript
which is long deprecated and not compatible with c#
!
And in general do not nest MonoBehaviour messages under Update
! Otherwise the messaging system won’t find them and they are never called at all.
Your class should look like
public class PlayerAttach : MonoBehaviour
{
private void OnTriggerEnter(Collider other)
{
// Rather use CompareTag instead of ==
// the latter fails silently in case of s typo making your debugging live only harder
if (!other.CompareTag("player")) return;
transform.parent = other.transform;
}
private void OnTriggerExit(Collider other)
{
if (!other.CompareTag("player")) return;
transform.parent = null;
}
}
Further, a logical question: How exactly do you expect the player object leaving this collider if you make it a parent so whenever the player object moves this object moves along with it?
answered Jul 13, 2021 at 15:27
derHugoderHugo
77.4k9 gold badges67 silver badges105 bronze badges
here is my player attach code for moving platforms:
I’m getting an error CS1001: Identifier expected for some reason ant youtube is not helping me…
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerAttach : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
function OnTriggerEnter(other.Collider){
if (other.gameObject.tag == "player")
{
transform.parent = other.transform;
}
}
function OnTriggerExit(other.Collider){
if (other.gameObject.tag == "player")
{
transform.parent = null;
}
}
}
}
asked Jul 13, 2021 at 15:05
3
What you have is unityscript
which is long deprecated and not compatible with c#
!
And in general do not nest MonoBehaviour messages under Update
! Otherwise the messaging system won’t find them and they are never called at all.
Your class should look like
public class PlayerAttach : MonoBehaviour
{
private void OnTriggerEnter(Collider other)
{
// Rather use CompareTag instead of ==
// the latter fails silently in case of s typo making your debugging live only harder
if (!other.CompareTag("player")) return;
transform.parent = other.transform;
}
private void OnTriggerExit(Collider other)
{
if (!other.CompareTag("player")) return;
transform.parent = null;
}
}
Further, a logical question: How exactly do you expect the player object leaving this collider if you make it a parent so whenever the player object moves this object moves along with it?
answered Jul 13, 2021 at 15:27
derHugoderHugo
77.4k9 gold badges67 silver badges105 bronze badges
- Remove From My Forums
-
Question
-
Hello to all,
We’ve all encountered a lot of errors and warnings whenever we debug our applications, but what I encountered recently was ridiculus!
Has anybody encountered an «Identifier expected» error that doesn’t tell you WHERE the error came from?
I’m using VS2005 and developing 2 intranet sites. The main intranet site works fine, but just recently, whenever I try to build (Ctrl + B) or debug (F5) my 2nd site, I get just one error:
«Identifier expected»
It goes like this:
Description: Identifier expected
File: <empty>
Line: <empty>
Column: <empty>
Project: <empty>I can’t debug by site’s codes because of this!
If there is something with my code, why wouldn’t the error list panel tell me what and where it is?!
Somebody please help me! I feel like an idiot already…
«Better be a geek than an idiot…»
Answers
-
Hello Falcon,
Compilation Error CS1001 means we did not supply an identifier for an Enum, parameter name, etc…
Please take a look at this article for more information and some samples that generate CS1001:
http://msdn.microsoft.com/en-us/library/b839hwk4(VS.80).aspxIn this case, based on the detailed output, the issue might be caused by UserLogs.aspx.cs. We will be very appreciated if you could post a code snippet of UserLogs.aspx.cs file for our further analysis.
Also, we could post threads in our ASP.NET Forum for more information. More specifically, if the code related to a purticular database, like SQL Server, MySql, or any database else, please take a look at this thread in our ASP.NET Forum.
Thanks a lot!
Best regards,
Roahn
-
Marked as answer by
Wednesday, March 18, 2009 5:05 AM
-
Marked as answer by
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
public void RadarOnGUI() { Visuals.RadarList.Clear(); Rect radarRect = MenuHandler.RadarRect; Vector2 vector; vector..ctor(radarRect.center.x, radarRect.center.y + radarRect.height / 2f - 10f); Vector2 vector2; vector2..ctor(radarRect.center.x + radarRect.width / 2f - 10f, radarRect.center.y); Vector2 vector3; vector3..ctor(vector.x, vector2.y); int num = 20; float num2 = Math.Abs(radarRect.center.x - vector2.x); float num3 = num2 / (float)num; Vector3 position = Camera.main.transform.position; List<Zombie> list = new List<Zombie>(); foreach (ZombieRegion zombieRegion in ZombieManager.regions) { foreach (Zombie item in zombieRegion.zombies) { list.Add(item); } } foreach (Zombie zombie in list) { Vector2 vector4; vector4..ctor(zombie.transform.position.x - position.x, zombie.transform.position.z - position.z); float num4 = (float)Math.Round((double)(vector4.x * num3), 0); float num5 = (float)Math.Round((double)(vector4.y * num3), 0); num4 = -num4; Vector2 item2; item2..ctor(vector3.x + num4, vector3.y + num5); Log.l(vector3.ToString()); Log.l(item2.ToString()); Visuals.RadarList.Add(item2); } GUI.skin = HackDirector.sSkin; GUI.depth = 999; radarRect = MenuHandler.RadarRect; Vector2 vector5; vector5..ctor(radarRect.center.x, radarRect.center.y - radarRect.height / 2f + 20f); Vector2 vector6; vector6..ctor(radarRect.center.x - radarRect.width / 2f + 10f, radarRect.center.y); Vector2 vector7; vector7..ctor(vector6.x, vector.y); Vector2 vector8; vector8..ctor(vector2.x, vector.y); Vector2 vector9; vector9..ctor(vector6.x, vector5.y); Vector2 vector10; vector10..ctor(vector2.x, vector5.y); GL.PushMatrix(); GL.Begin(1); this.DrawingMaterial.SetPass(0); GL.End(); GL.PopMatrix(); GL.PushMatrix(); GL.Begin(1); this.DrawingMaterial.SetPass(0); GL.Color(Color.white); GL.Vertex3(vector.x, vector.y, 0f); GL.Vertex3(vector5.x, vector5.y, 0f); GL.Vertex3(vector6.x, vector6.y, 0f); GL.Vertex3(vector2.x, vector2.y, 0f); GL.Color(Color.black); GL.Vertex3(vector7.x, vector7.y, 0f); GL.Vertex3(vector8.x, vector8.y, 0f); GL.Vertex3(vector8.x, vector8.y, 0f); GL.Vertex3(vector10.x, vector10.y, 0f); GL.Vertex3(vector10.x, vector10.y, 0f); GL.Vertex3(vector9.x, vector9.y, 0f); GL.Vertex3(vector9.x, vector9.y, 0f); GL.Vertex3(vector7.x, vector7.y, 0f); GL.Color(Color.green); foreach (Vector2 input in Visuals.RadarList) { this.DrawSquare(input); } GL.End(); GL.PopMatrix(); } |