If a body is assumed to be continuous, one can use the technique of integration to obtain its moment of inertia about a given line.
Consider a small element of the body. The element should be chosen such that, the perpendicular from different points of the element to the given line differ only by infinitesimal amounts. Let its mass be 'dm' and its perpendicular distance from the given line be 'r'. If we evaluate the product r2dm and integrate it over the appropriate limits to cover the whole body, then