Click here to Skip to main content
15,887,861 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i would like to know what is the answer for this question

which code shall be used if you want to use implement undo functionality,which allows only string?

A)
Objective-C
Stack udQ = gcnew Stack();

B)
Objective-C
Queue<string> udQ = gcnew Queue<string>();

C)
Objective-C
Stack<string> udQ = gcnew Stack<string>();

D)
Objective-C
Queue udQ = gcnew Queue();



Thanks

What I have tried:

searched mostly but not getting clear idea
Posted
Updated 8-Jun-16 20:02pm
v3

C# Stack Type would be handy here, undo is nothing but it would return the last event in an Array.
stack is LIFO (last in first out) so I will go with stack for undo. Stack is always be useful than list in chronological ordering aspect
the ans is
Stack<string> udQ = gcnew Stack<string>();
here is simple undo sample code
C#
Stack<Action> undoStack = new Stack<Action>();    

void ChangeColor(Color color)
{
    var original = this.Object.Color;
    undoStack.Push(() => this.Object.Color = original);
    this.Object.Color = color;
}
 
Share this answer
 
v3
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
It's pretty obvious, if you think about it carefully...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900