Quick Answer — Converting Gauge to Stitch and Row Counts
Stitches per Inch = (Gauge Stitch Count)/(Swatch Size). A pattern's gauge line — something like "20 sts and 28 rows = 4in in stockinette" — states stitches and rows per a reference swatch size, almost always 4in or 10cm.
The reliable way to hit a target finished measurement is to use your own actual gauge, not the pattern's: Stitches to Cast On = Target Width × Your Stitches per Inch, and the same for rows against target length. This works correctly no matter how far your gauge is from the pattern's, because you're building directly from your fabric's real density.
The second common need is adapting a specific number the pattern gives you — a sleeve cast-on, a set number of stitches for a cuff — to your gauge: Adjusted Stitch Count = Pattern Stitch Count × (Your Stitches per Inch)/(Pattern Stitches per Inch).