System.Collections.Stack.Pop C# (CSharp) Méthode

Pop() public méthode

public Pop ( ) : object
Résultat object
        public virtual object Pop() { throw null; }
        public virtual void Push(object obj) { }

Same methods

Stack::Pop ( ) : Object

Usage Example

Exemple #1
1
        private static void Main()
        {
            string inputSentence = SampleSentence;
            string splitPattern = @"(\s+|\s*\,\s*|\s*\-\s*|\s*\!|\s*\.)";
            string[] elements = Regex.Split(inputSentence, splitPattern);

            Stack words = new Stack();
            Queue separators = new Queue();
            StringBuilder result = new StringBuilder();

            foreach (var element in elements)
            {
                if (Regex.IsMatch(element, splitPattern))
                {
                    separators.Enqueue(element);
                }
                else if (Regex.IsMatch(element, @"\S"))
                {
                    words.Push(element);
                }
            }

            while (words.Count > 0)
            {
                result.Append(words.Pop());
                result.Append(separators.Dequeue());
            }

            Console.WriteLine(result);
        }
All Usage Examples Of System.Collections.Stack::Pop