Field due to an infinitely long straight uniformly charged wire
Consider an infinitely long thin straight wire with uniform linear charge density λ. The direction of electric field at every point must be radial (outward if λ > 0, inward if λ < 0).
Consider a pair of line elements P1 and P2 of the wire, as shown. The electric fields produced by the two elements of the pair when summed give a resultant electric field which is radial (the components normal to the radial vector cancel).
To calculate the field, imagine a cylindrical Gaussian surface, as shown in the Fig. Since the field is everywhere radial, flux through the two ends of the cylindrical Gaussian surface is zero.
At the cylindrical part of the surface, E is normal to the surface at every point, and its magnitude is constant, s ince it depends only on r.
The surface area of the curved part is 2Πrl, where l is the length of the cylinder.