private static string PostfixFromConsole() { Console.WriteLine("Enter your infix expression separating each line by enter. To finish your expression press enter after an empty line."); var expr = new List <string>(); var input = Console.ReadLine(); expr.Add(input); while (!string.IsNullOrWhiteSpace(input)) { input = Console.ReadLine(); expr.Add(input); } var postfix = ""; foreach (var line in expr) { if (!string.IsNullOrWhiteSpace(line)) { var p = ReversePolishNotation.ConvertFromInfix(line); postfix += p; if (!string.IsNullOrWhiteSpace(p)) { postfix += Constants.NewLine; } } } return(postfix); }
private static string PostfixFromFile(string infix) { var postfix = ""; foreach (var line in infix.Split(new[] { Constants.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { if (!string.IsNullOrWhiteSpace(line)) { var p = ReversePolishNotation.ConvertFromInfix(line); postfix += p; if (!string.IsNullOrWhiteSpace(p)) { postfix += Constants.NewLine; } } } return(postfix); }