BPM variable scope

You are re-declaring your variables (locally) inside the code block. If you look at it from outside your current code looks like this

DateTime today;

void CodeBlock()
{
          DateTime today=DateTime.Today; // Re-declares the variable as a local variable that only has scope inside this code block
}

Console.WriteLine(today); // Today is still null here, because you haven't assigned any value to it.

You should not re-declare it inside the code block. Just assign it a value

void CodeBlock()
{
 today=DateTime.Today; 
}
4 Likes