jeudi 29 octobre 2020

Cannot implictly convert type "int" to "bool"

using System;

namespace Codes
{
    class Program
    {
        static void Main(string[] args)
        {
            String name = RandomNames();
            Console.Write(name);
            Console.ReadKey();
        }

        public static string RandomNames()
        {
            Random numGen = new Random();
            string vowel = "aeiou";
            string conso = "bcdfghjklmnpqrstvwxyz";
            int nameLen = numGen.Next(4,10);

            string result = "";
            for (int i = 0; i < nameLen; i++) 
            {
                if (i % 2) 
                {
                    result += vowel[numGen.Next(0, 4)]; // 4 is final index of vowel.
                } 
                else 
                {
                    result += conso[numGen.Next(0, 20)]; // 20 is final index of consonants.
                }
            }
            return result;
        }
    }

it says the "i" in if statement cannot implictly convert type "int" to "bool" and I don't know whats the problem with that because it's already an int in for loop

Aucun commentaire:

Enregistrer un commentaire