I really don’t know what is going on. It worked the first time, then when I try to do the second time it fails
I already checked spelling and found nothing. I am lost without help
I pointed out with a //comment the error line 🙂
Just in case my code is not self-explanatory, I want to get the second digit using the [1] selector
My code is:
static void Main(string[] args)
{
españolizar("55","44");
}
static void españolizar(string str, string str2)
{
string[] list1={"cero","un","dos","tres","cuatro","cinco","seis","siete","ocho","nueve","diez","once","doce","trece","catorce","quince"};
string[] list2={"nivelarindexes","dieci","veinti","trei","cuare","cincue","sese","sete","oche","nove"};
int numero = int.Parse(str);
string strNumero = Convert.ToString(numero);
int primerDigito = int.Parse(Convert.ToString(strNumero[0]));
int segundoDigito = 0;
if (strNumero.Length > 1)
//this is the one that fails
segundoDigito = int.Parse(Convert.ToString(strNumero[1]));
//\-------------------------/
}
Console.WriteLine(strNumero);
Console.ReadLine();
}
You forgot to open braces.