Dramatic irony is when a character is unaware of some truth and acts under some other assumption; usually the spectator knows what this truth is. In Act One, Scene One, Horatio and Bernardo believe that Old King Hamlet's ghost is stalking the grounds because Fortinbras is assembling an army to take back the land Old King Hamlet won from his father in battle. (This is the reason Horatio and Bernardo are standing guard.) The audience is not immediately aware that the ghost is there to encourage Hamlet to avenge him; not to participate in the upcoming war. But the audience eventually discovers this with Hamlet and before the characters: Horatio and Bernardo. Bernardo is confident that the presence of the king's ghost has to do with war:
I think it be no other but e'en so.
Well may it sort that this portentous figure
Come armed through our watch, so like the King
That was and is the question of these wars. (I.i.122-25)
In Act One, Scene Five, the ghost tells Hamlet he wants him to avenge his death. Hamlet does not divulge this information to Horatio, Marcellus, and Bernardo. Only the audience and Hamlet are aware of what the ghost said to him. This becomes a running theme in Hamlet. No one is really sure why Hamlet acts the way he does. The audience knows that Hamlet is basically faking madness as a part of his revenge strategy. The other characters don't really know this and that's another example of dramatic irony.