1

Note: This is more of a question for my understanding.

Today I stumbled upon a structure within C# which I had not seen before. While typing and talking to a colleague, I mistakenly added (curly) brackets within my method body, and only noticed after compiling, and the compiler didn't show me any warnings or errors.

#region Determine if update is newer than current version

{
    var tmpMetaData = JsonConvert.DeserializeObject<JObject>(Path.Combine(plugin.FullName, METADATA_FILE_NAME));
    if (tmpMetaData.GetValue(METADATA_KEY_APP_VER) == metaData.GetValue(METADATA_KEY_APP_VER)) {
        WriteLine("The currently installed version of {0} is identical to the version found in the update pak...");
        WriteLine("This update will be ignored.");
        continue;
    }
}

#endregion

After googling for a while and not finding anything concrete, but some vague information about branching in C#, I gathered that this construct must be one form of branching.

I've seen similar in Java, however that is object initialization.

I cannot access the variable within this block, which further strengthens my theory.

Can anyone confirm my theory, or am I completely mistaken?

SimonC
  • 1,547
  • 1
  • 19
  • 43

0 Answers0