Hi guys, I made a code that translate strings to match each word from the array 0ne to the array two and its showing the right results. But how to let the compiler take the number in the string and print it out as it is, ummmm see the code i wrote
class Program
{
public static string[] E = { "i", "go", "school", "to", "at" };
public static string[] A = { "Je", "vais", "ecole", "a", "a" };
public static string Translate(string s)
{
string str = "";
Regex Expression = new Regex(@"[a-zA-Z]+");
MatchCollection M = Expression.Matches(s);
foreach (Match x in M)
str = str + " " + TranslateWord(x.ToString());
return str;
}
public static string TranslateWord(string s)
{
for (int i = 0; i < E.Length; i++)
if (s.ToLower() == E[i].ToLower())
return A[i];
return "Undefined";
}
here I want to enter the the whole string and the code should translate it with the number, now i know how to do the word (by spliting them and translate) but what about the numbers)
static void Main(string[] args)
{
string str = "I go to school at 8";
Console.WriteLine(Translate(str));
}
how to continue ?!