On the SPFile object there is a method called UndoCheckOut(). This discards the checkout and returns the file or publishing page back to its original state.
To discard the checkout of a publishing page do this:
publishingPage.ListItem.File.UndoCheckOut();
Comments