For what looks like a simple part, there can be a lot of variables.
Overall length is important, but so is the relationship between rod and chamber lengths.
diameter differences between rod and chamber will also affect how they work.
They are a simple device. Basically a chamber filled with high pressure gas. As the rod is pushed in, it takes up space, so the gas is further compressed. There's nothing else inside.
If the overall length is different, this may cause problems. Too short and it will actually try to prevent full travel of whatever it is attached to, in this case the hood, in others a tailgate, etc. Too long, and it will be applying pressure which may put a strain on something.
The gas pressure will also affect its performance. Higher pressure will aid lifting the hood, but also resist putting it down. It may also put extra strain on pivots.
If the difference between rod diameter and chamber inside diameter is different, the pressure rise as it is compressed will differ from standard. This may help, or not.
Choosing replacements as close as possible to original is always the best bet.