I have four point p0 , p1 ,p1′ , p2′ , each defined by x,y,z component and all lay on one line as in the figure

I want to get the line segment (the dashed part) result from the intersection between the four points
any suggestion , or sample code using C#
This is more or less the same answer as Howard gave but pressed into C# … I hope this helps with your code-base.
This code snippet should do the trick (finding the mid-points from your 4, but only if all are colinear) – also note I don’t check for real intersection, you can do this easily youself by inspecting the answer and your points.
I did not take the time and implement the Vector3D struct in a sensible manner (operators, …) – you can do this easily too.
Also note that this will work for not only 4 points but keep your diagram in mind.