using System.Windows.Forms; // for TextRenderer
Size size=TextRenderer.MeasureText(g, str, f, new Size(), TextFormatFlags.NoPadding);
Alternative Managed API:
g - is the Graphics object you want to draw on
str - the string that should be measured
f - the font you want to use
new Size() - just a dummy parameter