 When the Civil War began, Hayes served in the Confederate army along with 247 VMI cadets who fought at the Battle of New Market.After the end of the Civil War, he came to Baltimore but soon returned to Virginia where he graduated in 1867 and started as an assistant professor of mathematics.Hayes later moved to the Kentucky Military Institute, near Frankfort, where her served as a professor of natural sciences.