Note that there are some explanatory texts on larger screens.

plurals
  1. PORazor is removing curly brace on second if statement
    primarykey
    data
    text
    <p>I am getting a really strange error when i try to run my C# app locally. I am new to web development in c# so i may be missing something simple. I have searched for a while and found some very similar questions, but I could not find anyone with this error for the same reason.</p> <p>At the top of my cshtml file that is causing the error i have this code:</p> <p>My Code: </p> <pre><code>@{ var addr = ViewBag.Address; if (addr == null) { throw new InvalidOperationException("Address is null"); } string addrString = @addr.Street + " " + @addr.City + ", " + @addr.State + " " + @addr.Postal + " " + @addr.Country; addrString = addrString.Trim(); int lastSpot = addrString.Length - 1; if (addrString[lastSpot] == ',') { addrString = addrString.Remove(lastSpot); } } </code></pre> <p>When i run it i get this error. If i remove the second if statement the error goes away Error:</p> <p>Compiler Error Message: CS1513: } expected</p> <p>Source Error:</p> <pre><code>Line 619: } Line 620: } Line 621:} </code></pre> <p>When I look in the file generated by Razor i see this: Notice the second closing brace has been taken out:</p> <pre><code>Line 55: if (addrString[lastSpot] == ',') Line 56: { Line 57: addrString = addrString.Remove(lastSpot); Line 58: Line 59: Line 60: #line default Line 61: #line hidden Line 62: BeginContext("~/Views/Home/ResolveAddress.cshtml", 438, 268, true); </code></pre> <p>I have no clue why the second brace is not being recognized and any suggestions would be great. Also, my cshtml file is only 208 lines long.</p> <p>Thanks alot!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload