C# how to calculate text length in pixels?

C# how to calculate text length in pixels? The length multiplied by the font is not an option, it is not always correct work.
April 4th 20 at 00:50
2 answers
April 4th 20 at 00:52
April 4th 20 at 00:54
Approximately
// Set up string.
string measureString = "Measure String";
Font stringFont = new Font("Arial", 16);

// Measure string.
SizeF stringSize = new SizeF();
stringSize = e.Graphics.MeasureString(measureString, stringFont);

Find more questions by tags C#