Section 23. The party who produces a witness shall not impeach his credit by evidence of bad character, but may contradict him by other evidence, and may also prove that he has made at other times statements inconsistent with his present testimony; but before proof of such inconsistent statements is given, the circumstances thereof sufficient to designate the particular occasion shall be mentioned to the witness, and he shall be asked if he has made such statements, and, if so, shall be allowed to explain them.