I have the following code in C# and I get an error when I want to print the variable where I accumulate my result. I have the same for visual basic but in this it did not generate any inconvenience
namespace Fibonacci_CS
{
class Program
{
static void Main(string[] args)
{
UInt32 primero, segundo, resultado;
primero = 1;
segundo = 0;
for (int x = 1; x <= 20; x++)
resultado = primero + segundo;
Console.WriteLine(resultado);
segundo = primero;
primero = resultado;
}
}
}
Remember that in
C#
the braces they{}
define the block of the instruction, if you don't define any, it will only take the next line.Maybe what you are looking for is the following
You will see how it is framed
for
with the lines that it must include