The county legislative bodies have the power, and it is their duty, through an agent or proxy, to vote the stock of the county in any railroad, in all elections of officers and directors in such railroad.