What I'm trying to do is to allow the user to search how many false or true values are saved in a bool Vektor It's also important that the program should handle input errors.
I guess I have to use Convert.Boolean but I don't know how. At the moment I'm keep getting the same thing whether I search numbers or letter.
static void Main(string[] args)
{
Random newRandom = new Random();
int slumpTal = newRandom.Next(1, 101);
bool[] boolVektor = new bool[slumpTal];
//var nacas = Convert.ToBoolean(Convert.ToInt32("0"));
for (int i = 0; i < boolVektor.Length; i++)
{
int slump = newRandom.Next(0, 2);
if (slump == 0)
boolVektor[i] = true;
else
boolVektor[i] = false;
}
{
Console.Write("Skriv in sökOrd: ");
string searchWord = Console.ReadLine();
bool search = false;
for (int i = 0; i < boolVektor.Length; i++)
{
if (boolVektor[i] == search)
{
Console.WriteLine("The following were found: " + boolVektor[i]);
search = true;
}
if (!search)
{
Console.WriteLine("Your search failed");
}
}
Console.ReadLine();
}
}