Skip to content

C# Plus.NET Syntax Keyword

ZZZ Projects edited this page Nov 16, 2015 · 2 revisions

Plus.NET Keyword:

  • Break All
  • Break Outer
  • Check

Break All

Break all loop (do, for, foreach, while) or switch statement.

int result = 0;
for (int x1 = 0; x1 < 10; x1++)
{
    result += x1;
    for (int x2 = 0; x2 < 10; x2++)
    {
        result += x2;
        for (int x3 = 0; x3 < 10; x3++)
        {
            result += x3;
            break outer;
			// break this loop
        }
		// break this loop
    }

    // break this loop
}
return result;

This keyword is very useful in switch statement to break the outer loop or switch statement

Break Outer

Break the current and the first parent for a loop (do, for, foreach, while) or switch statement.

int result = 0;
for (int x1 = 0; x1 < 10; x1++)
{
    result += x1;
    for (int x2 = 0; x2 < 10; x2++)
    {
        result += x2;
        for (int x3 = 0; x3 < 10; x3++)
        {
            result += x3;
            break outer;
			// break this loop
        }
		// break this loop
    }

    // doesn't break this loop
}
return result;

This keyword is very useful in switch statement to break the outer loop or switch statement

Check

Checks whether the reference is null and then switches the control flow just like an 'if' statement.

Roslyn Request: https://github.com/dotnet/roslyn/issues/227

Customer customer = Customer.TryLoadFromDatabase(id)

check (customer)
{
    // executed if the object is not null
    customer.DoUpdate = true;
}
else
{
    // executed if the object is null
    customer = new Customer();
}