Error cs1513 expected что это



Error cs1513 expected что это

Answered by:

Question

This is the last two statements of my coding:>// closing a class statement>//closing a void statement.

No other errors. Message CS1513 three times repeated from csc compiler on the same line coding.

Answers

Error CS1513 shows that t he compiler expected a closing curly brace (>) that was not found.

The following sample generates CS1513:

namespace y // CS1513, no close curly brace

public static void Main()

If you still have any further concern , please post your code, we will try our best to help you to solve this issue.

Lucy Liu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

Источник

Error cs1513 expected что это

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Answered by:

Question

I am just starting university and have begun programming in C#, I have just run into an issue that I am unsure how to fix where compiling states that a > is expected on line 37, but when I fix this, a multitude of errors occur stating that:

A local or parameter named ‘Percentage’ cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter
Cannot convert lambda expression to type ‘bool’ because it is not a delegate type

Below is the area of code that is being changed

Any help regarding this error would be greatly appreciated

Answers

Try casting the values as floats:

All replies

The proper format of if with else if is in the link.

Here is the proper syntax:

You will have to rename the parameter «Percentage» to something like «percentage». The error tells you it is already used.

Let me know if that helps!

You hit an else before you hit a closing bracket here:

Control structures either govern the next block defined by brackets or only the code until the next Semikolon (wich means one line).

Читайте также:  Rpcndr h byte error

Your code put’s the else inside the if block. It is actually a peer of the if.

I guess you are missing closing bracket for if condition and else if condition. And else if end with else condition. Please try below code.

Hope this helps you.

I have tried your suggestions and I am now getting the error that occurred before when I tested it, with the command prompt outputting:

error CS0136: A local or parameter named ‘percentage’ cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter
error CS1660: Cannot convert lambda expression to type ‘bool’ because it is not a delegate type

Throughout the document, adding the curly bracket seems to break the program even worse.

Is this an easier fix or does this make the problem worse?

How can that be without an «else if»?

You can do the else.

I have tried your suggestions and I am now getting the error that occurred before when I tested it, with the command prompt outputting:

error CS0136: A local or parameter named ‘percentage’ cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter
error CS1660: Cannot convert lambda expression to type ‘bool’ because it is not a delegate type

Throughout the document, adding the curly bracket seems to break the program even worse.

Is this an easier fix or does this make the problem worse?

To fix the lambda problem, you must swat the «=>» to «>=» like in my code sample above.

Try renaming the Percentage variable just in the sample code you provided, or change » float Percentage = ( NumberofMarksInt / 70 ) * 100 ; » to » Percentage = ( NumberofMarksInt / 70 ) * 100 ; «. Drop the float in front of it. It was already defined.

That should fix it for you.

A control sturcture — be it an if, else, try, catch, switch, case, for or while — needs a clear definition for wich part of the code it applies. Indenting has no effect. Whitespaces have no effect.
You either define the area with curly brackets or it just takes everything until the next semikolon.

Читайте также:  Echo write error broken pipe

Without the proper braketing (the code you wrote in your OP) the syntax was so broken, the compiler could not even get to the real errors when looking at the code.
It was too broken to even properly find the real errors.

After you fixed the faulty brakets, you can now go deal with the real issues. Namely:

error CS0136: A local or parameter named ‘percentage’ cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter
error CS1660: Cannot convert lambda expression to type ‘bool’ because it is not a delegate type

CS0136 implies you already had a variable of that name defined. Show us the rest of your code, we might be able to spot it.

CS1660 complains about this combination «=>» That is the character combination that starts a lambda expression, not the «>=» (more or equal) sign. And lambdas really don’t belong into a if.

Источник

Error cs1513 expected что это

Answered by:

Question

Not sure why I am getting this error

This code has been in use for over a year, recently changed host and now getting compile error — error CS1513: > expected

Here is the code, which looks balanced for curly braces to me.

It is asking for another closing curly brace at the end.

Is this an issue of Webmatrix1 vs Webmatrix2 ?

Any help please — much appreciated.

Answers

My only thought is that something within the Layout page is causing this to occur.

I tried moving around some of the braces in the Layout page to see if that made any difference at all :

It’s possible that the semicolon issue is coming down from the Layout and the error is only been seen on the child-page level.

All replies

Do you have any other code that might be interferring with this? (The @ symbol can often throw off the curly braces and cause them to «miss» one another)

I tried the following code that you had below and it appeared to work just fine :

Читайте также:  Error invalid conversion from const char to unsigned char fpermissive

Thaks Rion
Yes it goes into another block as follows

The logic is if user is logged in then show their GiftAid status (which can be yes or no) else show the

Do you only need to display the actual

area or all of the code behind it?

Example with just Gift Aid

Example with entire section

(I removed the trailing ‘;’ after your RenderPage call, although I’m not around an environment to test it.)

removed the trailing ; but webmatrix still not happy and want another > at the end of first block of code — it gives line number and column number.

As I mentioned this code has been working for more than a year and now that I changed host this thing has cropped up, probably they have different compiler — Razor 2 ?

Ah you may want to ensure that you have the newest version of WebMatrix 2. (WebMatrix 3 was just released recently, although 2 should be sufficient)

Have you tried removing the Razor code blocks within your if-else blocks to see if that makes any difference at all? (Sometimes they can throw things off a bit) :

I did that and found out that it is the top code between @ < >that is the problem. The error goes away if I remove the top block but stays if I remove the @if block.

I noticed that before as well by the colour that it is not extending to the 2nd > where it should .

Regarding Webmatrix 2, yes I do have that uptodate which I regret because after the update the Webdeploy stopped working and hasn’t worked since despite pestering the hosts many times, and they say it is fine on their end. Therefore I changed the host and landed into more troubles, and webdeploy still dont work.

wasted a lot of time after the update without getting any real advantage.

Источник

Оцените статью
toolgir.ru
Adblock
detector