using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ejercicio3
{
class Program
{
enum direcion { arriba = 1, abajo = 3, derecha = 2, izquieda = 4,
abajoDerecha=23, abajoIzquierda=34,arribaDerecha=12,
arribaIzquieda=14, prohibido };
static void Main(string[] args)
{
string num = "";
Console.WriteLine("Escribe la direcion que desees tomar");
num = Console.ReadLine();
string[] array = num.Split(',');
direcion d = (direcion)Int32.Parse(num);
for (int i = 0; i < array.Length; i++)
{
Console.WriteLine("{0}", (direcion)int.Parse(num.Substring(i, 1)));
}
}
}
}
I want to separate what I type by console by ','
I searched and it is done with the method Split
but that way I change it to array
.
What I do not know is how to show this array
now.
I mean I want you to show me the enums
if I enter 1,2,3,4 etc
. I understood how to do it shown by a string
but I do not know with a array
.
I BELIEVE that this fails me;
Console.WriteLine("{0}", (direcion)int.Parse(num.Substring(i, 1)));
This line as I come from java I do not understand it very well.
And already if it is to raise the level and do it with arrays
even less ...
If you can explain how to do it besides clarifying this line that I do not understand I would appreciate it.