In this work, the dopant contrast in SEM image between the p-type and n-type areas in the semiconductor device is studied by using a Monte Carlo simulation method. The work function induced by the surface state is considered to be responsible for the dopant contrast. A layer-by-layer structure, i.e., three p-type layers with different concentrations and one n-type layer, each of them is separated by a undoped intrinsic Si layer, has been simulated to compare with the experimental observation. The simulated image shows clearly a dopant contrast between the layers and the undopted Si substrate.