I used this website: https://www.codeconvert.ai/php-to-csharp-converter
to convert a piece of php code into:
using System;
using System.Collections.Generic;
namespace CodeTranslation
{
class Program
{
static void Main(string[] args)
{
int length = 5;
List<string> values = new List<string>();
for (int i = 0; i < Math.Pow(2, length); i++)
{
values.Add(string.Format("{0:" + new string('0', length) + "}", Convert.ToString(i, 2)) + "<br>");
}
List<List<string>> pool = new List<List<string>>();
for (int i = 0; i <= length; i++)
{
pool.Add(new List<string>());
}
List<string> final = new List<string>();
foreach (string value in values)
{
int count = value.Split('1').Length - 1;
pool[count].Add(value);
}
List<string> result = CalculateResult(pool);
Console.WriteLine(string.Join("<br>", result));
}
static List<string> CalculateResult(List<List<string>> pool)
{
string start = "";
int a = 0;
int b = 1;
List<string> result = new List<string>();
while (result.Count != Math.Pow(2, 5))
{
List<string> poolA = pool[a];
List<string> poolB = pool[b];
if (poolA.Count == 0)
{
a++;
b++;
}
string stringA;
if (string.IsNullOrEmpty(start))
{
stringA = poolA[0];
poolA.RemoveAt(0);
}
else
{
stringA = result[result.Count - 1];
result.RemoveAt(result.Count - 1);
result.Insert(0, stringA);
But then at line 40. which is this one:
List<string> poolB = pool[b];
it comes up with the message like in the title.
I have read the other stackof threads but I don't know how to exactly resolve this still.
- also: why does it say that about poolB but not reg. poolA?