There are three kinds of irony, generally referred to as verbal, situational, and dramatic.
Verbal irony is defined as "ironic statements" with typically "a meaning in opposition to their literal meaning." Situational irony is defined as actions taken that "have an effect exactly opposite from what was intended."
Dramatic irony, on the other hand, is not something that requires close observation to identify, nor is it the unexpected result of a person's actions. The author specifically orchestrates it so that the audience is quite aware that his/her character is acting without knowledge that the audience has: we see the error; they don't. It is present when...
...the author causes a character to speak or act erroneously, out of ignorance of some portion of the truth of which the audience is aware.
The purpose of dramatic irony is tied to the theme or themes the author is trying to convey to the audience. The action of the character speaks specifically to that "life truth" by saying or doing something counter that truth.
For example, in Shakespeare's Julius Caesar, Mark Antony meets Brutus and the other assassins after they have killed Caesar. Antony pretends to be in agreement with what these men have done. Because of his pretense (and against Cassius' advice), Brutus agrees to let Antony speak at Caesar's funeral. After the assassins have left, Antony promises to avenge Caesar's death.
And Caesar's spirit ranging for revenge...
Shall in these confines with a monarch's voice
Cry “Havoc!” and let slip the dogs of war,
That this foul deed shall smell above the earth
With carrion men, groaning for burial. (III.i.290, 292-295)
The reader...the audience...knows that Antony yearns to avenge Caesar's death. With this knowledge, then, Antony is allowed to address the audience at Caesar's funeral—an audience that until this time supported Brutus' actions against Caesar for the good of Rome. Before Antony is done however, with his gift for rhetoric, he turns the audience against Brutus and his compatriots, and sends Rome into civil war.
When Brutus allows Antony to address the crowds after he is done speaking, there is dramatic irony: the audience knows that Antony is opposed to the actions of these men, though Brutus does not. Brutus sets himself up by believing Antony's words of assurance that he supported the assassination, but lets the audience know (after the others have left) that he intends to bring dissention and war to Rome against what he perceives as a crime.
(Ironically, Antony will plan to do exactly the same thing later to Octavius—one of the triumvirate with Antony—to unseat him so that Antony will have all the power. The difference is that Brutus took action for the good of Rome. Antony takes action only for himself.)