There is a code in which data is entered from the keyboard. How to change the code to enter data from a file?
using System; using System.Collections; using System.Text.RegularExpressions; class Program { public static void PrintValues(IEnumerable myCollection) { foreach (Object obj in myCollection) Console.Write("{0}", obj); Console.ReadLine(); } static void Main(string[] args) { Object qwer2; Stack stk = new Stack(); string term, qwer1, a1, a2, a3; Console.WriteLine("Write term in OPN: "); term = Console.ReadLine(); string[] split = term.Split(new Char[] { ' ' }); foreach (string s in split) { if (s.Trim() != "") { Regex rgx = new Regex("[A-Za-z0-9]"); foreach (char str in s) if (rgx.IsMatch(s)) stk.Push(s); else { if (s == "+" || s == "-") { qwer2 = stk.Pop(); a3 = qwer2.ToString(); a2 = s.ToString(); qwer2 = stk.Pop(); a1 = qwer2.ToString(); qwer1 = string.Concat("(" + a1 + a2 + a3 + ")"); stk.Push(qwer1); } else { qwer2 = stk.Pop(); a3 = qwer2.ToString(); a2 = s.ToString(); qwer2 = stk.Pop(); a1 = qwer2.ToString(); qwer1 = string.Concat(a1 + a2 + a3); stk.Push(qwer1); } } } } PrintValues(stk); } }