Shares of railroad companies were moving higher Wednesday afternoon, led by CSX ( CSX), which reported higher-than-expected first-quarter earnings late Tuesday.

CSX said Tuesday its first-quarter profit fell 30% from a year earlier, but the results easily beat Wall Street's expectations as cheaper fuel and lower costs balanced offset slackened demand.

Jacksonville, Fla.-based CSX reported EPS of 62 cents on $2.25 billion of revenue, beating analysts' estimates, which averaged 51 cents.

Stifel Nicolaus analyst John G. Larkin said "the company posted a very solid operating ratio in the first quarter in spite of the challenging operating environment."

He credited the company's ability to raise shipping prices and keep costs tight.

"The company's balance sheet appears strong enough to weather even a protracted economic downturn," he added.

Elsewhere, Kansas City Southern ( KSU) shares were up 6.9% to $16.18.

Union Pacific ( UNP) shares were higher by 0.7% to $46.51.

Canadian National Railway ( CNI) shares were up 2.5% to $40.66.

Norfolk Southern ( NSC) shares were up 1.3% to $36.92.

Canadian Pacific ( CP) shares were up 1.8% to $32.35.

More from Investing

Trump's 'Space Force' Could Launch a $1 Trillion Industry, Morgan Stanley Says

Trump's 'Space Force' Could Launch a $1 Trillion Industry, Morgan Stanley Says

Abiomed Stock Should Rise Some 12% From Here, Piper Jaffray Analyst Says

Abiomed Stock Should Rise Some 12% From Here, Piper Jaffray Analyst Says

Video: Here Is Why Carvana Isn't Worried About Amazon

Video: Here Is Why Carvana Isn't Worried About Amazon

Video: What Oprah's Content Partnership With Apple Means for the Rest of Tech

Video: What Oprah's Content Partnership With Apple Means for the Rest of Tech

REPLAY: Jim Cramer on the Markets, Oil, Starbucks, Tesla, Okta and Red Hat

REPLAY: Jim Cramer on the Markets, Oil, Starbucks, Tesla, Okta and Red Hat