using System;
public class Test
{
public static void Main()
{
string reply;
Console.WriteLine("Hi");
Console.ReadLine.ToUpper();
if(reply=="BYE")
{Console.WriteLine("bye");}
}
I was trying to mimic the code I found on youtube for a text adventure, but then I get this error called Compiler error saying «prog.cs(14,1): error CS1525: Unexpected symbol `end-of-file'» Anyone know the reason why it’s saying this?
asked Dec 9, 2014 at 2:02
4
Try adding another curly brace at the bottom (you didn’t fully close out the public class Test
using System;
public class Test
{
public static void Main()
{
string reply;
Console.WriteLine("Hi");
Console.ReadLine.ToUpper();
if(reply=="BYE")
{Console.WriteLine("bye");}
}
} //Added Curly Brace
answered Dec 9, 2014 at 2:06
mwilsonmwilson
11.9k6 gold badges53 silver badges91 bronze badges
1
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"); } }
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 |
using System; using System.Drawing.Drawing2D; using System.Drawing; using System.IO; using System.IO.Pipes; using System.Runtime.InteropServices; using System.Text; using System.Windows.Forms; namespace CyberWinFormTest { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Click(object sender, EventArgs e) { Graphics graph = CreateGraphics(); graph.Clear(Color.White); graph.MultiplyTransform(new Matrix(1f, 0f, 0f, -1f, 0f, Height / 2)); graph.DrawFunc(Pens.Black, x => (float)Math.Log(x / 100) * 100, 100f, 1000f, 10f); } } public static class DrawerExtension { /// <summary> /// Рисует график на основании функции. /// </summary> /// <param name="graph">График для рисования.</param> /// <param name="pen">Структура определяющая цвет, ширину линии.</param> /// <param name="func">Функция на основании которой будет построен график.</param> /// <param name="startX">Начальная Х координата для рисования графика.</param> /// <param name="endX">Конечная Х координата для рисования графика.</param> /// <param name="step">Расстояние между точками, по оси Х.</param> /// <returns>График.</returns> public static Graphics DrawFunc(this Graphics graph, Pen pen, Func<float, float> func, float startX, float endX, float step) { float prevX = startX; float prevY = func(startX); float currentX = currentX = startX + step; float currentY; while(currentX <= endX); { currentX += step; currentY = func(currentX); graph.DrawLine(pen, prevX, prevY, currentX, currentY); prevX = currentX; prevY = currentY; } return graph; } } |
На чтение 3 мин. Просмотров 34 Опубликовано 15.12.2019
Want to improve this question? Update the question so it’s on-topic for Stack Overflow.
Closed 4 years ago .
I have been trying to troubleshoot this error all day I’m pretty sure a closing parenthesis is required at the end of line 10 but other than that i have no clue besides closing the classes which only led to another error. Here’s the code.
Содержание
- -ExTaZi_x3
- Wulf Community Admin
- -ExTaZi_x3
- Wulf Community Admin
- -ExTaZi_x3
- Wulf Community Admin
- -ExTaZi_x3
- Wulf Community Admin
- -ExTaZi_x3
- Wulf Community Admin
-ExTaZi_x3
Hi all, i don’t understand this eror.
I know this plugins work good with others server and i don’t understand for why this eror come only for me :/
Need help
Make sure you downloaded the full file, not a partial. Also make sure nothing was added to it or modified.
-ExTaZi_x3
I’ve dowload the plugin from the official page (EventManager and TeamDeathmatch)
And i have try take my old version of this plugins from a old save (and work well on old server)
-ExTaZi_x3
What can I do to make the plugins compiles correctly?
However, I am about to have to download plugins from the real page and the version is that the developer offers to the community.
His might not be a problem with my server? If so how I could solve this?
Im a old admin from Cataclysme server and i have work on this plugins with him and i have the version of the server Cataclysme and this version work well on server Cataclysme (Remember me im the men with a bad english x) )
-ExTaZi_x3
I upload this version Event Manager for Rust | Ox />
[DOUBLEPOST=1472258463][/DOUBLEPOST]No possible help?
-ExTaZi_x3
Ok sorry, but i use Filezila and i upload the plugins on file plugins. Is not my first serv i have work with Cataclysme (french guy want translate all plugins ^^) And i’ve talked everal time to you with Cataclysme’s account
And i have similarry eror for EventManager and TeamDeathmatch
Im Naked Wanderer only because Cataclysme have change password so i have more 300 Message on ox >
Ok sorry, but i use Filezila and i upload the plugins on file plugins. Is not my first serv i have work with Cataclysme (french guy want translate all plugins ^^) And i’ve talked everal time to you with Cataclysme’s account
And i have similarry eror for EventManager and TeamDeathmatch
Im Naked Wanderer only because Cataclysme have change password so i have more 300 Message on oxide im not a real new ^^
Недопустимый термин «символ» в выражении Invalid expression term ‘character’
Компилятор обнаружил недопустимый символ в выражении. The compiler detected an invalid character in an expression.
Следующий пример приводит к возникновению ошибки CS1525: The following sample generates CS1525:
Пустая метка также может приводить к возникновению ошибки CS1525, как показано в следующем примере: An empty label can also generate CS1525, as in the following sample:
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.
Not sure what to do, also, when I tried a little earlier it worked well adding the minutes, but when I try to quit a bunch of error code appears. This is my code:
using System;
// If you write «using System;» at the top of your code, you no longer have to include the word «System» in your code. Ex: System.Console.Write = Console.Write (If you have «using System;» at the top of the script).
// There are many of these that you can use, and they are used to reduce the amount of typing that you have tp do in the code.
namespace Treehouse.FitnessFrog
// Namespaces are another way for organization in C#.
// Namespaces are used to organize its many classes.
// You can have as many Namespaces as you want, just put dots (.) between each name.
{
class Program
// All code is contained in a class; Class = way of organizing code ; Everything in curly brace is part of class; Program can have any number of classes; Classes are usually contained in their own file - Tell them apart by naming them. // To Compile, type "mcs Program.cs" in console. // To Run, type "mono Program.exe" in console. // The right most word is the name of the method, left of that is the name of the class, and everything that remains to the left of that is the namespace. // REPL | Stands for READ, EVALUATE, PRINT, LOOP. // One "=" sign means equals, but two, "==", is known as an equality operator. If the left = the right, it evaluates to true, if not, it evaluates to false. // *WHAT PARAMETERS ARE* Parameter Example: void SendMessage(string message, string recipient) | The parameters are the "string message, string recipient" part of the method. // Example of identifying parameters // Void SendMessage(string message, string recipient) | Question: Type of the first parameter | Answer: string // Void SendMessage(string message, string recipient) | Question: Name of the method | Answer: SendMessage // Void SendMessage(string message, string recipient) | Question: Name of the second parameter | Answer: recipient
{
// Static keyword allows the method to be called without instantiating an instance of the class.
// Classes often have multiple Methods instead of them; Class can have any other of Methods; Methods are used to further organize code into smaller chunks.
// Method named Main is what runs first | One method has to be named Main, others can be named whatever you want.
// Method has four parts; Method has name Ex: «Main»; All the code for the program will be written inside of the Method; Method can use other Methods, known as «calling a Method»; Third part of Method is perameters, put inside the parenthesis.
// The word void means it will not return anything to another method.
// The Four P’s of Problem Solving are: Prepare, Plan, Perform and Perfect.
// Prepare = This is where we understand and diagnose the problem. | Plan = This is where we organize everything before acting. | Perform = We simply put the plan into action. | Perfect = Check to see if creation has solved problem, and how to make better. Use 4 P’s again to improve.
static void Main() { // This is a new variable that will store the running total and initialize it to 0. // Int is the name of the type that can store numbers. | Int = Integer // No need for quotation marks, as it is not a string. (Number is 0, instead of "0"). // Integers are whole numbers ONLY, NO DECIMALS OR QUOTATIONS. int runningTotal = 0; // In math, a boolean (bool) is something that can be either true or false. // Just like STRING can ONLY STORE TEXT, and INT can ONLY STORE INTEGERS, BOOLEAN can ONLY STORE the value of: TRUE or FALSE. // If we NEVER change the value of keepGoing, the loop will run FOREVER, therefore, the program will run forever until it is forced to stop. bool keepGoing = true; // Below is a while loop, this is the most simple type of loop. // A while loop has two parts. // The first part is everything between its curly braces is the body, everything in the body is what we want to be looped/repeated. // The second part is the condition, everything between the parenthesis. This is the part that determines if the loop should run/repeat. If it's true, it'll repeat; if it's false, it'll skip over it. // Before the program will enter the loop, it will check the value of the bool "keepGoing", and it will skip it or execute it, depending on if it's true or false. while (keepGoing) { // Prompt the user for minutes exercised // Needs additional information in order to run, info will be in parenthesis. This method needs to know what we want to print to the screen, which will be listed in the parenthesis. // Make sure to write the text in double quotes, also known as a string. // Make sure to END ALL LINES WITH A SEMI-COLON. // The double slashes are there so that the quotations around "quit", can be there and not end the line of code. Console.Write("Enter how many minutes you exercised or type "quit" to exit: "); // Way to get the user to respond, and get their response to the console. | This tells the console to allow the user to enter the response. | Known as "reading from the console" // When this method is called, the console will read what the user types in until they hit the "ENTER"/"RETURN" key on the keyboard. // To assign "System.Console.ReadLine" to the entry variable, set them equal to each other. // This means that the string returned from this method will be stored in the entry variable. string entry = Console.ReadLine(); // The difference between an if statement and a while loop, is that If statements DO NOT LOOP. // When the program gets to an if statement, it checks the condition. If the condition evaluates to true, then the code in the body of the "if" will get executed. If the condition evaluates to false, it skips past the body of the if. if (entry == "quit") { keepGoing = false; } else { // Stores the converted integer into a new variable called "minutes". // You can add minutes to running total and then assigns the results back into running total. (It adds running total and minutes, and both of them become the runningTotal.). int minutes = int.Parse(entry); runningTotal = runningTotal + minutes; // Saving what the user enters into a variable so that it can be used later. | A variable is a way to temporarily store information that the code can use. | Variables can be created by first saying what type of information is needed to store. // In the example below, the variable type is "string", and the variable needs a name, names can have letters, numbers, or an underscore character, but cannot start with a number. Name should be descriptive of what it's meant to store. // In the example below, the name of the variable is meant to store the person's first name, so the variable name is "firstName". Then, we initialized the "firstName" to "Ryan". // Things on both sides of the equal sign must be the same type, in the example below, they're both strings. // The WriteLine method only writes a whole line to the console, just like typing a line to the console, then pressing "ENTER" at the end to move the cursor down to the next line. // Everything printed on the "WriteLine" method, will be printed on its own line. // All of the Console.Write code lines below can be compiled into one line, written as " Console.WriteLine("You've entered " + entry + " minutes"); " As shown below. // Console.Write("You've entered"); // Console.Write(entry); // Console.WriteLine(" minutes"); // The plus sign is used to stick one string to another, known as string concatenation, or concatenating strings. // The plus sign is known as the concatenation operator. Console.WriteLine("You've worked out for " + runningTotal + " minute(s)"); // Below are the coding challenges, may be good to refer to. // "Declare a string variable named bookTitle. - Don’t assign it anything." | Answer: string bookTitle; // "Initialize bookTitle with the title of your favorite book." | Answer: string bookTitle = "Book Name"; // "Use the System.Console.Write() method to print "Enter a book title: " to the console." | Answer: System.Console.Write("Enter a book title: "); // "Use the System.Console.ReadLine method to read the user’s response from the console and store it in a variable named bookTitle." | Answer: string bookTitle = "Whip" + System.Console.Write("Enter a book title: "); + bookTitle = System.Console.ReadLine(); //string firstName = "Ryan"; // Add minutes excerised to total // Display total minutes exercised to the screen // Repeat program until the user quits } } Console.WriteLine("Goodbye!"); } }
1 Answer
okay, sorry, I never knew how it was done! I just decided to go ahead and take the knowledge I learned to begin a course I bought from Udemy a while back, thanks guys!
Вам не хватает закрывающего паратеза:
if (String.Contains("y")) //<---missing extra )
У вас есть лишняя скобка:
int question1;
{ //<----what's that doing there?
Console.WriteLine("LOOOOOL");
Переформатированный код должен выглядеть так:
using System;
public class LOOOOOL
{
public static void Main(String [] args)
{
int enterInfo;
int question1;
Console.WriteLine("LOOOOOL");
enterInfo = Console.ReadLine();
Console.WriteLine(enterInfo);
question1 = Console.WriteLine("Is that what you wrote ???");
if (String.Contains("y"))
{
Console.WriteLine("So that's cool, right ???");
}
else
{
Console.WriteLine("Can you re-write it please ???");
question1 = Console.ReadLine();
Console.WriteLine(question1);
}
}
}
Кроме того, ваши переменные int… никогда будут содержать «y»…. возможно, вы захотите изменить эти два на строки
Также… String.Contains()… какую строку вы проверяете? Есть на что посмотреть
Возможно, enterInfo.Contains(«y») может быть вам полезен.