I have a "foreach" function in the code that's supposed to shift all objects by two elements. For some reason no output is given at the end. I have no idea what's the problem.
Here is the source code:
using System;
namespace testy
{
class Program
{
static void Main(string[] args)
{
string[] alphabet = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "R", "S", "T", "U", "W", "Y", "Z" };
string[] lol = {"a", "b", "r", "f", "d", "q", "u"};
int i = 0;
int por = 0;
string[] output = new string[lol.Length];
while(lol.Length == i)
{
while(lol[i] == alphabet[por])
{
por++;
}
output[i + 2] = alphabet[por];
por = 0;
i++;
}
foreach(string lol123 in output)
{
Console.WriteLine(lol123);
}
Console.ReadKey();
}
}
}
while(lol.Length == i)is false (lol.Length == 7, but i==0), so it never enters the loop. Btw, try to use debugger to execute the programm step by step if there are any uncertainties about the code