I have a file filled with text and numbers and need to import it into a Tuple<string, int>
array (Tuple<string, int>[] vowels = new Tuple<string, int>[81]
). The file looks something like this
a,2,e,6,i,3,o,8,u,2,y,5
The current method I use initially imports it into a string array using
string[] vowelsin = File.ReadAllText("path.txt").Split(',');
After importing, I turn the data into Tuples using
for (int x = 0; x < 81; x++)
vowels[x] = Tuple.Create(vowelin[x*2], int.Parse(vowelin[(x*2) + 1]));
While it works, it's a bit hard to read and during tests, takes around 100ms to complete. Are there any potential one-liners, faster methods, or more readable methods that could pull off the same thing?