public static void TransmitData()
        {
            var initialCount = ObjectStack.Count;

            Console.WriteLine("Initial Stack Contents Count {0}", initialCount);
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(Environment.NewLine);
            try
            {
                for (var i = 0; i < initialCount; i++)
                {
                    //Simulating an Exception
                    if (i == 4)
                    {
                        throw new IndexOutOfRangeException();
                    }
                    Console.WriteLine("Initial Value {0} at position {1}", ObjectStack.Peek(), i);
                    PushIntoBackUpStack(ObjectStack.Pop());
                }
            }
            catch (IndexOutOfRangeException exception)
            {
                Console.WriteLine(exception);
                OnExceptionRestoreStack();
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                OnExceptionRestoreStack();
            }
            finally
            {
                Console.WriteLine("Count: {0}", ObjectStack.Count);
            }
        }
 private bool IsObjectSameAsPreviousObject(ISerializable obj)
 {
     return(ObjectStack.Count != 0 && ReferenceEquals(obj, ObjectStack.Peek()));
 }