I've just taught this in my graduate class.   Check these [notes on intersection theory.][1]


The result you want is contain in Thm. 4.7.  Again, you need $2\dim S=\dim X$.

  [1]: http://www.nd.edu/~lnicolae/TopicsFall2011-Intersect.pdf