ITextSnapshot snapshot = textBuffer.CurrentSnapshot; string content = snapshot.GetText();
ITextSnapshot oldSnapshot = e.OldSnapshot; ITextSnapshot newSnapshot = e.NewSnapshot; if(oldSnapshot.Version.VersionNumber < newSnapshot.Version.VersionNumber){ // Do something if the new snapshot is more recent }This example code compares two text snapshots from a text buffer to determine if the new snapshot is more recent than the old snapshot. It is using the ITextSnapshotVersion interface to get the version number of each snapshot. Overall, ITextSnapshot is a useful tool for working with text documents in Visual Studio extensions and can be used for tasks such as retrieving the contents of a document and comparing different versions of it.