In this work, the corrosion inhibition effects of octadecyl trimethyl ammonium chloride (OTAC) and dioctadecyl dimethyl ammonium chloride (DDAC) on Q235 steel in a 0.5 mol/L H2SO4 solution are studied. The results of the electrochemical experiment, contact angle measurement, and scanning electron microscopy indicate that the two ionic liquids belong to mixed-type corrosion inhibitors with good anti-corrosion performance. Additionally, OTAC has a better anti-corrosion ability than DDAC, implying that the steric hindrance effect of the double alkyl chain is not conducive to the adsorption of DDAC on the electrode surface.