We propose a new Monte-Carlo method for calculation of the Casimir forces. Our method is based on the formalism of noncompact lattice quantum electrodynamics. This approach has been tested in the simplest case of two ideal conducting planes. After this the method has been applied to the calculation of the lateral Casimir forces between two ideal conducting rectangular gratings. We compare our calculations with the results of PFA and "Optimal" PFA methods.Comment: 12 pages, 6 figures, accepted in Int. J. Mod. Phys.