In the appendix of Algebaric Geometry by Hartshorne, he showshows us that how Serre definedefines the intersection numberintersection number in a more general case:$i(X,Y;Z)=\sum{(-1)^i*(lengthTor^A_i(A/a,A/b))}$,$$i(X,Y;Z)=\sum(-1)^i\cdot\bigl(\operatorname{length} \operatorname{Tor}^A_i(A/a,A/b)\bigr),$$
here X,Ywhere $X,Y$ intersect properly, Z$Z$ is an irreducible component, A$A$ is the local ring of generic point of Z$Z$, a and b$a$ and $b$ are the ideals of X, Y$X$ and $Y$ in A$A$. However, when computing a detailed example like that X, such as when $X$ is ana projective variety in $P^n$, Y$\mathbb P^n$ and $Y$ is a complete intersection defined by $f_1,...,f_r$, I find it difficult to write down what the intersection number is. Sincerely hope for a detailed computing method.