1. A dimension measuring method for measuring a pattern formed on a sample in accordance with detection of electrons obtained by scanning the sample with an electron beam, said dimension measuring method comprising steps of: setting a two-dimenstional partial domain including two edge portions of said pattern within scanning range of said electron beam; obtaining a plurality of images with different focus conditions by changing focus of said electron beam; evaluating the plurality of images with different focus conditions in accordance with a sharpness degree of said two-dimensional partial domain; and measuring dimension between two edges of one of the images with the highest sharpness degree.