I'm reviewing some code on the project I recently joined, and in a C# Win Forms Application for .NET 3.5 I found this:
public void foo()
{
//Normal code for function foo.
//This is at the end and it is left-indented just as I put it here.
EndPoint:
{
}
}
When I click "EndPoint/Go To Definition" it says "Cannot Navigate to Endpoint" but the project as a whole is pretty small and compiles/runs without error, so it's not a missing reference or anything.
What is EndPoint and what is this syntax with the name : {}?
goto
! – Kissgoto
can actually be useful but there needs to be strong cause to use it. The braces are not required for a goto-statement and, I assume, were just placed there for readability. – Smarm{}
are there to prevent a compiler error. If your remove them, the next statement is}
, and the C# compiler doesn't like that. It spit out the following errors in my test class:Only assignment, call, increment, decrement, and new object expressions can be used as a statement
,Invalid expression term '}'
, and; expected
. (Note, the code compiled fine until I removed the{}
after the label). – Biblical