Steve has the right answer. There is much more to it than just the length of the bar.
To select the correct chain you need to know the following.
First is the pitch. That is the distance between the pins on the drive links. Common ones are 325 and 3/8, but there are others.
Next you need to know the gauge. This is the width of the groove in your bar that the links ride in. Again common ones are .050 and .058.
Next is the number of drive links. This of course varies from saw to saw according to the pitch and the length of the bar.
Most bars have this information stamped into the steel of the bar. You may have to do some cleaning to find it. It’s generally up by the base of the bar where the bar connects to the machine. Sometimes you even have to remove the bar to find it.
I believe Stihl brand chains used to use a coded number stamped on the chain itself that showed both the gage and the drive links. I’m not sure if they still do this but it was possible to read the information directly off the chain. The problem was you needed a little conversion table to convert these numbers into an actual pitch and gauge measurement.
Hopefully all this information is stamped on the bar and you can be back in business quickly.
Grouse