Error cs1525 unexpected symbol expecting

I've written some code which disables a script and starts a coroutine when a collision happens, but I get this error Assets/Scripts/SceneDelay.cs(16,40): error CS1525: Unexpected symbol ), expectin...

I’ve written some code which disables a script and starts a coroutine when a collision happens, but I get this error
Assets/Scripts/SceneDelay.cs(16,40): error CS1525: Unexpected symbol ), expecting (, [, or {
I have searched up this error but none of the answers help me in my situation, my code seems perfect to me, I don’t understand what’s wrong with it. Here’s my code:

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

public class SceneDelay : MonoBehaviour {

public static int score = 0;
public Text scoreText;

private void OnTriggerEnter2D(Collider2D collision)
{
    if (collision.tag == "Obstacle")
    {
        GetComponent(new ScoreScript).enabled = false;
        StartCoroutine(DelayLoad());
    }
}

IEnumerator DelayLoad()
{
    yield return new WaitForSeconds(1);

    SceneManager.LoadScene("Menu");
    scoreText.text = 0.ToString();
    score = 0;

    yield break;
}
}

Permalink

Cannot retrieve contributors at this time

description title ms.date f1_keywords helpviewer_keywords ms.assetid

Compiler Error CS1525

Compiler Error CS1525

07/20/2015

CS1525

CS1525

7913f589-2f2e-40bc-a27e-0b6930336484

Compiler Error CS1525

Invalid expression term ‘character’

The compiler detected an invalid character in an expression.

The following sample generates CS1525:

// CS1525.cs  
class x  
{  
   public static void Main()  
   {  
      int i = 0;  
      i = i +   // OK - identifier  
      'c' +     // OK - character  
      (5) +     // OK - parenthesis  
      [ +       // CS1525, operator not a valid expression element  
      throw +   // CS1525, keyword not allowed in expression  
      void;     // CS1525, void not allowed in expression  
   }  
}  

An empty label can also generate CS1525, as in the following sample:

// CS1525b.cs  
using System;  
public class MyClass  
{  
   public static void Main()  
   {  
      goto FoundIt;  
      FoundIt:      // CS1525  
      // Uncomment the following line to resolve:  
      // System.Console.Write("Hello");  
   }  
}  

Antoffa

0 / 0 / 0

Регистрация: 31.03.2016

Сообщений: 37

1

10.09.2021, 16:45. Показов 4214. Ответов 14

Метки с# (Все метки)


Ошибка на main.cs(25,5): error CS1525: Unexpected symbol `<‘
не запускается , что не так ???

Ошибка main.cs(25,5): error CS1525: Unexpected symbol `<'

C#
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
using System;
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            double x;
            double y;
            double z;
            double F = 0;
            char check;
 
            do
            {
                Console.WriteLine("Введите значение переменной x");
                Console.Write("x =");
                x = double.Parse(Console.ReadLine());
                Console.WriteLine("Введите значение переменной y");
                Console.Write("y =");
                y = double.Parse(Console.ReadLine());
                z = x - y;
                switch (z)
                {
                    case < 0:
                        F = Math.Sin(x) + Math.Cos(y) * Math.Cos(y);
                        break;
                    case 0:
                        F = Math.Log(x);
                        break;
                    case > 0:
                        F = Math.Sin(x) * Math.Sin(x) + Math.Cos(y);
                        break;
                }
                Console.WriteLine("F =" + F);
                Console.WriteLine("Хотите запустить программу вновь? Y/N");
                check = char.Parse(Console.ReadLine());
            } while (check == 'Y' || check == 'y');
        }
    }
}

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



Programming

Эксперт

94731 / 64177 / 26122

Регистрация: 12.04.2006

Сообщений: 116,782

10.09.2021, 16:45

Ответы с готовыми решениями:

Ошибка main.cs(17,11): error CS1525: Unexpected symbol `void’, expecting `class’, `delegate’, `enum’, `interface’,
Выскакивает ошибка main.cs(17,11): error CS1525: Unexpected symbol `void’, expecting `class’,…

Ошибка CS1525 Unexpected symbol
Помогите пожалуйста решить ошибку (38,2):error CS1525:Unexpected symbol {
Вот код:
using…

Opencv error :-1: ошибка: main.o: undefined reference to symbol ‘_ZN2cv6String10deallocateEv’
Добрый вечер, только начинаю знакомится с opencv
Появились проблемы при запуске первого примера

error C2601: ‘main’ : local function definitions are illegal fatal error C1004: unexpected end of file found
День добрый люди написал програму выдает 2 ошибки че не так подскажите

error C2601: ‘main’ :…

14

Модератор

Эксперт .NET

13302 / 9586 / 2574

Регистрация: 21.04.2018

Сообщений: 28,283

Записей в блоге: 2

10.09.2021, 17:05

2

Цитата
Сообщение от Antoffa
Посмотреть сообщение

error CS1525: Unexpected symbol `<‘

case может только сравнить со значением или шаблоном.
Замените switch-case на if-else if-else.



0



zhunshun

603 / 445 / 196

Регистрация: 05.04.2015

Сообщений: 1,773

10.09.2021, 17:13

3

Antoffa, Так нельзя делать
напиши функцию

C#
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
using System;
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            double x;
            double y;
            double z;
            double F = 0;
            char check;
 
            do
            {
                Console.WriteLine("Введите значение переменной x");
                Console.Write("x =");
                x = double.Parse(Console.ReadLine());
                Console.WriteLine("Введите значение переменной y");
                Console.Write("y =");
                y = double.Parse(Console.ReadLine());
                z = x - y;
                switch (returnValue(z))
                {
                    case < 0:
                        F = Math.Sin(x) + Math.Cos(y) * Math.Cos(y);
                        break;
                    case 0:
                        F = Math.Log(x);
                        break;
                    case > 0:
                        F = Math.Sin(x) * Math.Sin(x) + Math.Cos(y);
                        break;
                }
                Console.WriteLine("F =" + F);
                Console.WriteLine("Хотите запустить программу вновь? Y/N");
                check = char.Parse(Console.ReadLine());
            } while (check == 'Y' || check == 'y');
        }
        static int returnValue(int number){
            if(number > 0) return 1;
            if(number < 0) return -1;
            return 0;
        }
    }
}



0



Antoffa

0 / 0 / 0

Регистрация: 31.03.2016

Сообщений: 37

10.09.2021, 17:18

 [ТС]

4

Через if else правильно работает, необходимо преобразовать в switch, такая задача стояла

C#
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
using System;
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            double x;
            double y;
            double F;
            char check;
            do
            {
                Console.WriteLine("Введите значение переменной x");
                Console.Write("x =");
                x = double.Parse(Console.ReadLine());
                Console.WriteLine("Введите значение переменной y");
                Console.Write("y =");
                y = double.Parse(Console.ReadLine());
                if (x < y)
                {
                    F = Math.Sin(x) + Math.Cos(y) * Math.Cos(y);
                }
                else if (x == y)
                {
                    F = Math.Log(x);
                }
                else
                {
                    F = Math.Sin(x) * Math.Sin(x) + Math.Cos(y);
                }
                Console.WriteLine("F =" + F);
                Console.WriteLine("Хотите запустить программу вновь? Y/N");
                check = char.Parse(Console.ReadLine());
            } while (check == 'Y' || check == 'y');
        }
    }
}

Добавлено через 4 минуты
Через if else правильно работает, необходимо преобразовать в switch, такая задача стояла



0



1346 / 835 / 419

Регистрация: 06.02.2012

Сообщений: 2,603

10.09.2021, 17:26

5

Antoffa, Вам же выше написали, что swith не работает с операторами. Может вы не так поняли свою задачу?



0



0 / 0 / 0

Регистрация: 31.03.2016

Сообщений: 37

10.09.2021, 17:34

 [ТС]

6

Первоначально было через if else, но надо было изменить решение этой задачи, и поэтому подумал делать через switch. Как можно еще изменить данное решение ????



0



603 / 445 / 196

Регистрация: 05.04.2015

Сообщений: 1,773

10.09.2021, 17:38

7

Цитата
Сообщение от Antoffa
Посмотреть сообщение

Как можно еще изменить данное решение ????

А что мои вариант не подходит??



0



1465 / 1006 / 456

Регистрация: 30.10.2017

Сообщений: 2,793

10.09.2021, 17:46

8

Цитата
Сообщение от Элд Хасп
Посмотреть сообщение

case может только сравнить со значением или шаблоном.

В C#9 этот код скомпилируется.

Antoffa, если хотите, чтобы case работал способом, указанным вами, создайте консольное приложение с поддержкой .NET Core и в свойствах проекта укажите целевую рабочую среду .NET 5.0. Или используйте вместо switch/case конструкцию if/else.



0



Элд Хасп

Модератор

Эксперт .NET

13302 / 9586 / 2574

Регистрация: 21.04.2018

Сообщений: 28,283

Записей в блоге: 2

10.09.2021, 18:32

9

Цитата
Сообщение от QuakerRUS
Посмотреть сообщение

В C#9 этот код скомпилируется.

Ну, очевидно же, что TC не использует эту версию.

Добавлено через 3 минуты

Цитата
Сообщение от Antoffa
Посмотреть сообщение

Как можно еще изменить данное решение ????

Примените условный оператор:

C#
20
21
22
23
24
    F = x < y
        ? Math.Sin(x) + Math.Cos(y) * Math.Cos(y)
        : x == y
        ? Math.Log(x)
        : Math.Sin(x) * Math.Sin(x) + Math.Cos(y);



0



1465 / 1006 / 456

Регистрация: 30.10.2017

Сообщений: 2,793

10.09.2021, 18:33

10

Цитата
Сообщение от Элд Хасп
Посмотреть сообщение

Ну, очевидно же, что TC не использует эту версию.

Однако код написал правильно. Это легко сделать, загуглив описание использования switch в справке Microsoft, к примеру.
https://docs.microsoft.com/ru-… statements

А вот то, что надо и соответствующую версию языка использовать при этом, уже не так очевидно.

Цитата
Сообщение от Antoffa
Посмотреть сообщение

Через if else правильно работает, необходимо преобразовать в switch, такая задача стояла

Элд Хасп, к тому же в задании четко сказано, что нужно использовать для этого switch, а, значит, лекции могли проводиться по этой версии языка.

Конечно, возможно все это мои догадки.



0



Модератор

Эксперт .NET

13302 / 9586 / 2574

Регистрация: 21.04.2018

Сообщений: 28,283

Записей в блоге: 2

10.09.2021, 18:38

11

Antoffa, но уточните у преподавателя на каком платформе и версии Шарпа допустимо выполнять задание.
Если допустима версия 9, то, как выше написал QuakerRUS, в ней скомпилируется и вариант с switch-case.

Добавлено через 2 минуты

Цитата
Сообщение от QuakerRUS
Посмотреть сообщение

к тому же в задании четко сказано, что нужно использовать для этого switch

Когда я отвечал, этого не было сказано.
Кроме того, постом позже TC поправляется, в задании нужно сделать «по другому».
А switch — это его попытка другой реализации.



1



1465 / 1006 / 456

Регистрация: 30.10.2017

Сообщений: 2,793

10.09.2021, 18:44

12

Цитата
Сообщение от Элд Хасп
Посмотреть сообщение

Кроме того, постом позже TC поправляется, в задании нужно сделать «по другому».

Тогда может быть все банальнее, например, преподавателю не понравилось, что расчет формулы не вынесен в отдельный метод.

Добавлено через 4 минуты
Antoffa, вы бы для начала узнали, что именно не понравилось преподавателю.



1



Antoffa

0 / 0 / 0

Регистрация: 31.03.2016

Сообщений: 37

10.09.2021, 19:31

 [ТС]

13

Вот так ???

C#
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
using System;
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            double x;
            double y;
            double z;
            double F = 0;
            char check;
 
            do
            {
                Console.WriteLine("Введите значение переменной x");
                Console.Write("x =");
                x = double.Parse(Console.ReadLine());
                Console.WriteLine("Введите значение переменной y");
                Console.Write("y =");
                y = double.Parse(Console.ReadLine());
                z = x - y;
                 F = x < y
        ? Math.Sin(x) + Math.Cos(y) * Math.Cos(y)
        : x == y
        ? Math.Log(x)
        : Math.Sin(x) * Math.Sin(x) + Math.Cos(y);
 
                Console.WriteLine("F =" + F);
                Console.WriteLine("Хотите запустить программу вновь? Y/N");
                check = char.Parse(Console.ReadLine());
            } while (check == 'Y' || check == 'y');
        }
        static int returnValue(int number){
            if(number > 0) return 1;
            if(number < 0) return -1;
            return 0;
        }
    }
}



0



Модератор

Эксперт .NET

13302 / 9586 / 2574

Регистрация: 21.04.2018

Сообщений: 28,283

Записей в блоге: 2

10.09.2021, 19:33

14

Цитата
Сообщение от Antoffa
Посмотреть сообщение

Вот так ???

Да.

Добавлено через 21 секунду
Antoffa, по интерфейсу Форума:

 Комментарий модератора 
При обращении к другому пользователю указывайте его ник в тегах [NICK][/NICK] или цитируйте часть сообщения на которое отвечаете.
В противном случае ему не придёт уведомление о вашем обращении и вы можете не дождаться ответа на своё сообщение.

Для вставки ника: введите ник, выделите его и нажмите кнопку «Динамик» на панели редактора сообщений.
Или кликните по нику автора сообщения в панели слева от текста его сообщения.

Для вставки цитаты: выделите нужную цитату, должна появиться всплывающая кнопка «Цитировать», нажмите её.

Добавлено через 35 секунд
Antoffa, и заключайте код в теги.
Для этого есть кнопки в панели редактора сообщений.



0



Antoffa

0 / 0 / 0

Регистрация: 31.03.2016

Сообщений: 37

10.09.2021, 19:48

 [ТС]

15

А можно данный вариант решить еще через цикл??

Цитата
Сообщение от Antoffa
Посмотреть сообщение

C#
23
24
25
26
27
                 F = x < y
        ? Math.Sin(x) + Math.Cos(y) * Math.Cos(y)
        : x == y
        ? Math.Log(x)
        : Math.Sin(x) * Math.Sin(x) + Math.Cos(y);

Добавлено через 1 минуту
Ну или данную задачу

Цитата
Сообщение от Antoffa
Посмотреть сообщение

А можно данный вариант решить еще через цикл??



0



For a long time I can’t understand what the matter is, it seems like everything is fine everywhere, or maybe I’m blind

Error while compiling: SkyMenu.cs(550,16): error CS1525: Unexpected symbol `void’, expecting `class’, `delegate’, `enum’, `interface’, `partial’, or `struct’

If it doesn’t bother you, please help me

  1  using Oxide.Core.Plugins;
  2  using Oxide.Game.Rust.Cui;
  3  using System;
  4  using System.Collections;
  5  using System.Collections.Generic;
  6  using System.Linq;
  7  using System.Globalization;
  8  using UnityEngine;
  9  using Color = UnityEngine.Color;
 10  using Random = UnityEngine.Random;
 11  
 12  namespace Oxide.Plugins
 13  {
 14      [Info("SkyMenu", "JoyRax", "0.0.1")]
 15      [Description("Menu game info")]
 16      class SkyMenu : RustPlugin
 17      {
 18          #region Vars
 19          [PluginReference] private Plugin ImageLibrary, NTeleportation;
 20          private string MainLayer = "ui_main";
 21  
 22          #endregion 
 23  
 24          #region Configuration
 25  
 26          private class PluginConfig
 27          {
 28              public CuiStandardElementSetting _CuiStandardElementSetting;
 29              public CuiServerNameSetting _CuiServerNameSetting;
 30              public CuiAvatarSetting _CuiAvatarSetting;
 31              public List<CuiUButtonSetting> _CuiUButtonSetting;
 32          }
 33  
 34          private class Anchor
 35          {
 36              public string Min;
 37              public string Max;
 38          }
 39  
 40          private class CuiStandardElementSetting
 41          {
 42              public string BackgroundColor;
 43              public Anchor Anchor;
 44              public bool CursorEnabled;
 45              public string Layer;
 46          }
 47  
 48          private class CuiServerNameSetting
 49          {
 50              public string NameServer;
 51              public string BackgroundColor;
 52              public string TextColor;
 53              public Anchor Anchor;
 54              public string ELParent;
 55              public string ELName;
 56              public string Font;
 57              public int FontSize;
 58          }
 59  
 60          private class CuiAvatarSetting
 61          {
 62              public string BackgroundColor;
 63              public string TextColor;
 64              public Anchor Anchor;
 65              public string ELParent;
 66              public string ELName;
 67              public string ELNameImage;
 68              public string ELNameText;
 69              public string Font;
 70              public int FontSize;
 71          }
 72  
 73          private class CuiStandardButtonSetting 
 74          {
 75              public string BackgroundColor;
 76              public string SmallBackgroundColor;
 77              public string TextColor;
 78              public string ELParent;
 79              public string ELName;
 80              public string ELSmallName;
 81              public string Font;
 82              public int FontSize;
 83              public int FontSizeSmall;
 84          }
 85  
 86          private class CuiUButtonSetting : CuiStandardButtonSetting
 87          {
 88              public Anchor Anchor;
 89              public string SmallText;
 90              public string Text;
 91              public string Command;
 92          }
 93  
 94          private PluginConfig _config;
 95  
 96          protected override void LoadDefaultConfig()
 97          {
 98              Config.WriteObject(GetDefaultConfig(), true);
 99          }
100  
101          private PluginConfig GetDefaultConfig()
102          {
103              return new PluginConfig
104              {
105                  _CuiStandardElementSetting = new CuiStandardElementSetting
106                  {
107                      BackgroundColor = "0 0 0 0.5",
108                      Anchor = new Anchor
109                      {
110                          Min = "0 0",
111                          Max = "1 1"
112                      },
113                      CursorEnabled = true,
114                      Layer = MainLayer
115                  },
116                  _CuiServerNameSetting = new CuiServerNameSetting
117                  {
118                      NameServer = "POISON RUST",
119                      BackgroundColor = "0 0 0 0.9",
120                      TextColor = "255 255 255 0.5",
121                      Anchor = new Anchor
122                      {
123                          Min = "0 0.944",
124                          Max = "1 1"
125                      },
126                      ELParent = MainLayer,
127                      ELName = MainLayer + ".PanelNameServer",
128                      Font = "robotocondensed-bold.ttf",
129                      FontSize = 22;
130                  }
131                  _CuiAvatarSetting = new CuiAvatarSetting
132                  {
133                      BackgroundColor = "0 0 0 0.9",
134                      TextColor = "255 255 255 0.5",
135                      Anchor = new Anchor
136                      {
137                          Min = "0.25 0.542",
138                          Max = "0.352 0.764"
139                      },
140                      ELParent = MainLayer,
141                      ELName = MainLayer = ".Avatar",
142                      ELNameImage = MainLayer = ".AvatarImage",
143                      ELNameText = MainLayer = ".AvatarText",
144                      Font = "robotocondensed-bold.ttf",
145                      FontSize = 20
146                  }
147  
148                  _CuiUButtonSetting = new List<CuiUButtonSetting>()
149                  {
150                      new CuiUButtonSetting
151                      {
152                          BackgroundColor = "0 0 0 0.9",
153                          SmallBackgroundColor = "255 255 255 0.05",
154                          TextColor = "255 255 255 0.5",
155                          ELParent = MainLayer,
156                          ELName = MainLayer + ".StandardButton",
157                          ELSmallName = MainLayer + ".StandardButtonSmallText",
158                          Font = "robotocondensed-bold.ttf",
159                          FontSize = 20,
160                          FontSizeSmall = 12,
161                          Anchor = new Anchor
162                          {
163                              Min = "0.25 0.465",
164                              Max = "0.352 0.535"
165                          },
166                          SmallText = "OPEN",
167                          Text = "STATISTICS",
168                          Command = "chat.say /test"
169                      },
170                      new CuiUButtonSetting
171                      {
172                          BackgroundColor = "0 0 0 0.9",
173                          SmallBackgroundColor = "255 255 255 0.05",
174                          TextColor = "255 255 255 0.5",
175                          ELParent = MainLayer,
176                          ELName = MainLayer + ".StandardButton",
177                          ELSmallName = MainLayer + ".StandardButtonSmallText",
178                          Font = "robotocondensed-bold.ttf",
179                          FontSize = 20,
180                          FontSizeSmall = 12,
181                          Anchor = new Anchor
182                          {
183                              Min = "0.25 0.389",
184                              Max = "0.352 0.458"
185                          },
186                          SmallText = "ACCEPT",
187                          Text = "TELEPORT",
188                          Command = "chat.say /test"
189                      },
190                      new CuiUButtonSetting
191                      {
192                          BackgroundColor = "0 0 0 0.9",
193                          SmallBackgroundColor = "255 255 255 0.05",
194                          TextColor = "255 255 255 0.5",
195                          ELParent = MainLayer,
196                          ELName = MainLayer + ".StandardButton",
197                          ELSmallName = MainLayer + ".StandardButtonSmallText",
198                          Font = "robotocondensed-bold.ttf",
199                          FontSize = 20,
200                          FontSizeSmall = 12,
201                          Anchor = new Anchor
202                          {
203                              Min = "0.25 0.313",
204                              Max = "0.352 0.382"
205                          },
206                          SmallText = "ACCEPT",
207                          Text = "TRADE",
208                          Command = "chat.say /test"
209                      },
210                      new CuiUButtonSetting
211                      {
212                          BackgroundColor = "0 0 0 0.9",
213                          SmallBackgroundColor = "255 255 255 0.05",
214                          TextColor = "255 255 255 0.5",
215                          ELParent = MainLayer,
216                          ELName = MainLayer + ".StandardButton",
217                          ELSmallName = MainLayer + ".StandardButtonSmallText",
218                          Font = "robotocondensed-bold.ttf",
219                          FontSize = 20,
220                          FontSizeSmall = 12,
221                          Anchor = new Anchor
222                          {
223                              Min = "0.25 0.236",
224                              Max = "0.352 0.306"
225                          },
226                          SmallText = "OPEN",
227                          Text = "WIPE BLOCK",
228                          Command = "chat.say /test"
229                      },
230                      new CuiUButtonSetting
231                      {
232                          BackgroundColor = "0 0 0 0.9",
233                          SmallBackgroundColor = "255 255 255 0.05",
234                          TextColor = "255 255 255 0.5",
235                          ELParent = MainLayer,
236                          ELName = MainLayer + ".StandardButton",
237                          ELSmallName = MainLayer + ".StandardButtonSmallText",
238                          Font = "robotocondensed-bold.ttf",
239                          FontSize = 20,
240                          FontSizeSmall = 12,
241                          Anchor = new Anchor
242                          {
243                              Min = "0.355 0.694",
244                              Max = "0.457 0.764"
245                          },
246                          SmallText = "OPEN",
247                          Text = "KITS",
248                          Command = "chat.say /test"
249                      },
250                      new CuiUButtonSetting
251                      {
252                          BackgroundColor = "0 0 0 0.9",
253                          SmallBackgroundColor = "255 255 255 0.05",
254                          TextColor = "255 255 255 0.5",
255                          ELParent = MainLayer,
256                          ELName = MainLayer + ".StandardButton",
257                          ELSmallName = MainLayer + ".StandardButtonSmallText",
258                          Font = "robotocondensed-bold.ttf",
259                          FontSize = 20,
260                          FontSizeSmall = 12,
261                          Anchor = new Anchor
262                          {
263                              Min = "0.355 0.618",
264                              Max = "0.457 0.688"
265                          },
266                          SmallText = "OPEN",
267                          Text = "CASES",
268                          Command = "chat.say /test"
269                      },
270                      new CuiUButtonSetting
271                      {
272                          BackgroundColor = "0 0 0 0.9",
273                          SmallBackgroundColor = "255 255 255 0.05",
274                          TextColor = "255 255 255 0.5",
275                          ELParent = MainLayer,
276                          ELName = MainLayer + ".StandardButton",
277                          ELSmallName = MainLayer + ".StandardButtonSmallText",
278                          Font = "robotocondensed-bold.ttf",
279                          FontSize = 20,
280                          FontSizeSmall = 12,
281                          Anchor = new Anchor
282                          {
283                              Min = "0.355 0.542",
284                              Max = "0.457 0.611"
285                          },
286                          SmallText = "SEND",
287                          Text = "TICKET",
288                          Command = "chat.say /test"
289                      },
290                      new CuiUButtonSetting
291                      {
292                          BackgroundColor = "0 0 0 0.9",
293                          SmallBackgroundColor = "255 255 255 0.05",
294                          TextColor = "255 255 255 0.5",
295                          ELParent = MainLayer,
296                          ELName = MainLayer + ".StandardButton",
297                          ELSmallName = MainLayer + ".StandardButtonSmallText",
298                          Font = "robotocondensed-bold.ttf",
299                          FontSize = 20,
300                          FontSizeSmall = 12,
301                          Anchor = new Anchor
302                          {
303                              Min = "0.355 0.465",
304                              Max = "0.457 0.535"
305                          },
306                          SmallText = "OPEN",
307                          Text = "STORE",
308                          Command = "chat.say /test"
309                      },
310                      new CuiUButtonSetting
311                      {
312                          BackgroundColor = "0 0 0 0.9",
313                          SmallBackgroundColor = "255 255 255 0.05",
314                          TextColor = "255 255 255 0.5",
315                          ELParent = MainLayer,
316                          ELName = MainLayer + ".StandardButton",
317                          ELSmallName = MainLayer + ".StandardButtonSmallText",
318                          Font = "robotocondensed-bold.ttf",
319                          FontSize = 20,
320                          FontSizeSmall = 12,
321                          Anchor = new Anchor
322                          {
323                              Min = "0.355 0.389",
324                              Max = "0.457 0.458"
325                          },
326                          SmallText = "OPEN",
327                          Text = "INFO",
328                          Command = "chat.say /test"
329                      },
330                      new CuiUButtonSetting
331                      {
332                          BackgroundColor = "0 0 0 0.9",
333                          SmallBackgroundColor = "255 255 255 0.05",
334                          TextColor = "255 255 255 0.5",
335                          ELParent = MainLayer,
336                          ELName = MainLayer + ".StandardButton",
337                          ELSmallName = MainLayer + ".StandardButtonSmallText",
338                          Font = "robotocondensed-bold.ttf",
339                          FontSize = 20,
340                          FontSizeSmall = 12,
341                          Anchor = new Anchor
342                          {
343                              Min = "0.355 0.313",
344                              Max = "0.457 0.382"
345                          },
346                          SmallText = "OPEN",
347                          Text = "VK GROUP",
348                          Command = "chat.say /test"
349                      },
350                      new CuiUButtonSetting
351                      {
352                          BackgroundColor = "0 0 0 0.9",
353                          SmallBackgroundColor = "255 255 255 0.05",
354                          TextColor = "255 255 255 0.5",
355                          ELParent = MainLayer,
356                          ELName = MainLayer + ".StandardButton",
357                          ELSmallName = MainLayer + ".StandardButtonSmallText",
358                          Font = "robotocondensed-bold.ttf",
359                          FontSize = 20,
360                          FontSizeSmall = 12,
361                          Anchor = new Anchor
362                          {
363                              Min = "0.355 0.236",
364                              Max = "0.457 0.306"
365                          },
366                          SmallText = "OPEN",
367                          Text = "DISCORD",
368                          Command = "chat.say /test"
369                      }
370                  };
371              };
372          }
373  
374          private void SaveConfig()
375          {
376              Config.WriteObject(_config, true);
377          }
378  
379          #endregion
380  
381          #region Init
382  
383          void OnServerInitialized(bool serverInitialized)
384          {
385              _config = Config.ReadObject<PluginConfig>();
386          }
387  
388          #endregion
389  
390          #region CuiRustCustomHelper
391  
392          private static class CuiRustCustomHelper
393          {
394              public static CuiElementContainer GettingStandardElement(CuiStandardElementSetting _setting)
395              {
396                  var container = new CuiElementContainer();
397  
398                  container.Add(new CuiPanel
399                  {
400                      Image = { Color = "0 0 0 0" },
401                      RectTransform = { AnchorMin = _setting.Anchor.Min, AnchorMax = _setting.Anchor.Max },
402                      CursorEnabled = _setting.CursorEnabled,
403                  }, "Overlay", _setting.Layer);
404  
405                  container.Add(new CuiElement
406                  {
407                      Parent = LayerMain,
408                      Components =
409                      {
410                          new CuiRawImageComponent { Color = _setting.BackgroundColor, FadeIn = 0.5f, Sprite = "assets/content/ui/ui.background.tiletex.psd", Material = "assets/content/ui/uibackgroundblur-ingamemenu.mat" },
411                          new CuiRectTransformComponent{ AnchorMin = "0 0", AnchorMax = "1 1" }
412                      }
413                  });
414  
415                  return container;
416              }
417  
418              public static CuiElementContainer GettingServerNameElement(CuiServerNameSetting _setting)
419              {
420                  var container = new CuiElementContainer();
421  
422                  container.Add(new CuiElement
423                  {
424                      Parent = _setting.ELParent,
425                      Name = _setting.ELName,
426                      Components =
427                      {
428                          new CuiImageComponent { FadeIn = 0.25f, Color = _setting.BackgroundColor} ,
429                          new CuiRectTransformComponent { AnchorMin = _setting.Anchor.Min, AnchorMax = _setting.Anchor.Max }
430                      }
431                  });
432                  container.Add(new CuiElement
433                  {
434                      Parent = _setting.ELName,
435                      Components = {
436                          new CuiTextComponent() { Color = _setting.TextColor, FadeIn = 1f, Text = _setting.NameServer, FontSize = _setting.FontSize, Align = TextAnchor.MiddleCenter, Font = _setting.Font },
437                          new CuiRectTransformComponent { AnchorMin = "0 0", AnchorMax = "1 1" },
438                      }
439                  });
440  
441                  return container;
442              }
443  
444              public static CuiElementContainer GettingAvatarElement(BasePlayer player, CuiAvatarSetting _setting)
445              {
446                  var container = new CuiElementContainer();
447  
448                  container.Add(new CuiElement
449                  {
450                      Parent = _setting.ELParent,
451                      Name = _setting.ELName,
452                      Components =
453                      {
454                          new CuiImageComponent {FadeIn = 0.25f, Color = _setting.BackgroundColor},
455                          new CuiRectTransformComponent { AnchorMin = _setting.Anchor.Min, AnchorMax = _setting.Anchor.Max }
456                      }
457                  });
458                  container.Add(new CuiElement
459                  {
460                      Parent = _setting.ELName,
461                      Name = _setting.ELNameImage,
462                      Components =
463                      {
464                          new CuiImageComponent {FadeIn = 0.25f, Color = "0 0 0 0"},
465                          new CuiRectTransformComponent {AnchorMin = "0 0.188", AnchorMax = "1 1"}
466                      }
467                  });
468                  container.Add(new CuiElement
469                  {
470                      Parent = _setting.ELNameImage,
471                      Components =
472                      {
473                          new CuiRawImageComponent { Png = (string) ImageLibrary.Call("GetImage", player.UserIDString) },
474                          new CuiRectTransformComponent { AnchorMin = "0 0", AnchorMax = "1 1", OffsetMax = "0 0" }
475                      }
476                  });
477                  container.Add(new CuiElement
478                  {
479                      Parent = _setting.ELName,
480                      Name = _setting.ELNameText,
481                      Components =
482                      {
483                          new CuiImageComponent {FadeIn = 0.25f, Color = "0 0 0 0"},
484                          new CuiRectTransformComponent {AnchorMin = "0 0", AnchorMax = "1 0.188"}
485                      }
486                  });
487                  container.Add(new CuiElement
488                  {
489                      Parent = _setting.ELNameText,
490                      Components = {
491                          new CuiTextComponent() { Color = _setting.TextColor, FadeIn = 1f, Text = ""+player.displayName.ToUpper()+"", FontSize = _setting.FontSize, Align = TextAnchor.MiddleCenter, Font = _setting.Font },
492                          new CuiRectTransformComponent { AnchorMin = "0 0", AnchorMax = "1 1" },
493                      }
494                  });
495  
496                  return container;
497              }
498  
499              public static CuiElementContainer GettingButtonElement(BasePlayer player, List<CuiUButtonSetting> _setting)
500              {
501                  var container = new CuiElementContainer();
502  
503                  foreach (var _settingItem in _setting)
504                  {
505                      container.Add(new CuiElement
506                      {
507                          Parent = _settingItem.ELParent,
508                          Name = _settingItem.ELName,
509                          Components = {
510                              new CuiImageComponent {FadeIn = 0.25f, Color = _settingItem.BackgroundColor},
511                              new CuiRectTransformComponent {AnchorMin = _settingItem.Anchor.Min, AnchorMax = _settingItem.Anchor.Max}
512                          }
513                      });
514                      container.Add(new CuiButton
515                      {
516                          RectTransform = { AnchorMin = "0 0", AnchorMax = "1 0.7" },
517                          Button = { Command = _settingItem.Command, Close = _settingItem.ELParent, Color = "0 0 0 0" },
518                          Text = { Color = _settingItem.TextColor, Text = _settingItem.Text, FontSize = _settingItem.FontSize, Align = TextAnchor.MiddleCenter, Font = _settingItem.Font }
519                      }, _settingItem.ELName);
520                      container.Add(new CuiElement
521                      {
522                          Parent = _settingItem.ELName,
523                          Name = _settingItem.ELSmallName,
524                          Components = {
525                              new CuiImageComponent {FadeIn = 0.25f, Color = _settingItem.SmallBackgroundColor},
526                              new CuiRectTransformComponent {AnchorMin = "0 0.7", AnchorMax = "1 1"}
527                          }
528                      });
529                      container.Add(new CuiElement
530                      {
531                          Parent = _settingItem.ELSmallName,
532                          Components = {
533                              new CuiTextComponent() {Color = _settingItem.TextColor, FadeIn = 1f, Text = _settingItem.SmallText, FontSize = _settingItem.FontSize, Align = TextAnchor.MiddleCenter, Font = _settingItem.Font},
534                              new CuiRectTransformComponent {AnchorMin = "0 0", AnchorMax = "1 1"}
535                          }
536                      });
537                  }
538  
539                  return container;
540              }
541          }
542  
543          #endregion
544  
545          #region UI
546  
547          private void CustomDrawCUI(BasePlayer player)
548          {
549              CuiHelper.AddUi(player, GettingStandardElement(_config._CuiStandardElementSetting)); 
550              CuiHelper.AddUi(player, GettingServerNameElement(_config._CuiServerNameSetting)); 
551              CuiHelper.AddUi(player, GettingAvatarElement(player, _config._CuiAvatarSetting)); 
552              CuiHelper.AddUi(player, GettingButtonElement(player, _config._CuiUButtonSetting)); 
553          }
554  
555          private void CustomDestroyCUI(BasePlayer player)
556          {
557              CuiHelper.DestroyUi(player, MainLayer);
558          }
559  
560          #endregion
561  
562          #region Hook
563  
564          [ChatCommand("menu")]
565          private void ChatOpenMenu(BasePlayer player)
566          {
567              CustomDrawCUI(player);
568          }
569  
570          [ChatCommand("menu.close")]
571          private void ChatCloseMenu(BasePlayer player)
572          {
573              CustomDestroyCUI(player);
574          }
575  
576          [ConsoleCommand("skymenu.open")]
577          private void CmdOpenMenu(BasePlayer player)
578          {
579              CustomDrawCUI(player);
580          }
581  
582          [ConsoleCommand("skymenu.close")]
583          private void CmdCloseMenu(BasePlayer player)
584          {
585              CustomDestroyCUI(player);
586          }
587  
588          #endregion
589      }
590  }

What I have tried:

I can’t figure out how to deal with this error

Содержание

  1. C# error CS1525: Unexpected symbol `>’
  2. 2 Answers
  3. Your program «works», but deviates from the instructions.
  4. Почему выдает ошибку CS1525?? Что-то плохо?
  5. «error CS1525: Unexpected symbol» on Run (Alt+Shift+Enter) #1
  6. Comments
  7. Почему выдает ошибку CS1525?? Что-то плохо?
  8. «error CS1525: Unexpected symbol» on Run (Alt+Shift+Enter) #1
  9. Comments

C# error CS1525: Unexpected symbol `>’

I am sure that every «<» has its equally paired «>» in my code, but the compiler keep telling me that Program.cs(20,40): error CS1525: Unexpected symbol `>’. I wonder where my mistake is, and how can I fix it?

2 Answers

Steven Parker
Steven Parker

Your program «works», but deviates from the instructions.

This is a great example of how something that works (will compile an run) might not be what was asked for (satisfies the requirements). This has been a topic of many previous questions, but I’ll repost the info here:

People often over-think this one and get too creative, and their answer is rejected for a variety of reasons (some which don’t seem to make any sense).

Here are the secret «rules» you must follow for success on this one:

  • Your program must ask for and accept input ONE TIME ONLY
  • If the input validates, your program will perform exactly as in Task 1
  • If the input does not validate, it will print the error message and exit
  • Validation must be done by exception catching. There are other perfectly good methods that can be used for validation, but they will not pass this challenge

It looks like you have an extra loop that is violating the first and third «rule».

Источник

Почему выдает ошибку CS1525?? Что-то плохо?

ПОЖАЛУЙСТА ПОМОГИ !! Я не знаю, что происходит, этот кусок моего дурацкого кода не работает. Пожалуйста, помогите мне, потому что я новичок в С#, и я просто пытаюсь написать код для практики. Я написал «оператор If», и обычно он должен работать с: <>, но это не так. И есть еще несколько проблем, вот вывод над кодом:

вы пропустили закрытие )

Последовательный отступ облегчает обнаружение этих проблем много.

Крик «ПОЖАЛУЙСТА, ПОМОГИТЕ» почти всегда принесет вам пару дополнительных голосов против. Публикации Каждый здесь нужна помощь — мы это знаем.

Max Gaming 4000

вам не хватает закрывающего паратеза:

у вас есть лишняя скобка:

Переформатированный код должен выглядеть так:

Кроме того, ваши переменные int . никогда будут содержать «y». возможно, вы захотите изменить эти два на строки

Также. String.Contains() . какую строку вы проверяете? Есть на что посмотреть 🙂

Возможно, enterInfo.Contains(«y») может быть вам полезен.

Большое спасибо ! Я такая дура. Но, пожалуйста, почему он говорит мне main.cs(23,246): ошибка CS1525: неожиданный символ «конец файла»

Max Gaming 4000

обновил мой ответ

здесь я опубликую, как должен выглядеть ваш код, так как мой ответ дайте мне секунду

Источник

«error CS1525: Unexpected symbol» on Run (Alt+Shift+Enter) #1

Great tool! I have a problem though.

I paste this in the window:

and when I hit Alt+Shift+Enter I get:

(4,0): error CS1525: Unexpected symbol strings’`

When I move to each line and hit Alt+Enter everything executes well.

[Evaluating external code (Scratchpad.csx)]

[Evaluating external code (Scratchpad.csx)]

[Evaluating external code (Scratchpad.csx)]

[Evaluating external code (Scratchpad.csx)]

[Evaluating external code (Scratchpad.csx)]

[Evaluating external code (Scratchpad.csx)]

[Evaluating external code (Scratchpad.csx)]

[Evaluating external code (Scratchpad.csx)]

[Evaluating external code (Scratchpad.csx)]

so it must be some kind of bug. can you please check?

thank you!
david

The text was updated successfully, but these errors were encountered:

There are 2 things going on, first you forgot a semicolon «;» on the 3rd line. But you are right, pasting multi-line statements to the REPL doesnt work right now, but I’ll add that soon, I think it should be supported.

If add all the code to one line and fix the colon it should work.

One more thing, if you select the whole block of code in a script file and then hit alt+Enter it will work!

oh the semicolon! that’s the culprit for the entire issue.
when I add it, everything works.. so not sure what you are saying that pasting multi-line statements doesn’t work.

when I don’t add the semicolon, select the entire code and hit alt+Enter, it’s still the same error..

the reason I didn’t pick up on the error message saying the error was on (4,0) is that I was sure the problem is in the first line and (4,0) is referring to «strings» symbol there.. when in reality it was the 4th line (because the semicolon was missing on the third line)..

I’m happy , everything works! 🙂 thank you!

Источник

Почему выдает ошибку CS1525?? Что-то плохо?

ПОЖАЛУЙСТА ПОМОГИ !! Я не знаю, что происходит, этот кусок моего дурацкого кода не работает. Пожалуйста, помогите мне, потому что я новичок в С#, и я просто пытаюсь написать код для практики. Я написал «оператор If», и обычно он должен работать с: <>, но это не так. И есть еще несколько проблем, вот вывод над кодом:

вы пропустили закрытие )

Последовательный отступ облегчает обнаружение этих проблем много.

Крик «ПОЖАЛУЙСТА, ПОМОГИТЕ» почти всегда принесет вам пару дополнительных голосов против. Публикации Каждый здесь нужна помощь — мы это знаем.

Max Gaming 4000

вам не хватает закрывающего паратеза:

у вас есть лишняя скобка:

Переформатированный код должен выглядеть так:

Кроме того, ваши переменные int . никогда будут содержать «y». возможно, вы захотите изменить эти два на строки

Также. String.Contains() . какую строку вы проверяете? Есть на что посмотреть 🙂

Возможно, enterInfo.Contains(«y») может быть вам полезен.

Большое спасибо ! Я такая дура. Но, пожалуйста, почему он говорит мне main.cs(23,246): ошибка CS1525: неожиданный символ «конец файла»

Max Gaming 4000

обновил мой ответ

здесь я опубликую, как должен выглядеть ваш код, так как мой ответ дайте мне секунду

Источник

«error CS1525: Unexpected symbol» on Run (Alt+Shift+Enter) #1

Great tool! I have a problem though.

I paste this in the window:

and when I hit Alt+Shift+Enter I get:

(4,0): error CS1525: Unexpected symbol strings’`

When I move to each line and hit Alt+Enter everything executes well.

[Evaluating external code (Scratchpad.csx)]

[Evaluating external code (Scratchpad.csx)]

[Evaluating external code (Scratchpad.csx)]

[Evaluating external code (Scratchpad.csx)]

[Evaluating external code (Scratchpad.csx)]

[Evaluating external code (Scratchpad.csx)]

[Evaluating external code (Scratchpad.csx)]

[Evaluating external code (Scratchpad.csx)]

[Evaluating external code (Scratchpad.csx)]

so it must be some kind of bug. can you please check?

thank you!
david

The text was updated successfully, but these errors were encountered:

There are 2 things going on, first you forgot a semicolon «;» on the 3rd line. But you are right, pasting multi-line statements to the REPL doesnt work right now, but I’ll add that soon, I think it should be supported.

If add all the code to one line and fix the colon it should work.

One more thing, if you select the whole block of code in a script file and then hit alt+Enter it will work!

oh the semicolon! that’s the culprit for the entire issue.
when I add it, everything works.. so not sure what you are saying that pasting multi-line statements doesn’t work.

when I don’t add the semicolon, select the entire code and hit alt+Enter, it’s still the same error..

the reason I didn’t pick up on the error message saying the error was on (4,0) is that I was sure the problem is in the first line and (4,0) is referring to «strings» symbol there.. when in reality it was the 4th line (because the semicolon was missing on the third line)..

I’m happy , everything works! 🙂 thank you!

Источник

Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Li Yu

I am sure that every «{» has its equally paired «}» in my code, but the compiler keep telling me that Program.cs(20,40): error CS1525: Unexpected symbol `}’.
I wonder where my mistake is, and how can I fix it?


Program.cs

using System;

namespace Treehouse.CodeChallenges
{
    class Program
    {
        static void Main()
        {
            while(true)  //loop started
            {
                Console.Write("Enter the number of times to print "Yay!": ");
                string entry = Console.ReadLine();

                    if(entry.ToLower()=="quit")
                    {
                        break;
                    }
                    else
                    {
                        int time = int.Parse(entry);  //turn "string" into "int"
                        int k;
                        for(k = 0; k < time)  //make the loop run k times
                        {
                            Console.Write("Yay!");
                            k = k + 1;
                            continue;
                        }    
                    }

                break;  //leave the "while loop" since "for" is not satisfied
            }    
        }
    }
}

2 Answers

Steven Parker

:point_right: Your program «works», but deviates from the instructions.

This is a great example of how something that works (will compile an run) might not be what was asked for (satisfies the requirements). This has been a topic of many previous questions, but I’ll repost the info here:

People often over-think this one and get too creative, and their answer is rejected for a variety of reasons (some which don’t seem to make any sense).

Here are the secret «rules» you must follow for success on this one:

  • Your program must ask for and accept input ONE TIME ONLY
  • If the input validates, your program will perform exactly as in Task 1
  • If the input does not validate, it will print the error message and exit
  • Validation must be done by exception catching. There are other perfectly good methods that can be used for validation, but they will not pass this challenge

It looks like you have an extra loop that is violating the first and third «rule».

Avan Sharma

using System;

namespace Treehouse.CodeChallenges
{
    class Program
    {
        static void Main()
        {
                              Console.Write("Enter the number of times to print "Yay!": ");
                                    int entry = int.Parse(Console.ReadLine());
                            for(int i=0;i<entry;i++)
                           {
                                 Console.WriteLine("Yay!");
                            }
         }
    }
}

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

public class PlaerMufment : MonoBehaviour {

    CharacterController cc;
    Vector3 moveVec;

    float speed = 5;

    int laneNamber = 1,
        lanesCount = 2;

    public float FirstlanePos,
                 LaneDistance,
                 SideSpeed;


    void Start()
    {
        cc = GetComponent<CharacterController>();
        moveVec = new Vector3(1, 0, 0);
    }

    


    void Update()
    {
        moveVec.x *= speed;
        moveVec *= Time.deltaTime;

        float imput = Input.GetAxis("Horizontal");

        if (Mathf.Abs(input) >.if);
        {
            laneNamber += (int)Matht.Sign(input);
            laneNamber = Mathf.Clamp(laneNamber, 0, lanesCount);
        }

        Vectore3 newPos = transfore.position;
        newPos.z = Mathf.Lerp(newPos.z, FirstLanePos + (laneNamber * LaneDistance), Time.deltaTime * SideSpeed);
        transform.position = newPos;

        cc.Move(moveVec);
    }
}

AssetsSkriptPlaerMufment.cs(36,31): error CS1525: Invalid expression term ‘.’
AssetsSkriptPlaerMufment.cs(36,32): error CS1001: Identifier expected
AssetsSkriptPlaerMufment.cs(36,32): error CS1026: ) expected
AssetsSkriptPlaerMufment.cs(36,34): error CS1003: Syntax error, ‘(‘ expected
AssetsSkriptPlaerMufment.cs(36,34): error CS1525: Invalid expression term ‘)’

Понравилась статья? Поделить с друзьями:
  • Error cs1525 unexpected symbol end of file
  • Error cs1525 invalid expression term unity
  • Error cs1525 invalid expression term string
  • Error cs1525 invalid expression term int
  • Error cs1520 method must have a return type unity