/** * This is method is used for print the stack in reverse order * */ private String printPath(Stack <string> stk) { StringBuilder sb = new StringBuilder(); //sb.Append( String.Format("{0,-260}", stk.Peek())); sb.Append(stk.Peek() + atTheRateSparator); //Console.Write(stk.Peek() + "\t\t"); //from the top to bottom for (int i = stk.Count - 1; i >= 0; i--) { //Console.Write(stk.ElementAt(i) + ":"); if (!string.IsNullOrEmpty(stk.ElementAt(i))) { sb.Append(stk.ElementAt(i) + colonSparator); } } sb.Remove(sb.Length - 1, 1); sb.Append(newlineSparator); Console.Write(sb.ToString()); return(sb.ToString()); }