Electric field due to infinite line of charge [closed]

In my textbook it derives the electric field due to an infinitely long linear charge using a cylindrical Gaussian surface. However, if I take a finite-length linear charge, and draw the same cylinder, I get the same field. Why does the derivation only work for an infinitely long linear charge?

closed as off-topic by Mitchell, Chris♦, John Rennie, glS, sammy gerbilJan 26 '18 at 0:35

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Homework-like questions should ask about a specific physics concept and show some effort to work through the problem. We want our questions to be useful to the broader community, and to future users. See our meta site for more guidance on how to edit your question to make it better" – John Rennie, glS
If this question can be reworded to fit the rules in the help center, please edit the question.

• The sentence beginning "By symmetry, the magnitude $E$..." is only true for an infinite cylinder, not for a finite one. – Chris Jan 23 '18 at 5:17
• Still like if we apply the same formula on a finite linear charge won't the result be same considering that length of the linear charge and height of the cylinder will cancel each other out? – user180358 Jan 23 '18 at 5:19
• – sammy gerbil Jan 26 '18 at 0:35
• I don't see why this was closed as a "homework-like question", though I agree that it's a duplicate of the one linked by @sammygerbil. – Michael Seifert Jan 26 '18 at 0:47
• @MichaelSeifert More than one reason was given by the 5 of us voted to close the question. Only the majority reason is given to explain why the question has been put on hold. In the event of a tie the last vote cast is the decider. See close vote reason logic when there isnt a majority – sammy gerbil Jan 26 '18 at 1:07

You can't apply Gauss' law in any useful way for a finite line charge, because the electric field isn't normal to the surface of the cylinder, and so $\int\vec E\cdot d\vec A\ne EA$.